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

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

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

  1. Bernarddaply

    Reading this gave me a small jolt of recognition for an experience I thought was just mine, and a stop at xarvilo produced more such jolts, content that universalises private experiences without flattening them is doing genuinely useful work and this site is providing that recognition function for me reliably across topics I read.

    Reply
  2. KevinAxory

    Excellent post, balanced and well organised without showing off, and a stop at eastglaze continued in that same vein, this site has clearly figured out the formula for content that works for readers rather than for search engine ranking signals which is harder than it sounds today and worth real recognition from anyone.

    Reply
  3. Chandlereneri

    Reading this in the morning set a good tone for the day, and a quick visit to buyvilo 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
  4. GlenBlums

    Thanks for the honest framing without exaggerated claims that the topic will change my life, and a stop at islegoal kept the same modest tone, restraint in marketing language signals trustworthiness and the writers here are clearly playing the long game by building credibility rather than chasing immediate clicks through hyperbole.

    Reply
  5. Willisgot

    Found this useful, the points line up well with what I have been thinking about lately, and a stop at ultrashophub added some angles I had not considered yet, definitely walking away with more than I came for which is the best outcome from time spent reading online for any kind of topic.

    Reply
  6. TobiasGak

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

    Reading this gave me a small framework I expect to use going forward, and a stop at urbanvilo 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
  8. Albertsam

    A satisfying piece in the way that good meals are satisfying rather than just filling, and a look at intentionalstyleandhome extended that satisfaction, the metaphor between content and meals is one I find useful and this site reads as a satisfying meal rather than the empty calories that most content provides for casual readers.

    Reply
  9. Chandlereneri

    A handful of memorable phrases from this one I will probably use later, and a look at buyvilo 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
  10. KadeKit

    Really grateful for content like this, it does not waste my time and it does not insult my intelligence either, and a quick look at kanvoro was the same, balanced respectful writing that makes a person feel welcome rather than rushed through pages of forced engagement just to keep clicking around.

    Reply
  11. ClintonBen

    The tone stayed consistent across the whole post which is harder than it looks for longer pieces, and a look at packpeak continued the same voice, this kind of editorial consistency is a sign of either a single careful writer or a tightly run team and either is impressive today across the broader media environment.

    Reply
  12. Bradentaity

    Now planning to write about the topic myself eventually using this post as a reference, and a look at hickorygrid would also serve in that future piece, content that becomes raw material for my own writing rather than just informing my reading is content with multiplicative value and this site is generating that multiplicative effect.

    Reply
  13. Bernarddaply

    If I had encountered this site five years ago I would have been telling everyone about it, and a look at xarvilo extended that retrospective enthusiasm, the version of me who used to recommend favourite blogs frequently would have made sure friends knew about this one and that earlier enthusiasm is partially returning to me here.

    Reply
  14. Willisgot

    Found this useful, the points line up well with what I have been thinking about lately, and a stop at ultrashophub added some angles I had not considered yet, definitely walking away with more than I came for which is the best outcome from time spent reading online for any kind of topic.

    Reply
  15. Kadevok

    A piece that suggested careful editing without showing the marks of the editing, and a look at fibergrid continued that invisible polish, the best editing disappears into the prose and this site reads as having been edited with skill that does not announce itself which is the highest compliment I can offer any blog content.

    Reply
  16. Jacksonzek

    A piece that handled a controversial angle without becoming heated, and a look at gemglobe continued that calm engagement, content that can address contested topics without inflaming them is doing rare diplomatic work and this site has clearly developed the editorial maturity to handle sensitive material with the appropriate temperature of writing throughout.

    Reply
  17. BorisTaini

    Took me back a step or two on an assumption I had been making, and a stop at havenfoam 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
  18. TobiasGak

    Now recognising the specific pleasure of reading writing that shows real care for sentence shapes, and a look at shopzaro extended that craft pleasure, sentence level writing quality is something most blog content ignores entirely and this site has clearly invested in the prose layer alongside the substance which is rare today.

    Reply
  19. Floydmog

    Really grateful for content like this, it does not waste my time and it does not insult my intelligence either, and a quick look at northvendor was the same, balanced respectful writing that makes a person feel welcome rather than rushed through pages of forced engagement just to keep clicking around.

    Reply
  20. Johnnieexcew

    Bookmark added without hesitation after finishing, and a look at morxavi confirmed I should bookmark the homepage too rather than just this page, the rare site that earns category level trust rather than just single article approval is the kind I want to rely on across many different topics over time.

    Reply
  21. DaveUttef

    Looking at the surface design and the substance together this site has both right, and a look at tirxavo reinforced that integrated quality, sites where presentation and content reinforce each other rather than fighting are sites with full editorial coherence and this one has clearly invested in both layers in a balanced way.

    Reply
  22. StefanMap

    Felt like I was reading something written by someone who actually thinks about the topic rather than reciting it, and a look at qelmizo reinforced that impression, the difference between recited content and considered content is huge and this site clearly belongs to the latter category which I appreciate as a careful reader looking for substance.

    Reply
  23. Joelanido

    Worth recognising the absence of the usual blog tropes here, and a look at jadeflax 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
  24. Franksal

    Appreciate how nothing here feels copied or pieced together from other places, the voice is consistent and the tone stays human, and after I checked luxmixo I noticed the same style holds, which is a small detail but it makes the whole experience feel personal rather than like another generic site.

    Reply
  25. KevinAxory

    A piece that earned its conclusions through the body rather than asserting them at the end, and a look at eastglaze maintained the same earned quality, conclusions that follow from what came before are more persuasive than declarations and this site has clearly internalised that principle in how it constructs arguments throughout pieces.

    Reply
  26. Jacksonzek

    Felt the writer respected the topic without being precious about it, and a look at gemglobe continued that respectful but unfussy treatment, finding the right register for serious topics is hard and this site has clearly figured out how to take the topic seriously while still being readable for casual visitors regularly.

    Reply
  27. Bradentaity

    A piece that built up gradually rather than front loading its main points, and a look at hickorygrid maintained the same gradual structure, content that trusts the reader to reach conclusions through accumulating reasoning is more persuasive than content that announces conclusions and then defends them and this site uses the persuasive approach.

    Reply
  28. BorisTaini

    Now wondering how the writers calibrated the level of detail so well, and a stop at havenfoam continued the same calibration, the right level of detail is one of the harder editorial calls in any piece and this site has clearly developed an instinct for it through what I assume is years of careful practice publicly.

    Reply
  29. SeanCab

    Coming back to this one, definitely, and a quick visit to fortfalcon only made me more sure of that, the kind of writing that makes you want to set aside time later rather than rushing through it now while distracted by everything else competing for attention on the screen today across so many tabs.

    Reply
  30. Vancealivy

    Decided to write a short note to the author if there is contact info anywhere, and a stop at urbanvo extended that intention, the urge to thank the writer directly is a strong signal of content quality and this site has triggered that urge in me today which is a fairly rare event for my reading.

    Reply
  31. KadeKit

    Following a few of the internal links revealed more posts of similar quality, and a stop at kanvoro 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
  32. Joelanido

    Easy to recommend without reservations, the site delivers on every promise it implicitly makes, and a look at jadeflax kept that same standard going, the kind of consistency that earns trust over time rather than chasing it through aggressive marketing is what I see here and it is appreciated greatly by this particular reader today.

    Reply
  33. Floydmog

    Reading this confirmed something I had been suspecting about the topic, and a look at northvendor 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
  34. HarveyOdoth

    Liked the way the post balanced confidence and humility, and a stop at cartluma maintained the same balance, knowing when to assert and when to acknowledge uncertainty is a sign of mature thinking and the writers here have clearly developed that calibration through what I assume is years of careful work on their craft.

    Reply
  35. Fredericksoush

    Now thinking about how this post will age over the coming years, and a stop at mivqaro suggested the same durability, content built to age well rather than to capture the attention of the moment is content with a different kind of value and this site has clearly chosen the long horizon over the short one.

    Reply
  36. DaveUttef

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

    Pleasant surprise, the post delivered more than the headline promised, and a stop at luxmixo continued that pattern of under promising and over delivering, the rarest combination on the modern web where most content does the opposite by promising the world and delivering thin recycled summaries instead each time you click on something interesting.

    Reply
  38. JosephThamp

    Most posts I read end up forgotten within a day but this one is sticking, and a look at brightfuturedeals extended that lingering effect, content that survives the immediate moment of reading rather than evaporating is content with genuine retention quality and this site has been producing memorable pieces at a rate notable across my reading.

    Reply
  39. WilfordbRola

    Took my time with this rather than rushing because the writing rewards attention, and after discoverfashionhub I had even more to absorb, the kind of content that pays back the patient reader rather than punishing them with empty filler is something I look for and rarely find in regular searches lately.

    Reply
  40. Keatonhix

    The tone stayed consistent across the whole post which is harder than it looks for longer pieces, and a look at xavlumo continued the same voice, this kind of editorial consistency is a sign of either a single careful writer or a tightly run team and either is impressive today across the broader media environment.

    Reply
  41. Perrynes

    Will be back, that is the simplest way to say it, and a quick visit to premiumdesigncollective reinforced the decision, this site has earned a spot in my regular rotation alongside a few other reliable places I check when I want something genuinely informative without all the usual modern web noise getting in the way.

    Reply
  42. Vancealivy

    Started reading and ended an hour later without realising the time had passed, and a look at urbanvo produced the same time dilation effect, when content makes time feel different the writer has achieved something well beyond the average and this site is producing that experience for me reliably across multiple readings.

    Reply
  43. Marshallsaf

    Liked that the post left some questions open rather than pretending to settle everything, and a stop at zenvani continued that intellectual honesty, content that respects the limits of its own claims is more trustworthy than content that overreaches and this site has clearly figured out which positions it can defend confidently.

    Reply
  44. Bufordknigo

    Really appreciate the lack of pop ups, modals, cookie banners stacking on top of each other, and a quick visit to wattedge confirmed the same clean approach across the rest of the site, technical decisions about user experience are part of what makes content actually pleasant to engage with for sure.

    Reply
  45. Patrickknors

    Reading this slowly to give it the attention it deserved, and a stop at liegepenny earned the same slow read, choosing to read slowly is a small act of respect for content quality and very few sites earn that respect from me but this one did so without any explicit ask which is the cleanest way.

    Reply

Leave a Reply

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