网站/WordPress从虚拟主机搬家到VPS上

拖了一个月终于着手并且完成了。其实没有什么难的。但是因为我对Linux的了解非常局限,还是花了一番功夫,同时学了很多东西,在这里记一下。没有试图写一篇“手把手教你搬WP”,只是记录一些我觉得有帮助的东西,希望做同样的事情的且同样不是那么牛逼的Linux学习者们有用:)

虽说是WordPress搬家,但是任何一个小型网站搬家都差不多这样了吧,嘿嘿。

如果用cPanel和MySQLAdmin之类的东西可能就很傻瓜,但是第一cPanel太贵了(竟然要425多刀一年,我都笑了),第二VPS都买了必须必须要抓住每一个学Linux的机会啊。

过程如下(断断续续弄了好几天…):

环境

虚拟主机和VPS都是host2ez的,最牛逼的主机提供商。系统是CentOS Linux 5.6,apache(现在改名叫httpd)已经装好了,再装

yum php mysql mysql-server

就成。

文件

这个简单,cPanel把虚拟主机上文件打包,VPS上wget下来就好。WP的独立性做的好,文件路径改变不会有什么问题。备份用的插件BackUpWordpress倒因为出问题了,不能识别路径,我直接禁用掉了,VPS嘛马上弄个备份方案还不容易,不需要用WP的插件了。在[wordpress path]/wp_config.php里把信息改一下,数据库部分的怎么改见下面。

数据库

对数据库命令不了解的同学建议先看一下mysql的教程。我不能把所有操作都写出来…这次弄这个还学了不少数据库的东西…tutorial很容易搜到,我觉得有一个比较好的命令列表点 这里,里面包括了所有常用的命令。

在虚拟主机的cPanel – mysqladmin里备份出.sql文件,传上VPS,导入文件的命令是

mysql – u user_name -p database_name < file_name.sql

很多地方写的-p后面跟密码,我用的版本-p后面不跟东西,回车以后才提示输密码,可能是新版本不提倡显式输入密码了吧。非要用的话就–password=”xxxxxx”

如果你导出文件选的是整个mysql,需要打开文件把database”information_schema”部分删掉,否则会失败,这个db貌似是mysql自己的,不能改..不懂

之后要建立一个用户并给此用户分配使用相应db的权限,虽然我们也可以直接把root用户写进wp_config.php但是稍微有点安全意识的程序员都不会想要这么做的…虽然权限没什么大不了的,但是名字叫root就是不行! 所以进数据库:

mysql -u root -p

进去以后添加用户:

mysql> create user 'username'@'localhost' identified by 'mypass';

分配权限:

mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;

然后就把这个用户甩给Wordpress啦(编辑wp_config.php)

测试的时候有一些问题

上面完了就能http进vps的ip看到博客了,但是不要去点任何东西…因为数据库里“本站”的地址还是原来的域名,这样如果你原来的网站还开着那么随便点个链接就进到原来网站了,如果没开那就can’t find page啦。

而且因为没法进后台改,所以只好进mysql改了

mysql> use viaxlcom_viaxlcom;
mysql> select * from wp_options where option_value rlike "^http";
+-----------+---------+-------------+----------------------------+----------+
| option_id | blog_id | option_name | option_value               | autoload |
+-----------+---------+-------------+----------------------------+----------+
|         2 |       0 | siteurl     | http://axlarts.com/blog      | yes      |
|        39 |       0 | home        | http://axlarts.com           | yes      |
|        41 |       0 | ping_sites  | http://rpc.pingomatic.com/ | yes      | 
+-----------+---------+-------------+----------------------------+----------+
3 rows in set (0.06 sec)
update wp_options set option_value="http://12.34.56.78/blog" where option_id=2;
update wp_options set option_value="http://12.34.56.78" where option_id=39;

这样就把VPS上的网站地址改成本身的IP了。

————————————-
另外我发现一些插件会出现权限问题,比如JW player(放flv视频用的插件),没法启用插件因为提示不能写目录,我整个www目录都是755权限,设置成777以后可以开启了,然后再弄回来。这个问题解决了但是原因一直不知道,直到我因为另一个问题搜了一下才搞明白。

另一个问题是:更新插件update的时候会提示我输入ftp帐号,以前没这事啊,于是我就去装了个vsftpd(ftp的服务端),设置好能更新了,但是为什么?后来搜到这篇文章 <Auto Update WordPress Without FTP> 解决了ftp的问题并且意识到上面的问题也和这个有关系,即因为目录的owner不是httpd,所以网站脚本没有对文件操作的权限。

