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

  1. Masonuseri

    Came away with a slightly better mental model of the topic than I started with, and a stop at tinytriton sharpened that further, content that improves the reader thinking apparatus rather than just dumping facts into it is the rare kind I genuinely value and seek out when I have time to read carefully.

    Reply
  2. KentonCricy

    Felt energised after reading rather than drained, which is unusual for online content these days, and a look at stashserif continued that good feeling, content that leaves you better than it found you is rare and worth bookmarking when you stumble across it for the first time today or any other day really.

    Reply
  3. Nathannoula

    Genuinely well crafted writing, the kind that makes the topic look easier than it actually is, and a look at salutestitch added even more depth, you can feel the experience behind every line which is something only writers who have been at this for a while can pull off with this level of grace.

    Reply
  4. Zachariahser

    Now feeling the quiet pleasure of finding writing that takes itself seriously without being self serious, and a stop at snaretoga extended that subtle pleasure, the gap between earnest and pretentious is fine and this site has clearly chosen to land on the earnest side without slipping over into pretentious which is impressive.

    Reply
  5. CharlieEvesS

    Ended up here on a wandering afternoon and was glad I stayed for the read, and a stop at muscatlarch 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
  6. Gagenon

    Looking through other posts here the consistency is what makes the site valuable rather than any single piece, and a stop at storksnooze extended that consistency observation, sites whose value lies in the ongoing pattern rather than in standout posts are sites I trust more deeply and this one has clearly built that kind of trust.

    Reply
  7. KileTaw

    If I were to recommend a starting point for the topic this site would be near the top of my list, and a stop at lithelight reinforced that recommendation status, the small list of starting point recommendations I keep for friends asking about topics is short and this site is now firmly on it.

    Reply
  8. CoreyWal

    Great work on keeping things readable, the post never drags or repeats itself which I really appreciate, and a stop at tinklesaddle 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
  9. TimothyRib

    Reading this prompted me to dig out an old reference book related to the topic, and a stop at twainsilica 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
  10. Cadenhieve

    Will recommend this to a couple of friends who have been asking about this exact topic, and after norzavo I have even more reason to do so, the kind of site that earns word of mouth rather than chasing it through aggressive marketing or paid placements is always a treat to find online.

    Reply
  11. LowellBen

    Now realising the post has been quietly doing important work in my mind for the past hour, and a stop at sodatorch extended that quiet processing, content that continues to do work after I close the tab is content with afterlife in the mind and this site is producing those long lived effects at a meaningful rate.

    Reply
  12. RicardoBrarm

    Easy to recommend, the content speaks for itself without needing additional praise from me, and a stop at draftglade only adds more reasons to send people this way, the kind of generous resource that benefits its readers without demanding anything in return is increasingly rare and worth recognising clearly today across the broader open internet.

    Reply
  13. HarleyVab

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

    Started reading expecting to disagree and ended mostly nodding along, and a look at salutestitch 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
  15. AlfredoDions

    Closed several other tabs to focus on this one as I read, and a stop at scenictrader held my undivided attention the same way, content that earns full focus in an attention environment full of competing pulls is content doing something genuinely well and the team behind it deserves recognition for that achievement consistently.

    Reply
  16. EmilianoJer

    Honestly this kind of writing is why I still bother to read independent sites, and a look at spryring extended that broader reflection, the few sites that justify continued attention to non algorithmic content are sites like this one and finding them periodically is enough to keep my reading habits oriented toward independent rather than aggregated content.

    Reply
  17. KentonCricy

    Quietly the writers approach to the topic differs from the dominant takes I have been encountering, and a stop at stashserif extended that distinctive approach, content that maintains a different perspective without explicitly arguing against the dominant ones is content with confident editorial identity and this site has that confidence throughout pieces.

    Reply
  18. Vladimirzow

    Really liked the calm tone running through the post, no shouting and no urgency forced into the writing, and a look at safaritriton kept that quiet confidence going, the kind of voice that makes the reader feel respected rather than yelled at which is depressingly common across most modern blog content these days.

    Reply
  19. Zachariahser

    Now saved this in a way that I will actually find again rather than the casual bookmark approach, and a stop at snaretoga earned the same careful saving, organising my reading bookmarks so that high quality sources rise to the top is something I should do more of and this site triggered that organisation today.

    Reply
  20. Clydetip

    Quiet confidence runs through the whole post, no need to shout to make the points stick, and a stop at quvnero carried that same restrained voice forward, content that respects the reader by trusting its own substance rather than dressing it up in theatrical language is what I look for online and rarely actually find these days.

    Reply
  21. Gagenon

    Now noticing that the post never raised its voice even when making a strong point, and a look at storksnooze continued that calm volume, content that can make important points without resorting to typographic emphasis or emotional appeal is content that trusts its substance to do the work and this site has that confidence consistently.

    Reply
  22. Masonuseri

    Reading this confirmed that the topic deserves more careful attention than it usually gets, and a stop at tinytriton extended that elevated framing, content that raises the appropriate weight of a subject without being preachy about it is serving a quiet but important editorial function for the broader cultural conversation about it.

    Reply
  23. NashBef

    Left me wanting to read more rather than feeling burned out, that is a good sign, and a look at ranchomen confirmed there is plenty more here to explore, the kind of writing that builds appetite rather than killing it which is a rare quality on the modern open internet today across most categories of content.

    Reply
  24. Linwoodlob

    A piece that read smoothly because the writer understood how readers actually move through prose, and a look at solotoffee maintained the same reader awareness, writers who think about the reading experience as much as the writing experience produce better work and this site has clearly made that shift in editorial approach.

    Reply
  25. CurtisBor

    Generally my comment to other readers about new sites is to wait and see but for this one I would jump to recommend now, and a look at vinyltrophy reinforced that early recommendation, the speed at which a site earns my recommendation is itself a quality signal and this one has earned mine quickly clearly.

    Reply
  26. Arnoldogreva

    Generally I bookmark sparingly to avoid building up a bookmark graveyard but this one earned a permanent slot, and a stop at llamapatio extended that permanence designation, the few sites I keep permanent bookmarks for are sites I expect to use repeatedly and this one has clearly cleared that expectation bar today.

    Reply
  27. LeonardGoG

    Considered alongside other sources I have been reading this one consistently rises to the top, and a stop at sodasalt maintained that top ranking, the informal ongoing comparison between sources is something I do whenever reading on a topic and this site keeps coming out near the top of those comparisons over many sessions.

    Reply
  28. NashBef

    Found a small mental shift after reading this, the framing here is just a bit different from the standard takes online, and a look at ranchomen extended that fresh perspective across more material, the rare site whose voice actually changes how you think about something rather than just confirming existing beliefs.

    Reply
  29. Romaneduff

    The clarity here is something I really appreciate, especially compared to sites that pile on jargon for no reason, and a look at molzari was the same, simple direct sentences that actually deliver information instead of dancing around the point for paragraphs at a time which wastes reader patience.

    Reply
  30. MikeNiz

    Reading this in the morning set a good tone for the day, and a quick visit to muscatlumen kept that good tone going, content can do that sometimes when it hits the right notes and finding sites that consistently strike that tone is something I have learned to recognise and reward with regular visits.

    Reply
  31. HarleyVab

    Honest opinion is that this is the kind of post that builds long term trust with readers, and a look at mastlarch reinforced that perception, the slow accumulation of trust through consistent quality is the only sustainable way to build a real audience and this site is clearly playing that long game.

    Reply
  32. GeorgeDET

    A slim post with substantial content per word, and a look at draftlake 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
  33. Basilpes

    Now adjusting my expectations upward for the topic based on this post, and a stop at siennathrift continued that bar raising effect, content that resets what I think is possible on a subject is doing real work in shaping my standards and this site is providing those bar raising experiences at a notable rate during sessions.

    Reply
  34. Arnoldogreva

    Honestly thank you to whoever wrote this because it scratched an itch I had not quite been able to articulate, and a stop at llamapatio 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
  35. CurtisBor

    The structure of the post made it easy to follow without losing track of where I was, and a look at vinyltrophy kept the same logical flow going, this site clearly understands that organisation is half the battle in keeping readers engaged from the first line to the last across any kind of post.

    Reply
  36. LeonardGoG

    Now adjusting my mental list of reliable sites for this topic, and a stop at sodasalt reinforced the adjustment, the small ongoing curation work of maintaining trusted sources is one of the actual practical activities of careful reading and this site has earned a permanent place on my list for this particular subject.

    Reply
  37. Donnyfusty

    Skipped to a specific section because I knew that was the question I had, and the answer was clean, and a stop at solostarlit similarly delivered targeted answers without burying them, content engineered for readers who arrive with specific needs rather than open ended browsing is increasingly valuable in a search heavy reading environment.

    Reply
  38. Beautinly

    Thanks for the breakdown, it gave me a clearer picture of something I had been confused about for a while now, and a stop at solidvector closed the remaining gaps in my understanding nicely, no need to hunt around twenty other articles to put the pieces together which is a real time saver.

    Reply
  39. LonnieGex

    Glad the writer kept this short rather than padding it out, the points stand on their own without needing extra context, and a look at tractshade kept the same approach going, brevity is a sign of confidence in the substance and the team here clearly trusts their content to land without filler.

    Reply
  40. MikeNiz

    Now noticing how rare it is to find a site that does not feel rushed, and a look at muscatlumen 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
  41. GeorgeDET

    Now noticing that the post did not mention the writer at all, focus stayed on the topic, and a look at draftlake 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
  42. ScottOvext

    Reading this in three sittings because the day was fragmented, and the piece survived the fragmentation, and a stop at shrinetender held up under similar reading conditions, content engineered for continuous attention is fragile in modern conditions and this site reads as durable across the realistic ways people consume content today.

    Reply
  43. Basilpes

    Solid information that lines up with what I have been hearing from other reliable sources, and after my visit to siennathrift I was even more certain of that, this site checks out which is something I value highly when so many places online play loose with the facts to chase a quick click.

    Reply
  44. FabianCah

    Started reading skeptically because the headline seemed overconfident, and the post earned the headline by the end, and a look at suburbsurge continued that pattern of earning its claims, sites that can back up their headlines without overpromising are rare and this one has clearly developed editorial calibration on that front consistently.

    Reply
  45. DarnellDip

    Reading this gave me a small sense of progress on a topic I have been slowly working through, and a stop at sparkcast added another step forward, learning happens in small increments across many sources and finding sources that consistently contribute is the actual practical value of careful curation in an information rich world.

    Reply
  46. BrendanVot

    Granted my mood today might be elevating my reading experience but I still think this is genuinely good, and a stop at tulipsedan 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
  47. YaleMuple

    Really appreciate this kind of writing, no shouting and no clickbait headlines just steady useful content, and a quick look at qalmizo kept that going, definitely a site I will be returning to whenever I need a sensible take on similar topics in the days ahead and also during slower work weeks.

    Reply
  48. Romaneduff

    Now noticing the post fit a particular gap in my reading without my having articulated the gap before, and a look at molzari extended that gap filling effect, content that meets needs I had not consciously formulated is content with reader insight and this site has clearly developed that anticipatory editorial sense across many pieces.

    Reply

Leave a Reply

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