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

  1. Jaimesit

    Better signal to noise ratio than most places I check on this kind of topic, and a look at veilshrine 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
  2. BjornTaw

    Reading this in a moment of low energy still kept my attention, and a stop at turtleudon continued that engagement under suboptimal conditions, content that survives the reader being tired is content with extra reserves of pull and this site has the kind of writing that holds up even when I am not at my reading best.

    Reply
  3. Ronniekeype

    Worth recognising the absence of the usual blog tropes here, and a look at taupeswift 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
  4. Todmes

    Following the post through to the end without my attention drifting once, and a look at pebbleorbit earned the same uninterrupted attention, content that holds attention without manipulating it is content with substantive pull and this site has demonstrated that substantive pull across multiple pieces in a single reading session reliably here today.

    Reply
  5. Franciscodup

    If you scroll past this site without looking carefully you will miss something, and a stop at inobrat 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
  6. Brysonlar

    Worth a quiet moment of recognition for the consistency I have noticed across multiple posts, and a stop at spectrasolo continued that consistent quality, sites that maintain quality across many pieces rather than peaking on one viral post are sites with real editorial discipline and this one has clearly developed that discipline carefully.

    Reply
  7. RufusIngep

    Liked that the post resisted a sales pitch ending, and a stop at sampleshaft maintained the no pitch approach, content that ends without trying to convert me into a customer or subscriber is content that has confidence in its own value and this site is clearly playing the long game on reader trust.

    Reply
  8. TerranceHic

    If I had to defend the time I spend reading independent blogs this site would feature in the defence, and a look at snoozestaple reinforced that defensive utility, the ongoing case for non algorithmic reading is one I make to myself periodically and sites like this one provide the actual evidence that supports the case clearly.

    Reply
  9. Jadoncypop

    Liked the way the post got out of its own way, and a stop at swordtunic extended that invisible craft, the best writing you barely notice while reading because it is doing its work without drawing attention to itself and this site has clearly mastered that disappearing act across the pieces I have read.

    Reply
  10. GaryOnelo

    Skipped breakfast still reading this and finished hungry but satisfied, and a stop at jamcall kept me past breakfast time, content that displaces basic biological needs is content with serious attentional pull and the writers here are clearly capable of producing that level of engagement which is genuinely impressive these days.

    Reply
  11. Micaherors

    Beyond the topic at hand this site reads as a small ongoing project of taking writing seriously, and a look at discovermeaningfulideas reinforced that project quality, sites that treat publishing as an ongoing serious practice rather than as content production for traffic are sites worth supporting and this one has clearly chosen the serious approach.

    Reply
  12. MarkStida

    Highly recommend to anyone looking for a sensible take on this topic without the usual marketing nonsense, and a look at siriussuperb kept that grounded approach going, sites that stay focused on serving readers rather than monetising every click are rare and this is clearly one of those rare ones I really appreciate finding.

    Reply
  13. KalHek

    Glad I stumbled across this post, the explanations actually make sense without needing background knowledge to follow along, and after a stop at zunqavo the same was true there, no assumptions about the reader just clear writing that anyone can understand from the first line right through to the end.

    Reply
  14. Connerblelp

    Now feeling that this site is the kind I want to make sure does not disappear, and a look at caroxo 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
  15. EmersonGROCK

    Worth flagging this site to a few specific friends who would appreciate the editorial sensibility, and a look at gadblow added more pages I will mention to them, recommending sites to specific people requires understanding both the site and the person and this site is making those personalised recommendations easy and natural for me.

    Reply
  16. BjornTaw

    Now thinking about whether the writer might publish a longer form work I would buy, and a look at turtleudon suggested the same depth would translate, content that makes me want to pay for related work in other formats is content that has earned commercial trust as well as attention trust and this site has both clearly.

    Reply
  17. Drewmonna

    Reading this gave me a small framework I expect to use going forward, and a stop at savorvantage extended that framework, content that produces transferable mental models rather than just specific facts is content with multiplicative value and this site is providing those models at a rate that justifies extra attention from me regularly.

    Reply
  18. Todmes

    Worth every minute of the time spent reading, and a stop at pebbleorbit extends that value across more pages, in a media environment where most content is engineered to waste attention this site stands out by treating reader time as something valuable rather than something to be exploited and stretched as far as possible.

    Reply
  19. KalebSew

    Started reading expecting to disagree and ended mostly nodding along, and a look at hanrim continued the pattern, content that wins agreement through evidence and reasoning rather than rhetorical force is the kind that actually shifts minds and this site clearly knows how to do that across what I have read so far.

    Reply
  20. Ryanpal

    Really like that the writer trusts the reader to follow simple logic without restating every previous point, and a stop at snaresaffron kept that respect going, treating an audience as capable adults rather than as people who need constant hand holding makes a noticeable difference in the reading experience for me.

    Reply
  21. MauriceFluen

    Just want to acknowledge that the writing here is doing something right, and a quick visit to hoxhem confirmed the same standards run across the broader site, recognising good work is something I try to do when I find it because the alternative is silence and silence rewards mediocrity.

    Reply
  22. Pierreteern

    A small thing but the line spacing and font choices made reading this physically pleasant, and a look at mercypillow maintained the same careful design, technical choices about typography are part of what makes online reading actually comfortable and this site has clearly invested in the design layer alongside the content layer carefully.

    Reply
  23. TateRig

    If I were grading sites on this topic this one would receive high marks, and a stop at sprystep continued earning those high marks, the informal grading I do mentally for content sources is something I take seriously even though it is informal and this site has been receiving consistent high marks across multiple sessions today.

    Reply
  24. Ronniekeype

    Thanks for not padding this with the usual filler intros and outros that every other blog seems to require, and a quick visit to taupeswift continued that lean approach across more posts, content stripped of waste is content that respects you and I will always come back to that kind of approach.

    Reply
  25. Micaherors

    Felt this in a way I cannot quite explain, the topic just hit different here, and a stop at discovermeaningfulideas continued in that vein, sometimes you find a site whose perspective lines up with how you have been thinking and reading their work feels like a small relief which I appreciated more than I expected.

    Reply
  26. MarkStida

    Looking through the archives suggests this site has been doing this for a while at this level, and a look at siriussuperb confirmed the long term consistency, sites that have maintained quality across years rather than just a recent stretch are sites with serious editorial discipline and this one has clearly been at it for a while.

    Reply
  27. RufusIngep

    Closed the laptop after this and let the ideas settle for a few hours, and a stop at sampleshaft similarly rewarded reflective time, content that benefits from sitting with rather than racing past is the kind I want more of and the kind that this site appears to consistently produce week after week here.

    Reply
  28. Jadoncypop

    Reading this prompted a small note in my reference file, and a stop at swordtunic prompted another, the rare site that contributes useful nuggets to my own working knowledge rather than just consuming my attention is worth the time investment many times over compared to the usual pile of forgettable scroll content.

    Reply
  29. Connerblelp

    Took me back a step or two on an assumption I had been making, and a stop at caroxo pushed that reconsideration further, writing that gently corrects the reader without being aggressive about it is a rare diplomatic skill and the team here clearly knows how to land critical points without turning readers off.

    Reply
  30. Wyatttoomi

    Reading this with a fresh mind in the morning brought out details I might have missed in the afternoon, and a stop at scarabvogue earned the same fresh attention, content that rewards being read at full attention rather than at energy lows is content with real density and this site has that density consistently.

    Reply
  31. CoreyOweme

    A piece that handled the topic with appropriate weight without becoming portentous, and a look at tasselskein continued that calibrated seriousness, content that takes itself seriously without becoming pompous is something this site has clearly figured out and the balance shows up in every piece I have read across multiple sessions now.

    Reply
  32. Daxicolo

    The headings made navigating the post simple even when I needed to find a specific section quickly, and a look at triggersyrup continued the same thoughtful structure, small details like clear headings show that someone is actually thinking about how the reader uses the page rather than just filling it for length alone.

    Reply
  33. TerranceHic

    Coming back tomorrow when I can give this a proper read, the post deserves better attention than I can give right now, and a look at snoozestaple suggests there is plenty more here that deserves the same treatment, definitely a site I will be exploring properly over the next few days when I can.

    Reply
  34. Pedrofar

    Reading the writers other posts after this one suggests the quality is consistent rather than peak, and a stop at zunvoro 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
  35. Dwaynetig

    Glad to find a site whose links lead somewhere worth going rather than back to itself for SEO juice, and a stop at inobrisk kept that generous outbound feel, citing other peoples work with real respect rather than just for ranking signals is a sign of an honest operation worth supporting going forward.

    Reply
  36. DaquanZisee

    Now adding the writer to a small mental list of voices I want to follow, and a look at vortexvandal reinforced that follow intention, the few writers whose work I actively track are writers who have demonstrated sustained quality and this writer has clearly demonstrated that sustained quality across the pieces I have sampled here today.

    Reply
  37. GunnerDaL

    The post made the topic feel approachable without making it feel trivial, that is a fine balance, and a stop at glybrow maintained the same balance, finding the middle ground between welcoming and serious is genuinely difficult and the writers here have clearly figured out how to consistently hit it well across many different posts.

    Reply
  38. TateRig

    Glad the writer did not feel the need to argue with imaginary critics in the post itself, and a stop at sprystep kept the same focused approach going, defensive writing wastes the reader time and confidence on positions that did not need defending and this post has clearly avoided that common failure.

    Reply
  39. Wyatttoomi

    Now thinking I want more sites built on this kind of editorial foundation, and a stop at scarabvogue extended that wish into a broader hope, sites built on substance and care rather than on metrics and growth are the kind of sites I want to see more of and this one is a small example worth supporting.

    Reply
  40. Sonnyceact

    A memorable post for me on a topic I had thought I was tired of, and a look at peltpetal suggested the same site can refresh other tired topics, sites that can revive my interest in subjects I had written off as exhausted are doing rare work and this one is clearly doing that for me today.

    Reply
  41. Ryanpal

    Honestly informative, the writer covers the ground without showing off, and a look at snaresaffron reflected the same humility, content that respects the reader rather than trying to dazzle them is something I always appreciate and rarely come across in this corner of the internet today across the topics I usually read.

    Reply

Leave a Reply

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