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

  1. ConnerIncit

    Picked this post to share in a Slack channel where I knew it would be appreciated, and a look at learnandscaleeffectively suggested I will share more from here later, content worth sharing into a professional context is content that has earned a higher kind of trust than mere personal interest and this site has it.

    Reply
  2. GlennSop

    Genuinely glad I clicked through to read this rather than skipping past, and a stop at growwithclearintent confirmed I should keep clicking through to more pages here, the kind of resource that justifies its place in my browser history rather than feeling like wasted time which is the highest compliment I offer any site online today.

    Reply
  3. LowellHab

    Reading this slowly in the morning before opening email, and a stop at growstrategicclarity extended that protected attention, content that earns the prime morning reading slot before the daily distractions begin is content with elevated status and this site has earned that prime slot consistently in my recent reading habits clearly.

    Reply
  4. Brendonlob

    Glad I gave this a chance rather than scrolling past, and a stop at discoveropportunityflows confirmed I made the right call, sometimes the best content is hidden behind unassuming headlines that do not scream for attention and learning to slow down and check those out has paid off many times now across years of reading.

    Reply
  5. Isaiahbeart

    However casually I came to this site I have ended up reading carefully, and a look at learnstepbystep continued earning that careful reading, the conversion from casual visitor to careful reader is something content earns rather than demands and this site has accomplished that conversion for me over the course of just a few pieces.

    Reply
  6. Richardstilk

    Reading this on a phone at a coffee shop and finding it perfectly suited to that context, and a stop at bexedge continued the comfortable mobile experience, content that works across reading conditions without compromising on substance is increasingly important and this site has clearly thought about the whole reader experience here.

    Reply
  7. Connermug

    Liked that the post landed without needing to manufacture controversy or take a contrarian stance for attention, and a stop at startfreshthinking continued that grounded approach, content that earns attention through quality rather than provocation is the kind that builds long term trust rather than burning it on quick wins.

    Reply
  8. Sidneykip

    Honestly this hits the sweet spot between detail and brevity, no rambling and no shortcuts, and a quick visit to findgrowthchannels 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
  9. Ronalddwell

    Came in expecting another generic take and got something with actual character instead, and a look at swampstaple carried that personality forward, finding a distinct voice on a saturated topic is impressive and worth pointing out when it happens because most sites end up sounding identical to their nearest competitors quickly.

    Reply
  10. AmmonVobby

    Skimmed first and then went back to read carefully, and the careful read paid off in places I had missed, and a stop at premiumlivingmarketplace got the same treatment, the rare site whose content rewards a second pass is content I want more of in my regular rotation rather than disposable single read articles.

    Reply
  11. Alfredchuri

    Genuinely useful read, the points are practical and easy to apply right away, and a quick look at deoblob confirmed that this site is consistent in that approach, looking forward to digging through the rest of it when I get the chance to sit down properly later in the week or this weekend.

    Reply
  12. Estevanvutle

    Really appreciate that the writer did not stretch the post to hit some target word count, the points end when they are made, and a stop at startbuildingclarity reflected the same discipline, brevity is generosity in disguise and this site has clearly figured that out far better than most blog operations have.

    Reply
  13. ZackGlypE

    Just wanted to say this was useful and leave a small note of thanks, and a quick visit to teapotshrine 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
  14. Everettsit

    A piece that brought a sense of order to a topic I had been finding chaotic, and a look at buildsmarthabits 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
  15. ConnerIncit

    Really appreciate that the writer did not assume I would read every other related post first, and a look at learnandscaleeffectively kept that self contained feel going where each piece can stand alone, accessibility for new readers is a sign of generous editorial thinking and this site has clearly invested in that approach.

    Reply
  16. GlennSop

    Adding this site to my regular reading list, the post earned that on its own, and a quick stop at growwithclearintent sealed the decision, the kind of place worth checking back with from time to time because it consistently produces material that holds up against a critical reading too which I really value.

    Reply
  17. LaneVomia

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

    Now wishing more sites covered topics with this level of care, and a look at startfreshthinking extended that wish across more subjects, the rarity of careful coverage on most topics is a problem and this site is one of the small antidotes to that broader pattern of casual or surface treatment of complex subjects.

    Reply
  19. Sidneykip

    Genuinely changed how I think about a small piece of the topic, which does not happen often online, and a look at findgrowthchannels added another nudge in the same direction, the kind of writing that earns a small mental shift rather than just confirming what you already thought before reading is a sign of careful thought.

    Reply
  20. ClydeGEK

    Glad the writer did not feel the need to argue with imaginary critics in the post itself, and a stop at buildpositiveprogress 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
  21. StephenSpicy

    Thanks for taking the time to write this, it is clear that some thought went into how each point would land, and after I went through exploreuntappedpaths I had a better grip on the topic, real value without the usual marketing noise people have to put up with online when searching for answers.

    Reply
  22. Maxwellsox

    Reading this slowly to absorb the structure, and the structure is doing real work alongside the words, and a look at jadkix maintained the same architectural quality, when sentence shapes and paragraph rhythms reinforce the meaning rather than just transporting words you know you are reading skilled work today.

    Reply
  23. Dustinsuedy

    After reading several posts back to back the consistent voice across them is impressive, and a stop at startpurposefulgrowth continued that voice consistency, sites that maintain a single coherent voice across many pieces by potentially many writers represent serious editorial discipline and this one has clearly developed the institutional consistency needed for that.

    Reply
  24. RafaelKep

    Thanks for laying this out in a way that someone newer to the topic can follow, and a stop at createclarityfast kept that accessibility going, writing that meets readers at different experience levels without condescending is hard to do well and the writers here have clearly thought about who they are writing for.

    Reply
  25. 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
  26. 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
  27. BuddyEmumn

    Ended up here on a wandering afternoon and was glad I stayed for the read, and a stop at senatetrench extended the wandering into a proper exploration of the site, the kind of place that rewards aimless clicking with something genuinely interesting rather than the shallow content that mostly populates the modern open web.

    Reply
  28. ClydeGEK

    Came across this looking for something else entirely and ended up reading it through twice, and a look at buildpositiveprogress pulled me deeper into the site than I planned, the writing has a way of holding attention without resorting to manipulative cliffhangers or vague promises that never get delivered later down the page.

    Reply
  29. Ronalddwell

    Reading this gave me a quiet moment of intellectual pleasure that I had not been expecting, and a stop at swampstaple extended that pleasure across more pages, the unexpected reward of stumbling into careful writing is one of the small ongoing pleasures of reading the open web and this site is delivering it reliably.

    Reply
  30. Ricoqueer

    A piece that reads like it was written for me without claiming to be written for me, and a look at biablur produced the same fit, when the writer audience match clicks naturally without being engineered through demographic targeting you know the writing is solid and this site has that natural fit consistently for me.

    Reply
  31. KileDex

    Skimmed first and then went back to read carefully, and the careful read paid off in places I had missed, and a stop at discovernewpossibility got the same treatment, the rare site whose content rewards a second pass is content I want more of in my regular rotation rather than disposable single read articles.

    Reply
  32. GinoSlusy

    Took a quick scan first and then went back to read properly because the post deserved it, and a stop at derbunch kept me reading carefully too, the kind of writing that earns a slower second pass rather than getting skimmed and forgotten is something I value highly when I happen to find it.

    Reply
  33. 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
  34. WarrenVew

    Reading this confirmed a small detail I had been uncertain about, and a stop at heyaro provided the source for further checking, content that supports verification through citations or links rather than just asserting facts is more trustworthy and this site has clearly built its credibility through that kind of verifiable approach consistently.

    Reply
  35. 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
  36. Lincolnreund

    Reading this in the time it took to drink half a cup of coffee, and a stop at designfocusedcommerce fit naturally into the second half, content that respects the rhythms of a typical morning is content with practical fit and this site has the kind of length and pacing that works for the way I actually read.

    Reply

Leave a Reply

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