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

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

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

  1. Maxwellsox

    Closed the tab feeling I had spent the time well, and a stop at jadkix extended that feeling across more pages, the test of whether time on a site was well spent is one I apply silently after closing tabs and very few sites pass it but this one passed it cleanly today afternoon clearly.

    Reply
  2. Arthurres

    Granted my mood today might be elevating my reading experience but I still think this is genuinely good, and a stop at learnandadvanceforward reinforced that even discounted assessment, controlling for the mood adjustment that affects content perception this site still reads as substantively above average across multiple pieces I have read carefully today.

    Reply
  3. Dustinsuedy

    Honest reaction is that I want to send this to a friend who would benefit from it, and a look at startpurposefulgrowth added more material I will pass along too, the impulse to share is the strongest signal I have for content quality and this site is generating that impulse cleanly across multiple posts.

    Reply
  4. GuillermoBaf

    Honestly the simplicity of the explanation made the topic click for me in a way other writeups had not, and a look at growwithclarity continued that clarity into related areas, when a writer gets the level of explanation right the reader does the heavy lifting themselves and the post just enables it.

    Reply
  5. StephenSpicy

    Useful read, especially because the writer did not assume too much background from the reader, and a quick look at exploreuntappedpaths 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
  6. WilliamfaR

    Refreshing tone compared to the dry corporate posts on similar topics, and a stop at exploreideasfreely 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
  7. EmilioIcoff

    Halfway through reading I knew this would be one to bookmark, and a look at humzap confirmed that early intuition, when bookmark intent forms before finishing a post you know the writing has cleared a quality bar that most content fails to clear and this site has cleared it on multiple visits already.

    Reply
  8. QuincyFop

    Reading this confirmed something I had been suspecting about the topic, and a look at tidaltunic pushed that confirmation toward greater confidence, content that lines up with independently held intuitions earns a special kind of trust and I will return to writers who consistently land that way for me without overselling positions.

    Reply
  9. RafaelKep

    Nice and clean, that is the best way to describe the writing here, no clutter and no wasted words, and a quick visit to createclarityfast kept that going, I appreciate when a site treats its readers like people who can think for themselves without needing constant hand holding through every paragraph.

    Reply
  10. KileDex

    Liked how the post handled an objection I was forming as I read, and a stop at discovernewpossibility similarly anticipated where my thinking was going next, the rare writer who can predict reader concerns and address them in advance is doing something most online content fails to do despite that being basic editorial work.

    Reply
  11. Laynesaums

    Reading this felt easy in the best way, no friction and no confusion at any point, and a stop at shoresyrup carried that same comfort across more pages, the kind of editorial flow that lets you absorb information without fighting the format which is increasingly hard to find on the open web today across topics.

    Reply
  12. GinoSlusy

    A handful of memorable phrases from this one I will probably use later, and a look at derbunch added a couple more, content that contributes language to my own communication rather than just facts is content with a different kind of utility and this site is providing that linguistic utility consistently across what I read.

    Reply
  13. Vaughnsox

    Glad I gave this fifteen minutes rather than the usual three minute skim, and a look at growwithfocusedaction earned the same investment, time spent on quality content is rarely wasted but the reverse is also true and learning which sites deserve which kind of attention is part of being a careful online reader.

    Reply
  14. Patricklig

    A piece that respected the reader by not over explaining the obvious, and a look at findyournextidea 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
  15. Lincolnreund

    A piece that did not require external context to follow, and a look at designfocusedcommerce 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
  16. Arthurres

    Thanks for sharing this with the open internet rather than locking it behind a paywall like so many sites do now, and a stop at learnandadvanceforward kept the same vibe going, generous helpful and clearly written by someone who actually wants people to learn from it rather than just charge them.

    Reply
  17. Iraapess

    Considered against the flood of similar content this one stands apart in important ways, and a stop at explorepossibilitiestoday extended that distinctive feel, sites that find their own corner of a crowded topic and stay there are sites worth following and this one has clearly carved out its own space and committed to defending it carefully.

    Reply
  18. GuillermoBaf

    Really appreciate the confidence to make a clear point rather than hedging everything, and a quick visit to growwithclarity 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
  19. BuddyEmumn

    Glad I clicked through from where I did because this turned out to be worth the time spent, and after senatetrench I had a fuller picture, the kind of content that earns its visitors through delivering value rather than chasing them through aggressive advertising or constant pop ups appearing everywhere on the screen lately.

    Reply
  20. Ricoqueer

    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 biablur 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
  21. XanderSpaws

    Liked the balance between depth and brevity, never too shallow and never too long, and a stop at scopeskylark 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
  22. WilliamfaR

    Reading this confirmed that my time researching the topic in other places had not been wasted, and a stop at exploreideasfreely extended the confirmation, when independent sources agree that is a useful signal and this site is one of the more reliable sources I have found for cross checking what I read elsewhere on similar subjects.

    Reply
  23. WarrenVew

    Reading this prompted me to dig into a related topic later, and a stop at heyaro provided some of the starting points for that follow up reading, content that triggers further exploration rather than satisfying curiosity completely is content with real generative energy and this site has plenty of that energy throughout it.

    Reply
  24. Curtisunump

    Without overstating it this is a quietly excellent post, and a look at jaycap extended that quiet excellence, content that earns superlatives without demanding them through marketing language is content that has truly earned them through the substance and this site has clearly produced work in that earned excellence category today.

    Reply
  25. ChadGax

    Probably worth setting aside a longer block to read more carefully than I can right now, and a stop at discovernewperspectives confirmed the longer block plan, the impulse to schedule dedicated time for a sites archive is itself a measure of trust and this site has earned that scheduling impulse from me clearly today actually.

    Reply
  26. Cadennot

    Started thinking about my own writing differently after reading, and a look at startbuildingpurpose 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
  27. Roryaffer

    Liked that there was nothing performative about the writing, and a stop at jadyam continued that genuine quality, performative writing tries to be witnessed rather than read and the difference between performance and substance is huge for the careful reader and this site has clearly chosen substance every time clearly.

    Reply
  28. Patricklig

    Closed the tab and immediately reopened it ten minutes later because I wanted to reread a part, and a stop at findyournextidea drew the same return, content that pulls you back after closing it is doing something well beyond the average and worth marking as exceptional in my mental catalogue of reliable sites.

    Reply
  29. EmilioIcoff

    Even on a quick first read the substance of the post comes through, and a look at humzap 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
  30. ChadGax

    Started reading expecting to disagree and ended mostly nodding along, and a look at discovernewperspectives 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
  31. LyletoK

    Even just sampling a few posts the consistency is what stands out, and a look at learnandgrowfaster confirmed the broader pattern, sites where every piece I sample lives up to the standard set by the others are sites with serious quality control and this one has clearly invested in whatever editorial process produces that consistency reliably.

    Reply
  32. KeithDoome

    Pass this along to colleagues if the topic comes up, the framing here is sensible, and a stop at buildstrategicfocus adds more useful angles to share, the kind of content that improves conversations rather than just feeding them is what makes a resource genuinely valuable in professional contexts going forward over time and across project boundaries too.

    Reply
  33. XanderSpaws

    Walked away with a clearer head than I had before reading this, and a quick visit to scopeskylark 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
  34. Colbyfed

    Found this really helpful, the explanations are simple but they actually answer the questions a normal reader would have, and after I followed taffetaswan I had a clearer sense of the topic, no extra fluff just useful points laid out in a sensible order that made the time worth it.

    Reply
  35. KadeLef

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

    Now adding the writer to a small mental list of voices I want to follow, and a look at derburn 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. Iraapess

    Worth a quiet moment of recognition for the consistency I have noticed across multiple posts, and a stop at explorepossibilitiestoday 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
  38. Angelolak

    Picked up several practical tips that I plan to try out this week, and a look at silverumber added a few more I will be testing alongside, content with practical hooks that connect to my actual life is the kind that earns my repeat attention rather than the merely interesting that I forget within a day.

    Reply
  39. TimNer

    Reading this prompted me to dig out an old reference book related to the topic, and a stop at growstepbystep extended that connection to other sources, content that connects me back to my own existing knowledge rather than asking me to forget it is content with continuity and this site has that continuous quality.

    Reply
  40. EduardoWex

    Just one of those reads that left me feeling slightly more capable rather than overwhelmed, and a look at growwithconfidencenow kept that empowering feel going, the difference between content that builds the reader up and content that intimidates them is huge and this site clearly knows which side of that line to stand.

    Reply
  41. Cadennot

    Just wanted to say this was useful and leave a small note of thanks, and a quick visit to startbuildingpurpose earned a similar nod from me, the small acknowledgements add up over time and represent the real economy of trust that good content runs on across the open and increasingly fragmented modern internet.

    Reply
  42. Roryaffer

    Liked that there was nothing performative about the writing, and a stop at jadyam continued that genuine quality, performative writing tries to be witnessed rather than read and the difference between performance and substance is huge for the careful reader and this site has clearly chosen substance every time clearly.

    Reply
  43. MylesAboni

    Most of my reading time goes to a small number of trusted sources and this one is now joining that group, and a stop at explorenewdirections reinforced the group membership, the few sites that earn a place in my regular rotation are sites I expect ongoing returns from and this one has earned that elevated position consistently.

    Reply

Leave a Reply

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