/var/www目录的owner要设置成httpd的运行者(可以用ps aux或者top命令查看),可能是www,apache或者nobody或者其他的。我的是apache,所以在chown apache:apache /var/www -R之后update就不用输ftp了,我立刻关了vsftpd依然ok,可见之前是绕了弯子了,没权限还用ftp操作文件…

绑域名

进godaddy面板直接改A地址就好了,没有别的要操作的。

但是因为我本来虚拟主机上就放了两个网站,所以怎么在一个VPS上绑定多个域名多个网站?之前用cPanel是傻瓜操作,没有怎么弄?这个我也弄了好半天最终解决了,马上再写一篇单独说吧

好啦好啦,到此结束,路人有问题可以在下面留言~

25,554 thoughts on “网站/WordPress从虚拟主机搬家到VPS上

  1. CoryImity

    Genuinely well crafted writing, the kind that makes the topic look easier than it actually is, and a look at fossera added even more depth, you can feel the experience behind every line which is something only writers who have been at this for a while can pull off with this level of grace.

    Reply
  2. Ernestbew

    Really appreciate the confidence to make a clear point rather than hedging everything, and a quick visit to discovermoreoffers maintained the same direct stance, writing that takes positions rather than equivocating is more useful even when the positions are debatable because at least the reader has something to react to clearly.

    Reply
  3. Jeffreigh

    Bookmark earned, share earned, return visit earned, all from one reading session, and a look at zenvaxo did the same, the trifecta of bookmark and share and return is rare in a single visit and represents the highest level of engagement I tend to offer any piece of online content these days here.

    Reply
  4. Oliverscoox

    Now feeling the post has earned a proper recommendation rather than a casual mention, and a stop at hazeherb reinforced the recommendation strength, the difference between mentioning and recommending is a small editorial distinction I observe in my own conversations and this site has earned the upgraded recommendation level from me confidently today.

    Reply
  5. JosiahHop

    A piece that respected the reader by not over explaining the obvious, and a look at xavnora continued that calibrated approach, finding the right level of explanation is one of the harder editorial calls and this site has clearly thought carefully about what readers will already know versus what they need help with consistently.

    Reply
  6. Germanglach

    Reading this with a notebook open turned out to be the right move, and a stop at lilacneedle added more material to the notes, content that justifies active note taking from a passive reader is content with real informational density and this site is producing notes worthy material at a high rate consistently.

    Reply
  7. GinoImamy

    Started thinking about my own writing differently after reading, and a look at movlino continued that reflective effect, content that influences how I work rather than just informing what I know is content with the highest kind of impact and this site has triggered some of that reflective influence today on me.

    Reply
  8. Asherhiday

    Quietly the post solved something I had been turning over without quite knowing how to phrase the question, and a look at stylemixo extended that quiet solving, content that addresses unformulated needs is content with reader insight and this site has demonstrated that insight at a high rate across the pieces I have read recently.

    Reply
  9. Bufordknigo

    Stands apart from similar pages by actually being useful, that is high praise these days, and a look at wattedge kept that standard going, you can tell when a site is built around the reader versus around metrics and this one clearly belongs to the first category for sure based on what I read.

    Reply
  10. ArnoldLop

    Got something practical out of this that I can apply later this week, and a stop at qenmora added more details to think about, this is exactly the kind of content I bookmark for future reference rather than the throwaway listicles that dominate most search results these days for almost any common topic.

    Reply
  11. Eanabots

    Top tier post, the kind that makes you want to share the link with friends working in the same area, and a stop at luxrova only made me more confident in doing that, this site is one of the better resources I have seen on the topic recently across both new and older posts.

    Reply
  12. Jeffjaf

    Useful read, especially because the writer did not assume too much background from the reader, and a quick look at gladfir continued in the same way, a thoughtful site that meets people where they are which is something the modern web could use a lot more of for both casual and serious readers.

    Reply
  13. HarrisonAbard

    My usual pattern is to skim and bounce but this site has reset that pattern temporarily, and a stop at hiltgem maintained the slower reading mode, content that changes how I read is content with structural influence and this site has clearly nudged my reading behaviour toward something better at least for the duration of these visits.

    Reply
  14. Domenichewly

    Closed my email tab so I could read this without interruption, and a stop at mintvendor earned the same protected attention, when content is good enough to defend against the usual digital distractions you know it deserves better than the half attention most online reading gets in a typical busy day.

    Reply
  15. ZacharyFab

    Reading this triggered a small change in how I think about the topic going forward, and a stop at ebonfig reinforced that subtle shift, the rare content that actually moves my thinking rather than just confirming or filling it is the kind I most value and this site is providing that kind of impact today.

    Reply
  16. Oliverscoox

    Now feeling the post has earned a proper recommendation rather than a casual mention, and a stop at hazeherb reinforced the recommendation strength, the difference between mentioning and recommending is a small editorial distinction I observe in my own conversations and this site has earned the upgraded recommendation level from me confidently today.

    Reply
  17. MattAmale

    My usual response to new bookmarks is to forget them but this one I have already returned to twice, and a look at urbivio pulled me back a third time, the actual return rate to bookmarked sites is the real measure of value and this one is clearing that measure at a notable rate already.

    Reply
  18. Christopherfuh

    Started reading and ended an hour later without realising the time had passed, and a look at curatedglobalcommerce produced the same time dilation effect, when content makes time feel different the writer has achieved something well beyond the average and this site is producing that experience for me reliably across multiple readings.

    Reply
  19. SamsonLar

    Once you find a site like this the search for similar voices begins, and a look at jumbohelm extended the search energy, finding a high quality reference point makes the gap between it and adjacent sources visible in a way it was not before and this site has provided that high reference point across multiple recent visits.

    Reply
  20. KyrieBiz

    Spent a few minutes here and came away with a clearer picture of the topic, the writing keeps things simple without dumbing them down, and after a stop at modcove the rest of the points lined up neatly which is something I appreciate when I am short on time and need answers fast.

    Reply
  21. RaulLof

    Even on a quick first read the substance of the post comes through, and a look at cartrivo reinforced that immediate quality, content that does not require a slow careful read to demonstrate value but rewards one anyway is content with real depth and this site has produced work of that demanding depth class.

    Reply
  22. BasilCen

    Thanks for the breakdown, it gave me a clearer picture of something I had been confused about for a while now, and a stop at tirzani closed the remaining gaps in my understanding nicely, no need to hunt around twenty other articles to put the pieces together which is a real time saver.

    Reply
  23. CoryImity

    Decided this was the best thing I had read all morning, and a stop at fossera kept that ranking intact, ranking my reading is something I do mentally throughout the day and the top rank is competitive and not easily won but this site won it without needing to overstate its claims for that.

    Reply
  24. Asherhiday

    Probably this is one of the better quiet successes on the open web at the moment, and a look at stylemixo reinforced that quiet success quality, sites that are doing well without making a noise about doing well are the sites I most respect and this one has clearly chosen the quiet success path consistently throughout.

    Reply
  25. Eanabots

    Even from a single post the editorial care is clear, and a stop at luxrova extended that care across more pages, the kind of attention to quality that shows up in every paragraph is what separates serious sites from the rest and this one has clearly invested in that paragraph level attention across what I have read.

    Reply
  26. Bobbyphalk

    Worth bookmarking and sharing with anyone interested in the topic, that is my honest take, and a stop at seotrail reinforces that, the kind of generous resource that makes the open web feel worth defending against the constant pressure to retreat into walled gardens and curated feeds today everywhere I look across all my devices.

    Reply
  27. MorrisAspef

    Felt mildly happier after reading, which sounds silly but is true, and a look at mutelion extended that small mood lift, content that improves rather than degrades my mental state is content I want more of and the cumulative effect of reading sites that lift versus sites that drag is real over time.

    Reply
  28. HarrisonAbard

    Found something new in here that I had not seen explained this way before, and a quick stop at hiltgem expanded the idea even further, the kind of writing that nudges your thinking forward a bit without forcing the issue is exactly what I look for online today and rarely actually find anywhere.

    Reply
  29. Lukeduand

    After reading several posts back to back the consistent voice across them is impressive, and a stop at milknorth continued that voice consistency, sites that maintain a single coherent voice across many pieces by potentially many writers represent serious editorial discipline and this one has clearly developed the institutional consistency needed for that.

    Reply
  30. Bendreda

    Honestly impressed by how much useful content sits in such a small post, and a stop at zevarko confirmed the rest of the site packs a similar punch, density without confusion is a hard balance to strike and this site has clearly cracked the code on it across many different topic areas covered.

    Reply
  31. Jamelblatt

    Looking for similar voices elsewhere has come up empty in my recent searches, and a stop at fashionfindshub extended the search frustration, the rare site that does what no other does in quite the same way is precious and this one has clearly developed a particular approach that I have not been able to find duplicates of.

    Reply
  32. Domenichewly

    Honest reaction is that this is the kind of writing I would defend in a conversation about good blog content, and a look at mintvendor reinforced that, the rare site whose work I would actively recommend rather than just tolerate is the kind I want to support through return visits regularly.

    Reply
  33. Trevoroxith

    My time on this site has now extended past what I had budgeted, and a stop at xelvani keeps extending it further, content that overstays its budget in my schedule is content that has earned the extra time and this site has been earning extra time across multiple visits to the point where my schedule needs adjustment.

    Reply
  34. MattAmale

    During the time spent here I noticed the absence of the usual distractions, and a stop at urbivio extended that distraction free experience, content that does not fight my attention with pop ups and modals and aggressive prompts is content that respects me and this site has clearly chosen the respectful approach throughout.

    Reply
  35. RaulLof

    Walked away with a clearer head than I had before reading this, and a quick visit to cartrivo only sharpened that, the writing has a way of cutting through the noise that surrounds most topics online which is something I will definitely remember the next time I am searching for an answer to anything.

    Reply
  36. BruceDiult

    Looking at this from the perspective of someone tired of generic content the contrast is striking, and a look at gladhalo maintained that distinctive feel, sites with strong editorial identity stand out against the bland background of algorithmic content and this one has clearly developed an identity worth recognising through careful attention.

    Reply
  37. Bobbyphalk

    Worth flagging that this approach to the topic is fresh without being contrarian, and a stop at seotrail extended the same fresh angle, finding original perspective on familiar subjects is rare and this site has clearly developed its own way of seeing rather than echoing the dominant takes from elsewhere consistently.

    Reply
  38. Billyhousa

    A piece that read as the work of someone who reads carefully themselves, and a look at lullpebble continued that informed feel, writers who are also serious readers produce work with a different quality and this site reads as the product of someone steeped in good writing rather than just generating content for an audience.

    Reply
  39. Dorianphemo

    Now considering carefully how to share this site with the right audience rather than broadcasting widely, and a look at wattarc extended that careful sharing impulse, content worth sharing carefully rather than spamming is content that has earned a higher kind of recommendation and this site has earned that careful shareability throughout pieces.

    Reply
  40. SamsonLar

    Refreshing to find writing that does not try to manipulate the reader into clicking onto the next page through cliffhangers and forced engagement, and a stop at jumbohelm continued in the same respectful way, this is what reader first design actually looks like in practice rather than just in marketing copy that sounds nice.

    Reply
  41. MorrisAspef

    Liked the careful selection of which details to include and which to skip, and a stop at mutelion reflected the same editorial judgement, knowing what to leave out is just as important as knowing what to include and this site has clearly figured out where that line sits for the topics it covers regularly.

    Reply
  42. Bendreda

    Thank you for not assuming the reader already knows everything, the explanations meet me where I am, and a look at zevarko did the same, that consideration is what makes a site feel welcoming rather than gatekeepy which is sadly the default mood across the modern web today for most subjects covered.

    Reply
  43. Carmineitace

    Now adding this to a list of sites I want to see flourish, and a stop at curlbyrd reinforced that wish, the few sites I actively root for are sites that produce the kind of work I want more of in the world and this one has joined that small list based on what I have read so far.

    Reply
  44. RicoRusty

    A thoughtful piece that did not strain to be thoughtful, and a look at heathfoam continued that effortless quality, when thinking shows up in writing without the writer drawing attention to it you know you are reading something genuinely considered rather than something performing the appearance of consideration which is also common online.

    Reply
  45. Jamelblatt

    Glad I gave this a chance rather than scrolling past, and a stop at fashionfindshub confirmed I made the right call, sometimes the best content is hidden behind unassuming headlines that do not scream for attention and learning to slow down and check those out has paid off many times now across years of reading.

    Reply
  46. Jacksonvot

    Felt the writer did the homework before publishing, the references hold up, and a look at torlumo continued that documented care, content with traceable claims rather than vague assertions is the kind I trust and the lack of bald assertion in this post is one of its quietly impressive qualities for me.

    Reply
  47. Lukeduand

    Started reading without much expectation and ended on a high note, and a look at milknorth continued that arc, content that builds rather than peaks early is a sign of a writer who knows how to structure a piece for sustained reader engagement rather than relying on a strong hook to do all the work.

    Reply
  48. Trevoroxith

    Worth recognising the specific care that went into how this post ended, and a look at xelvani maintained the same careful conclusions, endings are where most blog content falls apart and this site has clearly invested in the closing stretches of its pieces rather than letting them simply trail off when energy fades.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *