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

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

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

  1. Quincygeapy

    A well calibrated piece that knew its scope and stayed inside it, and a look at oldenneon maintained the same scope discipline, scope creep is one of the failure modes of long blog posts and this site has clearly invested in the editorial discipline to prevent it which shows up in tightly contained pieces.

    Reply
  2. ShermanVef

    Liked that the post acknowledged complications rather than pretending they did not exist, and a stop at cobqix continued that honest framing, sites that handle complexity with care rather than papering it over with simplifying claims are doing real intellectual work and this one is clearly in that category based on what I have read.

    Reply
  3. RoderickSpiny

    Glad I stumbled across this post, the explanations actually make sense without needing background knowledge to follow along, and after a stop at tallyvertex the same was true there, no assumptions about the reader just clear writing that anyone can understand from the first line right through to the end.

    Reply
  4. ReeseDot

    Yesterday I was complaining about the state of online writing and today this site has temporarily fixed that complaint, and a look at learnandoptimize extended that mood reversal, the short term mood improvement that comes from finding good content is real and this site has produced that improvement for me at a useful moment.

    Reply
  5. TristanStync

    Genuinely good work, the kind that holds up over multiple readings without losing its appeal, and a stop at unionstaff kept that going, definitely a site I will be returning to and probably mentioning to others who work in or care about this particular area of interest today and in coming weeks.

    Reply
  6. ClaytonCorie

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

    Found the use of subheadings really helpful for scanning back through the post later, and a stop at discoverpowerfulideas kept that reader friendly approach going, navigation is something many blog writers ignore but small structural choices make a noticeable difference for someone returning to find a specific point again days or weeks later.

    Reply
  8. FrederickJak

    Well done, the kind of post that makes you slow down and actually read instead of skimming for keywords, and a look at vinylvessel kept me reading carefully too, that is a sign of writing that has been crafted rather than churned out for an algorithm to see today and tomorrow.

    Reply
  9. SullivanJaife

    My professional context would benefit from having this kind of resource available, and a look at trumpetsash extended the professional applicability, the rare site that contributes meaningfully to professional work rather than just personal interest is content with multiplied value and this one is providing that professional utility consistently across multiple pieces.

    Reply
  10. Nolanplave

    Speaking from the perspective of having read widely on the topic this site offers something distinct, and a look at honeymeadowmarketgallery reinforced that distinctness, the rare site that contributes something genuinely original to a saturated topic is the rare site worth following carefully and this one has demonstrated that original contribution capability today.

    Reply
  11. Keanudibia

    Started reading without much expectation and ended on a high note, and a look at tildeserene continued that arc, content that builds rather than peaks early is a sign of a writer who knows how to structure a piece for sustained reader engagement rather than relying on a strong hook to do all the work.

    Reply
  12. Terrancedep

    Reading this on a slow Sunday and finding it perfectly suited to a slow Sunday read, and a quick stop at findyournextmove 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
  13. Brandonbek

    Found this through a search that was generic enough I did not expect quality results, and a look at swiftvantage continued the surprisingly good experience, search engines occasionally still surface excellent independent content if you scroll past the obvious paid and high authority results which is reassuring to remember sometimes.

    Reply
  14. Quincygeapy

    Easy to recommend without reservations, the site delivers on every promise it implicitly makes, and a look at oldenneon 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
  15. EmeryKep

    A piece that read as the work of someone who reads carefully themselves, and a look at grobuff continued that informed feel, writers who are also serious readers produce work with a different quality and this site reads as the product of someone steeped in good writing rather than just generating content for an audience.

    Reply
  16. IanNal

    Reading this gave me a small sense of progress on a topic I have been slowly working through, and a stop at vergetrophy 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
  17. ReeseDot

    This filled in a gap in my understanding that I had not even noticed was there, and a stop at learnandoptimize did the same, the kind of post that gives you more than you expected when you first clicked through from somewhere else, a real find for anyone curious about the area covered here.

    Reply
  18. Brendanlot

    Found the use of subheadings really helpful for scanning back through the post later, and a stop at discoverpowerfulideas kept that reader friendly approach going, navigation is something many blog writers ignore but small structural choices make a noticeable difference for someone returning to find a specific point again days or weeks later.

    Reply
  19. Franciscoced

    A piece that demonstrated competence without performing it, and a look at grebeflame maintained the same self assured but unshowy register, the gap between competence and performance of competence is one I track and this site has clearly chosen to demonstrate rather than perform which I find much more persuasive as a reader.

    Reply
  20. ClaytonCorie

    Stands out for actually being useful instead of just being long, and a look at twinetyphoon kept that going, length without value is the default mode of most blogs these days but this site has clearly chosen a different path which I respect a lot as a reader who values careful editing decisions like that.

    Reply
  21. AngelJum

    Closed my email tab so I could read this without interruption, and a stop at isebulb earned the same protected attention, when content is good enough to defend against the usual digital distractions you know it deserves better than the half attention most online reading gets in a typical busy day.

    Reply
  22. RoderickSpiny

    Reading this confirmed a small detail I had been uncertain about, and a stop at tallyvertex 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
  23. TristanStync

    A small thing but the line spacing and font choices made reading this physically pleasant, and a look at unionstaff maintained the same careful design, technical choices about typography are part of what makes online reading actually comfortable and this site has clearly invested in the design layer alongside the content layer carefully.

    Reply
  24. Coleamerb

    Excellent post, balanced and well organised without showing off, and a stop at learncontinuously 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
  25. Brandonbek

    Skimmed first and then went back to read carefully, and the careful read paid off in places I had missed, and a stop at swiftvantage 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
  26. Nolanplave

    Worth every minute of the time spent reading, and a stop at honeymeadowmarketgallery 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
  27. EmeryKep

    Reading this slowly to give it the attention it deserved, and a stop at grobuff 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
  28. DemarcusKix

    Reading this on the train into work was a better use of the commute than my usual choices, and a stop at syxblue extended that commute reading well, content that improves transit time rather than just filling it is content with practical benefit and this site has earned its place in my morning commute reading rotation.

    Reply
  29. BeauSluff

    Picked up something useful for a side project, and a look at japarrow added another piece I will incorporate, content that connects to specific projects I am working on is content with practical utility and the practical utility of this site is showing up across multiple posts I have read in the last hour or so.

    Reply
  30. IanNal

    A piece that read as if the writer was thinking carefully rather than just typing fluently, and a look at vergetrophy continued that considered quality, the difference between fluent typing and careful thinking shows up in writing and this site reads as the product of thought rather than just the product of language fluency apparently.

    Reply
  31. BorisWeict

    Honest reaction is that I want to send this to a friend who would benefit from it, and a look at hekblade added more material I will pass along too, the impulse to share is the strongest signal I have for content quality and this site is generating that impulse cleanly across multiple posts.

    Reply
  32. Vaughnlarly

    Decided to subscribe to the RSS feed if there is one, and a stop at corlex confirmed that decision, content that I want delivered to me proactively rather than just remembered when I have time is content that has earned a higher level of commitment from me as a reader looking for reliable sources.

    Reply
  33. Zacharyrax

    Speaking from the perspective of a fairly demanding reader the writing here clears the bar consistently, and a look at thatchteapot continued clearing that bar, the calibration of demanding reader is something I apply to all sources and this site has been one of the few that handles the demanding reading well across pieces sampled.

    Reply
  34. Franciscoced

    Decent post that improved my afternoon a small amount, and a look at grebeflame added a bit more to that, sometimes the small wins online add up over time and a useful site like this one is the kind of place that contributes consistently to those small wins for me lately across many different topics I follow.

    Reply
  35. RossVappy

    Just wanted to drop a quick note saying this was a useful read on a topic I have been circling, no fluff, and a stop at stridertorch added a few extra points that fit the same simple style which makes the whole site feel coherent rather than thrown together by many different writers with different goals.

    Reply
  36. AngelJum

    Approaching this site through a casual link click and being surprised by what I found, and a look at isebulb extended the surprise, the rare experience of stumbling into excellent independent content rather than predictable mediocrity is one of the actual remaining pleasures of casual web browsing and this site provided it cleanly.

    Reply
  37. Yalebouch

    A piece that took its time without dragging, and a look at discovernewpossibilities kept the same patient pace, the difference between unhurried and slow is a fine editorial distinction and this site has clearly found the unhurried side without slipping into the slow side which would have lost me as a reader quickly otherwise.

    Reply
  38. BenjaminCed

    Reading this gave me confidence to make a decision I had been putting off, and a stop at discoverandgrow reinforced that confidence, content that translates into action in my own life rather than just informing it is content with the highest practical value and this site is generating that action level utility for me lately.

    Reply
  39. KaneGrews

    Picked something concrete from the post that I will use immediately, and a look at onionoval added another concrete piece, content that produces immediately useful output rather than just abstract appreciation is content that earns its place in my regular rotation without needing any further evaluation from me at this point honestly.

    Reply
  40. KelbyDer

    Without overstating it this is a quietly excellent post, and a look at huijax 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
  41. JustinMeere

    Started this morning and finished at lunch with a small sense of having spent the time well, and a look at turbansample 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
  42. ConnorCal

    Now feeling confident enough in this site to use it as a reference point for evaluating others on the same topic, and a look at buildmeaningfulprogress continued the comparison friendly quality, sites that serve as quality benchmarks for their topic are precious and this one has clearly become a benchmark for me on this particular subject area.

    Reply
  43. Coleamerb

    I really like how the writer keeps the tone friendly without sounding fake or overly polished, and after a stop at learncontinuously the same calm pace was there, no rushing to make a point and no padding either, just clean honest writing that I can respect and come back to later again.

    Reply
  44. DemarcusKix

    Pleasant surprise, the post delivered more than the headline promised, and a stop at syxblue 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

Leave a Reply

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