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

  1. CarmineSkack

    Picked up two new ideas that I expect will come up in conversations this week, and a look at finkgulf added another, content that arms me with talking points rather than just filling time is the kind that provides ongoing value beyond the moment of reading and this site is generating that kind of ongoing value.

    Reply
  2. Rickyruike

    Took my time with this rather than rushing because the writing rewards attention, and after basteclose 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
  3. KevinPaync

    Worth recognising the absence of the usual blog tropes here, and a look at nobleaisle 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
  4. Johnnieskefs

    Felt the post had been written without using a single buzzword, and a look at quickvendor continued that clean vocabulary, content free of jargon and trendy phrases reads better and ages better and this site has clearly committed to a vocabulary that will not feel dated in three years which is impressive editorially.

    Reply
  5. GordonKem

    Felt a small spark of recognition when the post named something I had been struggling to articulate, and a look at everjumbo produced more such moments, the rare service of giving readers language for fuzzy intuitions is one of the higher values that good writing can provide and this site offered several today instances.

    Reply
  6. Nolanmig

    Just sat back at the end of the post and felt grateful that someone took the time to write it, and a look at nookharbor extended that gratitude across more of the site, recognising effort behind quality work is part of what makes the open web a community rather than just a marketplace today.

    Reply
  7. JamarcusUseli

    Without comparing too aggressively to other sources this one stands out for the right reasons, and a look at caramelmarket continued that distinctive quality, content that distinguishes itself through substance rather than style tricks is content with lasting differentiation and this site has clearly chosen substance based differentiation as its core editorial strategy.

    Reply
  8. KevinPaync

    Now considering whether the post would translate well into a different form, and a look at nobleaisle suggested similar versatility, content that could move into other media without losing its substance is content that has been built around ideas rather than around format and this site reads as idea first throughout posts.

    Reply
  9. Knoxcrate

    Took the time to read the comments on this post too and they were also worth reading, and a stop at globalinspiredstorefront suggested the community quality matches the content quality, when the conversation around a piece is as good as the piece itself you know you have found a real corner of the internet.

    Reply
  10. Dylanvob

    Honestly this kind of writing is why I still bother to read independent sites, and a look at firhex 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
  11. Knoxcrate

    Now thinking about this site as a small example of what good independent writing looks like, and a stop at globalinspiredstorefront continued that exemplary status, the few sites that serve as good examples are sites worth holding up in conversations about quality and this one has earned that exemplary placement through patient consistent effort over time.

    Reply
  12. SterlingDuath

    Started this morning and finished at lunch with a small sense of having spent the time well, and a look at fairfinch extended that satisfaction into the afternoon, content that fits naturally into the rhythm of a working day rather than demanding a dedicated reading block is increasingly the kind I prefer.

    Reply
  13. Krisgom

    Now wishing I had found this site sooner, and a look at quelnix extended that mild regret, the calculation of how many years of good content I missed by not finding the right sources earlier is one I try not to make too often but it does come up sometimes when I find sites this good.

    Reply
  14. Dylanvob

    Worth every minute of the time spent reading, and a stop at firhex extends that value across more pages, in a media environment where most content is engineered to waste attention this site stands out by treating reader time as something valuable rather than something to be exploited and stretched as far as possible.

    Reply
  15. JamarcusUseli

    Bookmark folder reorganised slightly to make this site easier to find, and a look at caramelmarket 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
  16. GabrielInals

    Now recognising that the post handled the topic with appropriate technical precision without becoming dry, and a stop at celnova continued that balance, technical precision and readability are often in tension and this site has clearly figured out how to maintain both at once which is one of the harder editorial achievements in the form.

    Reply
  17. Darnellpaf

    Even across multiple posts the writers voice has remained consistent in a way I appreciate, and a stop at clevebound continued that voice, sites that maintain editorial consistency across many pieces have something most sites lack and this one has clearly worked out how to keep its voice steady across what reads as a growing archive.

    Reply
  18. MicahUtima

    Now leaving a small mental note to recommend this when the topic comes up in conversation, and a look at bracechord 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
  19. Krisgom

    Reading this gave me a small mental break from the heavier reading I had been doing, and a stop at quelnix extended that lighter feel, content that provides relief without becoming trivial is harder to produce than people realise and this site has clearly figured out how to be light without being shallow at all.

    Reply
  20. RyderNop

    After reading several posts back to back the consistent voice across them is impressive, and a stop at gablejuno 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
  21. AlonzoCed

    Thanks for laying this out in a way that someone newer to the topic can follow, and a stop at grebeheron 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
  22. Jasonmob

    Taking the time to read carefully here has been worthwhile for the past hour, and a look at glazeflask extended the worthwhile reading, the calculation of return on reading time spent is something I do informally and this site has been producing positive returns across multiple sessions during the last week of regular visits and reads.

    Reply
  23. SterlingDuath

    Polished and informative without feeling overproduced, that is the sweet spot, and a look at fairfinch hit it again, you can tell when a site has been built with care versus thrown together for the sake of having something to put online and this is clearly the former approach taken by the team.

    Reply
  24. LedgerVah

    Generally I find the content on similar topics frustrating in specific ways and this post avoided all of them, and a look at hopiron continued that frustration free experience, content that sidesteps the standard failure modes of its genre is content with editorial awareness and this site has clearly studied what fails elsewhere consistently.

    Reply
  25. DallasDouff

    Glad to have another reliable bookmark for this topic, and a look at flockfine suggested several more pages I will be marking too, building a personal library of trustworthy resources is one of the actual rewards of careful browsing and this site is earning a place on my permanent shortlist for the topic.

    Reply
  26. Andysiz

    Recommended without reservation for anyone interested in the topic at any level of expertise, and a look at heliofine only strengthens that recommendation, this site clearly knows how to serve readers across a range of backgrounds without watering down the content or talking past anyone in the audience which is genuinely impressive to see.

    Reply
  27. DallasSes

    Speaking honestly this is among the better discoveries of my recent browsing, and a stop at yourtradingmentor reinforced that discovery quality, the ranking of recent discoveries is informal but meaningful and this site has placed near the top of that ranking based on the consistency of quality across what I have already read carefully.

    Reply
  28. Andyglave

    Now noticing that the post benefited from being neither too short nor too long for its content, and a look at knollgull continued that calibration of length, sites that match length to content rather than padding to hit some target are sites that respect both their material and their readers and this site does both.

    Reply
  29. WestonMot

    Worth bookmarking and sharing with anyone interested in the topic, that is my honest take, and a stop at jetivory reinforces that, the kind of generous resource that makes the open web feel worth defending against the constant pressure to retreat into walled gardens and curated feeds today everywhere I look across all my devices.

    Reply
  30. Drewsog

    Excellent execution from start to finish, the post never loses its rhythm and the points stay sharp, and a quick stop at modernconsciousmarket kept the same level going, consistency like this across a site is the marker of a serious operation rather than a casual side project running on autopilot somewhere else.

    Reply
  31. Domenicobeby

    Nice and clean, that is the best way to describe the writing here, no clutter and no wasted words, and a quick visit to premiumeverydaygoods 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
  32. ElmerAlole

    Top quality material, deserves more attention than it probably gets, and a look at firhush reflected the same effort across the site, a hidden gem in the modern web where most attention goes to whoever shouts loudest rather than whoever actually delivers the best content for their readers without much marketing fanfare.

    Reply
  33. RyderNop

    Now appreciating that I did not feel exhausted after reading, and a stop at gablejuno 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
  34. GabrielInals

    Top notch writing, every paragraph carries weight and nothing feels like filler, and a stop at celnova reflected that same care, a rare thing on the open web these days where most pages exist for clicks rather than actual reader value or anything close to that which is honestly a real shame.

    Reply
  35. LedgerVah

    Now adding the homepage to my regular check rotation rather than waiting for individual links to find me, and a stop at hopiron confirmed the rotation upgrade, the move from passive discovery to active checking is a vote of confidence in a sites ongoing quality and this site has earned that active engagement clearly.

    Reply
  36. Brianmossy

    Служба дезинфекции приятно удивила качеством сервиса. Заявка была обработана быстро, специалист подробно проконсультировал по телефону и помог выбрать оптимальный вариант обработки помещения https://dezinfection-v-spb.click/dezinfekciya/ot-gribka/

    Reply
  37. AlonzoCed

    Worth recognising that the post did not pretend to be the final word on the topic, and a stop at grebeheron continued that humility, content that admits its own scope and limits is more trustworthy than content that overreaches and this site has clearly developed the editorial maturity to know what it can and cannot claim well.

    Reply
  38. Jasonmob

    Came across this through a roundabout path and now it is on my regular rotation, and a stop at glazeflask sealed that decision, the open web still produces serendipitous discoveries when you let the citations and references guide you rather than relying purely on algorithmic feeds for new content recommendations always.

    Reply
  39. DallasSes

    Looking forward to seeing what gets published next month, and a look at yourtradingmentor extended that anticipation across the broader site, finding myself looking forward to a sites future content rather than just consuming its existing content is a stronger commitment level than I usually reach with new finds and this site triggered that.

    Reply
  40. Andysiz

    Now feeling something close to gratitude for the fact this site exists, and a look at heliofine extended that gratitude, the rare site that produces this kind of response is the rare site worth defending in conversations about whether the modern internet is still capable of producing genuinely valuable independent content for serious adults.

    Reply
  41. Andyglave

    Took something from this I did not expect to find, and a stop at knollgull added another unexpected useful piece, content that exceeds expectations rather than just meeting them is the kind that builds enthusiasm and earns repeat visits without any explicit ask from the writer or platform behind the work being read.

    Reply
  42. Darnellpaf

    Worth recognising that the post did not pretend to be the final word on the topic, and a stop at clevebound continued that humility, content that admits its own scope and limits is more trustworthy than content that overreaches and this site has clearly developed the editorial maturity to know what it can and cannot claim well.

    Reply
  43. Domenicobeby

    Worth marking the moment when reading this clicked into something useful for my own work, and a look at premiumeverydaygoods extended that practical click, content that connects to my actual life rather than just being interesting is content with the highest kind of value and this site is generating that connection at a high rate.

    Reply
  44. DallasDouff

    Liked that the post resisted a sales pitch ending, and a stop at flockfine maintained the no pitch approach, content that ends without trying to convert me into a customer or subscriber is content that has confidence in its own value and this site is clearly playing the long game on reader trust.

    Reply
  45. Drewsog

    Excellent execution from start to finish, the post never loses its rhythm and the points stay sharp, and a quick stop at modernconsciousmarket kept the same level going, consistency like this across a site is the marker of a serious operation rather than a casual side project running on autopilot somewhere else.

    Reply
  46. WestonMot

    Pass this along to anyone you know dealing with similar questions, the answers here are clear, and a stop at jetivory 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
  47. ElmerAlole

    Reading this on a slow Sunday and finding it perfectly suited to a slow Sunday read, and a quick stop at firhush kept the same gentle pace, content that fits the mood of the moment is something I notice and remember and this site has the kind of pace that suits relaxed reading sessions especially well.

    Reply
  48. Hankneite

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

Leave a Reply

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