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

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

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

  1. RossMow

    Saving this link for the next time someone asks me about this topic, and a look at honeymarket expanded what I will be sharing with them, this is the kind of resource that makes a real difference when you are trying to point a friend to something useful and reliable rather than generic marketing pages.

    Reply
  2. AlanBer

    Really appreciate that the writer did not overstate the importance of the topic to make the post feel weightier, and a quick visit to gambitfort maintained the same modest framing, content that is honest about its own scope rather than inflating itself is the kind I trust and return to repeatedly over time.

    Reply
  3. Lawsonsuime

    Quality writing that respects the reader’s intelligence without overloading them, and a quick look at flankivory reflected that approach, a balanced thoughtful site that earns trust by being consistent rather than by shouting about how trustworthy it is which is the usual approach online sadly across most content categories.

    Reply
  4. Nicolasveity

    Better signal to noise ratio than most places I check on this kind of topic, and a look at iconflank kept that going, every paragraph here carries something worth reading rather than padding out the page to hit some arbitrary length target that search engines reward but readers ignore as soon as they notice it.

    Reply
  5. Jesustricy

    A well calibrated piece that knew its scope and stayed inside it, and a look at fawnetch maintained the same scope discipline, scope creep is one of the failure modes of long blog posts and this site has clearly invested in the editorial discipline to prevent it which shows up in tightly contained pieces.

    Reply
  6. Johanjiz

    Found the writing surprisingly fresh for what is by now a well covered topic, and a stop at iciclemart kept that freshness going across the related pages, original perspective on familiar ground is hard to come by and this site has clearly earned its place in the conversation rather than just rehashing old ideas.

    Reply
  7. HughGaway

    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 clevergoodszone the rest of the points lined up neatly which is something I appreciate when I am short on time and need answers fast.

    Reply
  8. Miltonken

    Saving the link for sure, this one is a keeper, and a look at clipchime confirmed I should bookmark the entire site rather than just this page, the consistency across what I have seen so far suggests there is a lot more here worth coming back for soon when I have more time.

    Reply
  9. Kendallploff

    Honestly enjoyed every minute spent here, that is not something I say lightly, and a look at silkgrovevendorroom confirmed I will be back, the bar for spending time online is high for me these days but this site clears it without effort which is high praise indeed from this reader who is usually rather demanding.

    Reply
  10. AlanBer

    The tone stayed consistent across the whole post which is harder than it looks for longer pieces, and a look at gambitfort continued the same voice, this kind of editorial consistency is a sign of either a single careful writer or a tightly run team and either is impressive today across the broader media environment.

    Reply
  11. RossMow

    A piece that left me thinking I had been undercaring about the topic, and a look at honeymarket reinforced that mild concern, content that raises the appropriate weight of a subject without being preachy about it is doing important work and this site is providing that gentle elevation of attention for me consistently.

    Reply
  12. GarrettRoada

    A piece that did not require external context to follow, and a look at depotglow maintained the same self contained quality, content that stands alone without forcing readers to chase prerequisites is more accessible and this site has clearly thought about how each piece can serve a fresh visitor rather than only existing members.

    Reply
  13. RodrigoAgink

    Quietly the post solved something I had been turning over without quite knowing how to phrase the question, and a look at guavaflank 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
  14. WilfredCig

    Started forming counter examples to test the claims and the post handled most of them implicitly, and a look at herbfife continued that anticipatory style, writers who think two steps ahead of the critical reader save themselves from a lot of follow up work and this writer has clearly internalised that habit consistently.

    Reply
  15. DeshawnJaine

    A piece that did exactly what it promised in the headline without overshooting or underdelivering, and a look at oasiscrate continued that calibration, alignment between promise and delivery is a basic editorial virtue that many sites fail at and this site has clearly mastered the matching of expectation and substance throughout pieces.

    Reply
  16. Juliorag

    A genuinely unexpected highlight of my reading week, and a look at globalcuratedgoods extended that pattern, the surprise of finding excellent content rather than the predictable mediocre is one of the few real pleasures of casual web browsing and this site delivered that surprise cleanly today which I really do appreciate.

    Reply
  17. Kendallploff

    Taking the time to read carefully here has been worthwhile for the past hour, and a look at silkgrovevendorroom extended the worthwhile reading, the calculation of return on reading time spent is something I do informally and this site has been producing positive returns across multiple sessions during the last week of regular visits and reads.

    Reply
  18. Timmywap

    Thanks for the simple approach, too many sites bury the actual point under layers of unnecessary words, but here every line earns its place, and a look at idleflint showed the same care for the reader which is something I will remember the next time I need answers on a topic.

    Reply
  19. VernonHam

    However many similar pages I have read this one taught me something new, and a stop at flaskkelp added more new material, content that contributes genuinely fresh information rather than recycling what is already widely available is content with real informational value and this site is providing that informational freshness at a notable rate.

    Reply
  20. Abrahamlax

    Now adjusting my mental model of how the topic fits into the broader landscape, and a look at goldenknack extended that adjustment, content that affects my structural understanding rather than just my factual knowledge is content with deeper impact and this site is providing those structural updates at a meaningful rate consistently across topics.

    Reply
  21. KalNessy

    Better than the average post on this subject by some distance, and a look at fluxhusk reinforced that, you can tell within the first paragraph that the writer here actually cares about the topic rather than just covering it for the sake of having something to publish that week or that day.

    Reply
  22. RodrigoAgink

    Approaching this site through a casual link click and being surprised by what I found, and a look at guavaflank extended the surprise, the rare experience of stumbling into excellent independent content rather than predictable mediocrity is one of the actual remaining pleasures of casual web browsing and this site provided it cleanly.

    Reply
  23. WilfredCig

    Felt the post handled a sensitive angle of the topic with appropriate care, and a look at herbfife extended that careful handling across related material, sites that can navigate delicate territory without causing damage are rare and require a level of judgement that comes from experience rather than from following any clear playbook.

    Reply
  24. Miltonken

    Quietly the post solved something I had been turning over without quite knowing how to phrase the question, and a look at clipchime 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
  25. SheldonMeeno

    Skipped past the first paragraph thinking it was setup and had to come back when the rest referenced it, and a stop at bettershoppingchoice similarly rewarded careful reading from the start, content where every paragraph carries weight is content I now know to read from the beginning rather than skipping ahead.

    Reply
  26. Juliorag

    Came here from a search and stayed for the side links because they were that interesting, and a stop at globalcuratedgoods took me even further into the site, the kind of organic exploration that good content invites is something most sites kill through aggressive interlinking and pushy navigation choices rather than relying on quality.

    Reply
  27. NicoSounk

    Worth pointing out that the post avoided the temptation to summarise everything at the end, and a look at gildvendor continued that confident closing approach, content that trusts readers to retain the substance without being reminded of it at the end is content that respects the reader and this site practices that respect.

    Reply
  28. Timmywap

    Skipped the comments to avoid spoilers and came back later to find them genuinely worth reading, and a stop at idleflint extended that surprised respect, when the discussion below a post matches the quality of the post itself you have found something special and this site appears to attract that kind of audience.

    Reply
  29. RonWap

    Solid value for anyone willing to read carefully, and a look at gambitgulf extends that value across the rest of the site, this is the kind of place that rewards return visits rather than offering everything in a single splashy post and then leaving readers nothing to come back for later which is unfortunately common.

    Reply
  30. VernonHam

    Found something new in here that I had not seen explained this way before, and a quick stop at flaskkelp 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
  31. Prestonsut

    Time spent here today felt productive in the way that good reading sessions sometimes do, and a stop at olivevendor extended that productive feeling across the rest of the morning, the difference between productive reading and merely passing time is real and this site is consistently on the productive side for me lately.

    Reply
  32. Abrahamlax

    Started imagining how I would explain the topic to someone else after reading, and a look at goldenknack gave me more material for that imagined explanation, content that improves my own ability to discuss a topic is content that has actually transferred knowledge rather than just decorating my screen for a few minutes.

    Reply
  33. Jermaineked

    Honestly this was a good read, no jargon and no padding, and a short look at fawngate kept that same feel going which I really appreciated, the writer clearly knows the topic well enough to explain it without hiding behind big words or filler that often gets used to seem clever.

    Reply
  34. SheldonMeeno

    If quality blog writing is dying as people sometimes claim then this site is one piece of evidence that it has not died yet, and a look at bettershoppingchoice extended that evidence, the broader cultural question about online writing has empirical answers in specific sites and this one is contributing to a more optimistic answer overall.

    Reply
  35. RonWap

    Took something from this I did not expect to find, and a stop at gambitgulf added another unexpected useful piece, content that exceeds expectations rather than just meeting them is the kind that builds enthusiasm and earns repeat visits without any explicit ask from the writer or platform behind the work being read.

    Reply
  36. Oliverknino

    Good clean post, no errors and no awkward phrasing that breaks the reading flow, and a stop at orchardharborvendorparlor kept the same standard, definitely the kind of editorial care that earns a return visit because it tells me the writer is paying attention to details that matter to readers rather than just rushing publication.

    Reply
  37. NicoSounk

    Decided not to skim despite my usual habit and was rewarded for the discipline, and a stop at gildvendor earned the same patient approach, training myself to recognise sites that warrant slower reading is part of being a careful online reader and this site is the kind that helps me practice that skill regularly.

    Reply
  38. KalNessy

    If you scroll past this site without looking carefully you will miss something, and a stop at fluxhusk extended that mild warning, the surface of the site does not advertise its quality loudly which means careful attention is required to recognise what is being offered here which is itself a kind of editorial signal.

    Reply
  39. Prestonsut

    Appreciated that the writer trusted the reader to follow along without constant restating of earlier points, and a look at olivevendor continued that respect for the reader, treating an audience as capable adults rather than as people to be hand held through every paragraph is something I notice and value highly across the open internet today.

    Reply

Leave a Reply

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