网站/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,032 thoughts on “网站/WordPress从虚拟主机搬家到VPS上

  1. Raulevott

    Definitely a recommend from me, anyone curious about the topic should check this out, and a look at silverharborvendorparlor adds even more reason for that, the depth and quality combine to make this site one I will be pointing people toward whenever similar conversations come up over the months ahead at work or socially.

    Reply
  2. ArmandoINEMI

    A satisfying piece in the way that good meals are satisfying rather than just filling, and a look at pebbleaisle extended that satisfaction, the metaphor between content and meals is one I find useful and this site reads as a satisfying meal rather than the empty calories that most content provides for casual readers.

    Reply
  3. CecilMes

    Reading this gave me confidence to make a decision I had been putting off, and a stop at marketpearl reinforced that confidence, content that translates into action in my own life rather than just informing it is content with the highest practical value and this site is generating that action level utility for me lately.

    Reply
  4. JamieItept

    Adding this to my list of go to references for the topic, and a stop at galloheron confirmed the rest of the site deserves the same, definitely the kind of resource that earns its place rather than getting forgotten the moment the next interesting article shows up in my feed somewhere else on the web.

    Reply
  5. Isaiahvep

    Honestly this hits the sweet spot between detail and brevity, no rambling and no shortcuts, and a quick visit to groovehale kept that going across the related pages, the kind of place that respects your attention without trying to grab it through cheap tactics or attention seeking design choices that get tired fast.

    Reply
  6. EvanClork

    Found the writing surprisingly fresh for what is by now a well covered topic, and a stop at heliokindle 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. Deondor

    Sets a higher bar than most of what shows up in search results for this topic, and a look at joustglade did not lower that bar at all, in fact it confirmed the impression, this is the kind of consistency that earns a place in regular rotation for serious readers instead of casual scrollers passing through.

    Reply
  8. Raulevott

    Reading this with my morning coffee turned into reading the related posts with my morning coffee, and a stop at silverharborvendorparlor stretched the morning further, content that pulls breakfast into a reading session rather than just accompanying it is content that has earned a higher claim on my attention than the average article does.

    Reply
  9. Miguelvow

    Thanks for putting this online without locking it behind email signups or paywalls, and a quick visit to flankisle kept that open feel going, content that trusts the reader to come back rather than gating access is the kind of approach I will reward with regular return visits over time happily.

    Reply
  10. Arthurtopsy

    Came here from another site and ended up exploring much further than I planned, and a look at gnarfrost only encouraged more exploration, the kind of place where one click leads to another not through manipulative design but through genuinely interesting content is rare and worth highlighting when found like this somewhere on the open internet.

    Reply
  11. Nickvag

    Reading this triggered a small change in how I think about the topic going forward, and a stop at fancyhale 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
  12. AmariGen

    Glad to have another reliable bookmark for this topic, and a look at harborlark suggested several more pages I will be marking too, building a personal library of trustworthy resources is one of the actual rewards of careful browsing and this site is earning a place on my permanent shortlist for the topic.

    Reply
  13. Isaiahvep

    Over the course of reading several posts here a pattern of quality has emerged, and a stop at groovehale confirmed the pattern, the difference between sites that hit quality occasionally and sites that hit it consistently is huge and this site has clearly demonstrated the consistent kind through what I have read this morning.

    Reply
  14. NoahNow

    During a quiet evening reading session this provided just the right depth without being heavy, and a stop at huskkindle maintained the same evening appropriate weight, content with depth that does not exhaust the reader is content with editorial calibration and this site has clearly figured out how to be substantial without being demanding all the time.

    Reply
  15. MorganSeiva

    A slim post with substantial content per word, and a look at kudosember maintained the same density, the content per word ratio is something I track informally and this site scores high on that ratio compared to most sources I read regularly which is a quiet indicator of careful editorial work behind the scenes.

    Reply
  16. ZachariahBlupe

    Most blog writing on this subject reaches for the same handful of arguments and this post avoided them, and a look at mistvendor continued the original treatment, content that finds its own path through territory other writers have flattened is content with real authorial energy and this site has plenty of that distinctive energy.

    Reply
  17. Jerryhit

    Came away with some new perspectives I had not considered before, and after clingclasp those ideas felt more complete, the kind of content that stays with you a little while after reading rather than slipping out the moment you switch tabs and move on with your day to whatever comes next.

    Reply
  18. Miguelvow

    Really like that there are no exclamation marks or all caps shouting throughout the post, and a quick visit to flankisle maintained the same calm voice, restraint in punctuation signals confidence in the content and this site clearly trusts its substance to do the persuading rather than relying on typographic emphasis.

    Reply
  19. Tobiashon

    Reading the writers other posts after this one suggests the quality is consistent rather than peak, and a stop at gallohex confirmed the consistent quality reading, sites that hold the same level across many pieces rather than peaking on a few are sites with sustainable editorial discipline and this one has clearly developed that.

    Reply
  20. Deondor

    A clean read with no irritations, and a look at joustglade continued that frictionless quality, the absence of small irritations is something I notice only when present elsewhere and this site is one of the rare places where everything just works and lets me focus on the substance rather than fighting the format.

    Reply
  21. NoahNow

    Picked this for my morning read because the topic seemed worth the time, and a look at huskkindle confirmed the choice was right, my morning reading slot is precious and giving it to this site felt like a good investment rather than a waste which is a higher endorsement than I usually offer for content.

    Reply
  22. BenjaminGoach

    Found this through a search that was generic enough I did not expect quality results, and a look at flumelake continued the surprisingly good experience, search engines occasionally still surface excellent independent content if you scroll past the obvious paid and high authority results which is reassuring to remember sometimes.

    Reply
  23. AmariGen

    Reading this prompted me to send the link to two different people for two different reasons, and a stop at harborlark provided ammunition for a third share, content that suits multiple audiences without being generic enough to be useless to any of them is genuinely valuable and this site has that multi audience quality clearly.

    Reply
  24. MorganSeiva

    Picked something concrete from the post that I will use immediately, and a look at kudosember added another concrete piece, content that produces immediately useful output rather than just abstract appreciation is content that earns its place in my regular rotation without needing any further evaluation from me at this point honestly.

    Reply
  25. Ervindep

    Reading this gave me a small mental break from the heavier reading I had been doing, and a stop at thoughtfulcommerceplatform extended that lighter feel, content that provides relief without becoming trivial is harder to produce than people realise and this site has clearly figured out how to be light without being shallow at all.

    Reply
  26. ZachariahBlupe

    Decided to subscribe to the RSS feed if there is one, and a stop at mistvendor confirmed that decision, content that I want delivered to me proactively rather than just remembered when I have time is content that has earned a higher level of commitment from me as a reader looking for reliable sources.

    Reply
  27. JayAgeda

    Just sat with this for a bit longer than I usually would because the points are worth thinking about, and after maplegrovemarketparlor I had even more to chew on, the kind of post that nudges your thinking forward without forcing the issue is something I have always appreciated in good writing online.

    Reply
  28. Jaydenapata

    Liked the careful selection of which details to include and which to skip, and a stop at helmkit 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
  29. Tobiashon

    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 gallohex 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
  30. CameronFlarp

    Saving this link for the next time someone asks me about this topic, and a look at grovefalcon 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
  31. Pablowah

    Thanks for the clean writing, no broken sentences and no awkward translations like some other sites have, and a quick stop at gnarkit kept that polish going nicely, it really does make a difference when a reader can move through a page without tripping on every line or going back to reread.

    Reply
  32. Jesustricy

    Worth recognising the absence of the usual blog tropes here, and a look at fawnetch continued that fresh quality, sites that avoid the standard moves of the medium read as more original even when the content is on familiar topics and this one has clearly chosen its own path through the conventional terrain skilfully.

    Reply
  33. JayAgeda

    Glad to have another reliable bookmark for this topic, and a look at maplegrovemarketparlor suggested several more pages I will be marking too, building a personal library of trustworthy resources is one of the actual rewards of careful browsing and this site is earning a place on my permanent shortlist for the topic.

    Reply
  34. Ervindep

    Reading this triggered a small but real correction in something I had assumed, and a stop at thoughtfulcommerceplatform extended that corrective effect, content that updates my beliefs through evidence rather than rhetoric is content with intellectual integrity and this site has earned that label consistently across the pieces I have read so far today.

    Reply
  35. Lawsonsuime

    Took a few notes from this post, the points are easy to remember without needing to come back and check, and a look at flankivory added a couple more, the kind of place that sticks in the memory long after the browser tab has been closed for the day which says a lot really.

    Reply
  36. BenjaminGoach

    Now feeling confident that this site will continue producing work I will want to read, and a look at flumelake extended that confidence into the future, projecting forward from current quality to expected future quality is something I do for sites I genuinely follow and this one has earned that forward looking trust clearly today.

    Reply
  37. Jaydenapata

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

    Picked a single sentence from this post to remember, and a look at iconflank gave me another to keep, content that produces memorable lines is doing more than just transferring information and the small selection of sentences I keep from each reading session is one of the actual returns I get from reading carefully.

    Reply
  39. 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
  40. CameronFlarp

    Refreshing tone compared to the dry corporate posts on similar topics, and a stop at grovefalcon carried that personality through nicely, you can tell when a real person is behind the writing versus a content team chasing metrics and this site definitely falls into the former category clearly across what I have seen.

    Reply
  41. DeshawnJaine

    The way the post stayed on topic throughout without going on tangents was really refreshing, and a look at oasiscrate kept that focused approach going, discipline like this in writing is rare and worth recognising because most writers cannot resist wandering off into related subjects that dilute their main point and confuse readers along the way.

    Reply
  42. Johanjiz

    Working through this site has been a small antidote to the shallow content that fills most of my reading time, and a stop at iciclemart extended that antidote function, sites that quietly improve the average quality of my reading by being themselves are sites worth supporting through return visits and recommendations consistently.

    Reply
  43. Pablowah

    During a quiet evening reading session this provided just the right depth without being heavy, and a stop at gnarkit maintained the same evening appropriate weight, content with depth that does not exhaust the reader is content with editorial calibration and this site has clearly figured out how to be substantial without being demanding all the time.

    Reply
  44. HughGaway

    Just sat with this for a bit longer than I usually would because the points are worth thinking about, and after clevergoodszone I had even more to chew on, the kind of post that nudges your thinking forward without forcing the issue is something I have always appreciated in good writing online.

    Reply

Leave a Reply

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