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

  1. JaimeCitof

    Reading this gave me a small refresher on something I had partially forgotten, and a stop at humgrain extended the refresher, content that strengthens existing knowledge rather than just adding new is content with a particular kind of consolidating value and this site is providing that consolidating function across multiple visits.

    Reply
  2. Dennisgeame

    Honestly thank you to whoever wrote this because it scratched an itch I had not quite been able to articulate, and a stop at gridivory kept that satisfying feeling going, the kind of writing that meets unspoken needs is special and this site clearly has writers who understand their readers more than most do today.

    Reply
  3. ErnestoErype

    Useful enough to recommend to several people I know who would appreciate it, and a stop at galehelm added more material I will pass along too, the kind of writing that earns word of mouth is the kind that actually delivers on its promises which is what this site does without any drama or fanfare attached.

    Reply
  4. GordonVax

    Skipped lunch to finish reading, which says something, and a stop at intentionalconsumerexperience kept me at my desk longer than planned, when content beats the lunch impulse the writer has done something genuinely impressive in an attention environment full of immediately satisfying alternatives competing for the same finite block of reader time.

    Reply
  5. TrentonSic

    The conclusions felt earned rather than tacked on at the end like an afterthought, and a look at knicknook kept that careful structure going, you can tell when a writer has thought about the shape of their post versus just letting it ramble out and hoping for the best at the end which most do.

    Reply
  6. Simonquogs

    Now noticing that the post did not mention the writer at all, focus stayed on the topic, and a look at flankgate continued that author absent quality, content that disappears the writer to focus on the substance is a particular kind of generosity and this site has clearly chosen the substance over the personality consistently.

    Reply
  7. KeatonLog

    Now leaving a small mental note to recommend this when the topic comes up in conversation, and a look at purebeautyoutlet extended that recommend ready feeling, content that arms me with shareable references for likely future conversations is content with social value and this site is providing that conversational ammunition consistently for me lately.

    Reply
  8. Dennisgeame

    Reading this slowly because the writing rewards a slower pace, and a stop at gridivory did the same, the pace at which I read content is something I now use as a quality signal and writing that earns a slower pace earns my attention as a reader looking for substance these days.

    Reply
  9. BenTooro

    Found the post genuinely useful for something I was working on this week, and a look at kraftkilt added more material I will reference, content that connects to my actual life and work rather than just being interesting in the abstract is the kind I will pay attention to and return to repeatedly.

    Reply
  10. Stewarthurry

    High quality writing, no marketing speak and no buzzwords that mean nothing, and a stop at clingchee kept that going, simple direct content that actually communicates something is harder to find than it should be and this is one of the rare places that gets it right consistently across many different posts.

    Reply
  11. Rolandomug

    Decided this was the kind of site I would defend in a discussion about good blog content, and a stop at helioketo reinforced that, very few sites earn active defence rather than passive consumption and this one has clearly crossed that threshold for me without needing any explicit pitch from the writers themselves either.

    Reply
  12. SullivanVioni

    Reading this gave me a quiet moment of intellectual pleasure that I had not been expecting, and a stop at humivy 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
  13. GordonVax

    Came across this looking for something else entirely and ended up reading it through twice, and a look at intentionalconsumerexperience 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
  14. Simonquogs

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

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

    In the middle of an otherwise scattered day this post landed as a moment of focus, and a stop at glyphfig extended that focused feeling across more pages, content that anchors a fragmented day rather than contributing to the fragmentation is content with real centring effect and this site is providing that anchoring function for me.

    Reply
  17. Averymox

    Closed and reopened the tab three times before finally finishing, and a stop at fancyfinal held my attention straight through, sometimes content fights for time against my own distraction and the times it wins say something positive about its quality and this post clearly won that fight today afternoon for me.

    Reply
  18. BenTooro

    A piece that exhibited the kind of patience that good writing requires, and a look at kraftkilt continued that patient quality, hurried writing is easy to spot and this site reads as having been written without time pressure which produces a different feel than the rushed content that dominates much of the modern blog space.

    Reply
  19. Ezekielheafe

    Now appreciating that I did not feel exhausted after reading, and a stop at galekraft extended that energising quality, content that leaves me with more attention than it consumed is rare and the gap between draining and energising content is real over the course of a typical day spent reading widely online.

    Reply
  20. SullivanVioni

    Reading this gave me a quiet moment of intellectual pleasure that I had not been expecting, and a stop at humivy 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
  21. Carlpromo

    Definitely a recommend from me, anyone curious about the topic should check this out, and a look at brightcartfusion 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
  22. Rolandomug

    Now adding this site to a small mental group of recommendations I keep ready for specific kinds of inquiries, and a stop at helioketo extended the recommendation readiness, content that I can confidently point friends and colleagues toward in specific contexts is content with real social utility and this site has that utility clearly.

    Reply
  23. Harleyunuff

    However casually I came to this site I have ended up reading carefully, and a look at grifffume 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
  24. Ezekielheafe

    Pass this along to anyone you know dealing with similar questions, the answers here are clear, and a stop at galekraft adds even more useful material, this is the kind of resource that deserves to circulate widely rather than getting lost in the constant churn of new content online that buries good work daily.

    Reply
  25. KeatonQuoth

    Stands apart from similar pages by actually being useful, that is high praise these days, and a look at floeiron kept that standard going, you can tell when a site is built around the reader versus around metrics and this one clearly belongs to the first category for sure based on what I read.

    Reply
  26. Dariusagish

    Solid little post, the kind that does not need to be flashy because the substance is doing the work, and a look at glyphfig kept that quiet confidence going across the site, this is what writing looks like when the writer trusts the content to land on its own without theatrics or unnecessary attention seeking behaviour.

    Reply
  27. Averymox

    Most of the time I bounce off similar pages within seconds, and a stop at fancyfinal held me longer than I would have predicted, the ability to convert a likely bouncing visitor into an engaged reader is a quality signal and this site has demonstrated that conversion ability across multiple visits where I expected to bounce.

    Reply
  28. RoccoPaype

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

    Started a draft response in my head and ended without publishing it because the post said it well enough, and a look at brightcartfusion produced the same effect, content that satisfies my urge to add to it by being complete enough on its own is rare and represents a particular kind of editorial completeness here.

    Reply
  30. NevilleFit

    Now noticing how rare it is to find a site that does not feel rushed, and a look at flankhaven extended that calm pace, content produced without time pressure has a different quality than content shipped to meet a deadline and this site reads as written without urgency which produces a different and better experience for readers.

    Reply
  31. CecilMes

    Better than most of the writing I have come across on this topic recently, simpler and more direct, and a look at marketpearl continued in that same way, a real outlier in a crowded space full of repetitive content that says little while taking up a lot of reader time today which is unfortunate.

    Reply
  32. ArmandoINEMI

    I came here looking for a quick answer and ended up reading the whole post because it was actually interesting, and after pebbleaisle I had a much fuller picture, no stress and no confusion just a clear walk through the topic that made everything fall into place without much effort.

    Reply
  33. Harleyunuff

    Now sitting with the thoughts the post triggered rather than rushing on to the next thing, and a stop at grifffume extended that reflective pause, content that earns time for thought after closing the tab is content of higher value than the merely interesting and this site has clearly produced that lasting effect today.

    Reply
  34. ChadBrort

    Bookmark folder reorganised slightly to make this site easier to find, and a look at tealvendor earned the same accessibility upgrade, the small organisational moves I make for sites I expect to return to often are themselves a signal of how much I trust them and this site triggered those moves naturally.

    Reply
  35. Jaylengligo

    However many similar pages I have read this one taught me something new, and a stop at krillflume 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
  36. Lucaren

    Held my interest from the opening line through to the closing thought, and a stop at consciouslivingmarketplace did the same, content that earns sustained attention in an environment full of distractions is doing something right and this site is clearly doing several things right rather than just one or two which I really appreciate.

    Reply
  37. GusEvome

    If I had to defend the time I spend reading independent blogs this site would feature in the defence, and a look at huskgenie 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
  38. NevilleFit

    Most of the time I feel the open web is in decline and then I find a site like this, and a stop at flankhaven reinforced that mood lift, the cumulative effect of finding occasional excellent independent content versus the cumulative effect of finding mostly mediocre content is real for the long term reader maintaining web habits today.

    Reply
  39. KeatonQuoth

    Now appreciating that the post did not try to imitate any other style I might recognise, and a stop at floeiron continued that distinct voice, content with its own register rather than borrowed from elsewhere is content with real authorial presence and this site has clearly developed that presence through what feels like patient editorial work.

    Reply
  40. Russellemone

    A piece that handled the topic with appropriate weight without becoming portentous, and a look at maplevendor 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
  41. JamieItept

    However many similar pages I have read this one taught me something new, and a stop at galloheron 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
  42. EvanClork

    Worth saying that the quiet confidence of the writing is what landed first, and a look at heliokindle continued that quiet quality, confident writing without the loud display of confidence is a rare combination and this site has clearly developed both the knowledge and the editorial restraint to land that combination consistently.

    Reply
  43. Jaylengligo

    Great work on keeping things readable, the post never drags or repeats itself which I really appreciate, and a stop at krillflume added a bit more context that fit naturally with what was already said here, no need to read everything twice to get the point being made today.

    Reply
  44. ChadBrort

    Glad the writer did not feel compelled to cover every possible angle of the topic, focus is a virtue, and a stop at tealvendor reflected the same disciplined scope, knowing what to leave out is half of what makes good writing good and this post has clearly been edited with that principle in mind.

    Reply
  45. GusEvome

    Probably one of the more reliable sources I have found for this kind of careful coverage, and a look at huskgenie reinforced the reliability, the small group of sources I would describe as reliable for a given topic is curated carefully and this site has earned a place in that small group through consistent performance.

    Reply
  46. Arthurtopsy

    Refreshing to find writing that does not try to manipulate the reader into clicking onto the next page through cliffhangers and forced engagement, and a stop at gnarfrost continued in the same respectful way, this is what reader first design actually looks like in practice rather than just in marketing copy that sounds nice.

    Reply
  47. Nickvag

    Now appreciating the way the post avoided the temptation to be longer than necessary, and a look at fancyhale continued that lean approach, content with the discipline to stop when finished rather than padding for length is content that respects both itself and its readers and this site has that disciplined editorial culture clearly throughout.

    Reply
  48. Lucaren

    Following a few of the internal links revealed more posts of similar quality, and a stop at consciouslivingmarketplace added more to that growing pile, sites where internal links lead to more good content rather than to more of the same recycled material are sites with depth and this one has clearly built that depth carefully.

    Reply

Leave a Reply

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