网站/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是傻瓜操作,没有怎么弄?这个我也弄了好半天最终解决了,马上再写一篇单独说吧

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

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

  1. OtisNib

    Now considering the post as evidence that careful blog writing is still possible, and a look at ponymedal extended that evidence, the broader question of whether the modern web can sustain quality writing has obvious empirical answers in sites like this one and seeing them is reassuring even when they remain a minority overall today.

    Reply
  2. Santiagorop

    Worth pointing out the careful word choice in this post, no buzzwords and no jargon, and a look at nuartlion continued that disciplined vocabulary, sites that resist the pull of trendy language are sites that will read well in five years and this one is clearly built for that kind of long durability.

    Reply
  3. CooperJeoxy

    Reading this on a long flight and finding it the best thing I read across hours of trying, and a stop at rafterpeach kept the streak going, when content beats long flight reading you know it has substance because flight reading is a hard test of a piece given the alternatives available everywhere.

    Reply
  4. KevinDuema

    Steam Desktop Authenticator https://sdasteam.com (SDA). It allows you to generate account login codes and automatically confirm trades or item sales on the Community Market without using your smartphone.

    Reply
  5. Billycrask

    Felt the post had been written without using a single buzzword, and a look at norqavo continued that clean vocabulary, content free of jargon and trendy phrases reads better and ages better and this site has clearly committed to a vocabulary that will not feel dated in three years which is impressive editorially.

    Reply
  6. Arthursnurb

    Excellent post, balanced and well organised without showing off, and a stop at purplemarsh continued in that same vein, this site has clearly figured out the formula for content that works for readers rather than for search engine ranking signals which is harder than it sounds today and worth real recognition from anyone.

    Reply
  7. JesusBrats

    Thanks for putting in the work to make this approachable, plenty of sites cover the same ground but most do it badly, and a quick visit to molqiro confirmed this one stands apart, simple language and useful examples without anyone trying to sell me anything along the way which I really appreciated.

    Reply
  8. RoccoApers

    A clear cut above the usual noise on the subject, and a look at domelounge only made that gap wider in my view, the kind of place that earns its visitors through quality rather than through aggressive marketing or sponsored placements which is increasingly the only way most sites stay afloat across the modern web.

    Reply
  9. OtisNib

    Picked this for a morning recommendation in our company chat, and a look at ponymedal suggested I will mention this site again later, recommending content into a workplace context is a small editorial act that requires confidence in the recommendation and this site is making me confident in those recommendations consistently here too.

    Reply
  10. Horacekib

    Liked the balance between depth and brevity, never too shallow and never too long, and a stop at qunvero kept the same balance going across the rest of the site, this is one of the harder skills in writing and the team here clearly has it figured out very well indeed across every page.

    Reply
  11. Santiagorop

    Reading this slowly because the writing rewards a slower pace, and a stop at nuartlion did the same, the pace at which I read content is something I now use as a quality signal and writing that earns a slower pace earns my attention as a reader looking for substance these days.

    Reply
  12. CooperJeoxy

    Honestly impressed, did not expect to find this level of care on the topic, and a stop at rafterpeach cemented the impression, you can tell within the first few paragraphs whether a site is going to be worth the time and this one delivered on that early promise nicely throughout the rest of what I read.

    Reply
  13. GarrettAvoip

    Once you start reading carefully here it is hard to go back to lower quality alternatives, and a stop at lionpilot reinforced that ratchet effect, the way good content raises standards is real over time and this site has clearly contributed to raising my expectations for what is possible in writing on the topic generally.

    Reply
  14. RoccoApers

    Solid stuff, the kind of post that I will probably refer back to later this month when the topic comes up again, and a look at domelounge only confirmed I should bookmark the site as a whole rather than just this single page for future reference and use across coming weeks.

    Reply
  15. Billycrask

    Solid quality, the kind of work that holds up to a careful read rather than a quick skim, and a quick look at norqavo kept that standard going strong, content that rewards attention rather than punishing it is something I appreciate more and more these days online across nearly every topic I follow.

    Reply
  16. Davionasymn

    Started reading and ended an hour later without realising the time had passed, and a look at muralpeony 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
  17. GarrettAvoip

    Reading this slowly because the writing rewards a slower pace, and a stop at lionpilot did the same, the pace at which I read content is something I now use as a quality signal and writing that earns a slower pace earns my attention as a reader looking for substance these days.

    Reply
  18. Horacekib

    Strong recommendation from me, anyone curious about the topic should make time for this, and a look at qunvero only sharpens that recommendation further, the kind of resource that holds up against careful scrutiny rather than crumbling at the first critical question is rare and worth pointing other people toward when the topic comes up.

    Reply
  19. Brandongic

    Worth recognising the specific care that went into how this post ended, and a look at masonotter 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
  20. Linwoodsture

    Great work on keeping things readable, the post never drags or repeats itself which I really appreciate, and a stop at rakemound added a bit more context that fit naturally with what was already said here, no need to read everything twice to get the point being made today.

    Reply
  21. KevinDuema

    Steam Desktop Authenticator https://sdasteam.com (SDA). It allows you to generate account login codes and automatically confirm trades or item sales on the Community Market without using your smartphone.

    Reply
  22. Davionasymn

    Now feeling that this site is the kind I want to make sure does not disappear, and a look at muralpeony reinforced that quiet protective feeling, the rare sites whose disappearance would actually matter to me are the sites I want to support through return visits and recommendations and this one has joined that small protected list.

    Reply
  23. Linwoodsture

    If the topic interests you at all this is a place to spend time, and a look at rakemound reinforced that recommendation, the broader question of where to invest topical reading time is one this site answers convincingly through the consistent quality across multiple pieces I have sampled during the current reading session today.

    Reply
  24. Derekadvor

    Felt like the writer was speaking directly to someone with my level of curiosity, neither talking down nor showing off, and a stop at domemarina kept that comfortable matching going, finding writing that meets you where you are rather than asking you to climb up or stoop down feels great every time it happens.

    Reply
  25. TrentHoism

    Really like the way the post resists reaching for cliches that would have made it feel generic, and a quick visit to liquidnudge kept that fresh feel going, original phrasing and unexpected metaphors are signs that the writer is actually thinking rather than just stitching together familiar phrases into the appearance of content.

    Reply
  26. Marshallhix

    Took my time with this rather than rushing because the writing rewards attention, and after molvani I had even more to absorb, the kind of content that pays back the patient reader rather than punishing them with empty filler is something I look for and rarely find in regular searches lately.

    Reply
  27. Brandongic

    Now placing this in the small category of sites whose updates I would actually want to know about, and a stop at masonotter confirmed that placement, the difference between sites I want to follow and sites I just consume from is real and this one has crossed into the active follow category from the casual consumption side.

    Reply
  28. TrentHoism

    Liked how the writer used real examples instead of theoretical ones to make the points stick, and a stop at liquidnudge added even more concrete examples, this is the kind of practical approach that respects readers who actually want to apply what they learn rather than just nodding along passively without doing anything useful.

    Reply
  29. Derekadvor

    Looking at the surface design and the substance together this site has both right, and a look at domemarina reinforced that integrated quality, sites where presentation and content reinforce each other rather than fighting are sites with full editorial coherence and this one has clearly invested in both layers in a balanced way.

    Reply
  30. Kaielifs

    Now adding a small note in my reading log that this site is one to watch, and a look at rampantpilot reinforced the watch status, the few sites I track deliberately rather than encounter accidentally are sites I expect ongoing returns from and this one has cleared the bar for that elevated tracking based on what I read.

    Reply
  31. Cadenhieve

    Looking for similar voices elsewhere has come up empty in my recent searches, and a stop at norzavo 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. CharlieEvesS

    Closed the tab with a small sense of finality rather than the usual rushed exit, and a stop at muscatlarch produced the same considered closing, when reading ends with deliberate satisfaction rather than impatient skip you know the time was well spent and this site is producing those satisfying endings consistently across what I read.

    Reply
  33. Marshallhix

    Came away feeling slightly smarter than I was when I started, that is a real win, and a stop at molvani added a bit more to that, the rare site that actually transfers some of its knowledge to the reader in a way that sticks rather than just creating an illusion of learning briefly.

    Reply
  34. Clydetip

    Different feel from the algorithmically optimised posts that dominate the topic, and a stop at quvnero reinforced that human touch, you can tell when a site is being run by someone who reads what they publish versus someone just hitting submit and moving on quickly to the next assignment without checking the result.

    Reply
  35. LowellBen

    I usually skim posts like these but this one held my attention all the way through, and a stop at sodatorch did the same, that is a strong endorsement coming from me because I am usually quick to bounce when content gets repetitive or fails to deliver on its initial promise made in the headline.

    Reply
  36. TimothyRib

    Now noticing that the post avoided the temptation to be funny in places where humour would have undermined the substance, and a stop at twainsilica maintained the same restraint, knowing when to be serious is a rare editorial virtue and this site has clearly developed it through what I assume is careful editorial practice over years.

    Reply
  37. KileTaw

    One of the more thoughtful posts I have read recently on this topic, and a stop at lithelight added even more weight to that impression, this is genuinely good content that holds its own against far better known sites in the same space without trying to imitate any of them at all which I appreciate.

    Reply
  38. Kaielifs

    Anyone curious about this topic would do well to start here, the foundation laid is solid, and a stop at rampantpilot would round out their understanding nicely, this is the kind of resource I would point a friend toward without hesitation if they asked me where to begin learning about anything in this area.

    Reply
  39. CoreyWal

    Decided this was the best thing I had read all morning, and a stop at tinklesaddle 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
  40. EmilianoJer

    Most attempts at writing on this topic feel like they are missing something and this post finally identified what was missing, and a look at spryring extended that diagnostic clarity, content that names what is wrong with adjacent treatments while doing better itself is content with both critical and constructive value and this site has both.

    Reply
  41. Vladimirzow

    Now placing this in the same category as a few other sites I have come to trust, and a look at safaritriton continued the placement decision, the small category of fully trusted sites is one I extend rarely and only after multiple positive reading sessions and this site has earned the category placement methodically over time.

    Reply
  42. Linwoodlob

    A piece that read smoothly because the writer understood how readers actually move through prose, and a look at solotoffee maintained the same reader awareness, writers who think about the reading experience as much as the writing experience produce better work and this site has clearly made that shift in editorial approach.

    Reply
  43. RicardoBrarm

    Thank you for being clear and direct, that simple approach saves so much frustration on the reader’s end, and a stop at draftglade only made me more sure of it, the rest of the content seems to follow the same pattern which is a great sign of consistent editorial care behind the scenes.

    Reply
  44. AlfredoDions

    A piece that brought a sense of order to a topic I had been finding chaotic, and a look at scenictrader continued that organising effect, content that imposes useful structure on messy subjects is doing genuine intellectual work and this site is providing that organisational function across multiple posts I have read recently here.

    Reply

Leave a Reply

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