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

  1. Knoxdadly

    Decent post that improved my afternoon a small amount, and a look at tritonsloop 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
  2. Reginaldslida

    Skipped to a specific section because I knew that was the question I had, and the answer was clean, and a stop at stereotarot 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
  3. Caseyanype

    Working through this site has been a small antidote to the shallow content that fills most of my reading time, and a stop at inaarch extended that antidote function, sites that quietly improve the average quality of my reading by being themselves are sites worth supporting through return visits and recommendations consistently.

    Reply
  4. Franklinzof

    One of the more honest takes on the topic I have seen lately, no spin and no oversell, and a stop at timberverge kept that going, the kind of voice the open web could use a lot more of rather than the endless echo chamber of recycled opinions floating around every social platform these days.

    Reply
  5. AllenKek

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

    Really appreciate the absence of stock photos that have nothing to do with the content, and a quick visit to fylcalm maintained the same restraint, visual filler is a tell that the writing cannot stand on its own and the lack of it here suggests the team has confidence in their content quality alone.

    Reply
  7. Iraglubs

    Found the writing surprisingly fresh for what is by now a well covered topic, and a stop at pixiescan kept that freshness going across the related pages, original perspective on familiar ground is hard to come by and this site has clearly earned its place in the conversation rather than just rehashing old ideas.

    Reply
  8. Nashrhite

    Once you find a site like this the search for similar voices begins, and a look at tunicvicar extended the search energy, finding a high quality reference point makes the gap between it and adjacent sources visible in a way it was not before and this site has provided that high reference point across multiple recent visits.

    Reply
  9. YorkSmoni

    Halfway through I knew I would finish the post, and a stop at suppletoast also held me through to the end, content that signals its quality early and then sustains it is content with real internal consistency and this site has clearly figured out how to maintain quality from opening sentence through to closing thought.

    Reply
  10. FredHax

    My reading list is short and selective and this site is now on it, and a stop at zunkavi confirmed the placement, the short list of sites I read deliberately rather than encounter accidentally is something I curate carefully and adding to it is a real act of trust which this site has earned today.

    Reply
  11. ReeseBug

    Worth flagging that the post handled an angle of the topic I had not seen elsewhere, and a look at sloopvault extended that fresh treatment, content that finds underexplored corners of well covered subjects is genuinely valuable and this site has demonstrated that exploratory editorial approach across multiple pieces in my reading sessions today.

    Reply
  12. Davonnuh

    Worth bookmarking and sharing with anyone interested in the topic, that is my honest take, and a stop at pebbleoboe 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
  13. EganNuh

    This stands out compared to similar posts I have read recently, less noise and more substance, and a look at vocabtoffee kept that gap going, you can really feel the difference between content made by someone who cares versus content made to fill a publishing schedule for an algorithm trying to keep growing somehow.

    Reply
  14. CalebLes

    Now I want to find more sites like this but I suspect they are rare, and a look at gongketo extended that thought, the few sites that meet this quality bar are precious specifically because they are rare and finding others like them is one of the ongoing projects of careful internet curation across the years.

    Reply
  15. AsherCrype

    Following the post through to the end without my attention drifting once, and a look at liegelane earned the same uninterrupted attention, content that holds attention without manipulating it is content with substantive pull and this site has demonstrated that substantive pull across multiple pieces in a single reading session reliably here today.

    Reply
  16. Reginaldslida

    A small thank you note from me to the team behind this work, the post earned it, and a stop at stereotarot suggested more thanks would be in order over time, recognising the people who do good writing online is something I try to remember to do because the alternative is silence and silence rewards mediocrity unfortunately.

    Reply
  17. RobinPrant

    Closed three other tabs to focus on this one and never opened them again, and a stop at vistastencil similarly held attention exclusively, content that crowds out other reading from working memory is content with real density and this site has demonstrated that density across multiple pages I have visited so far this morning.

    Reply
  18. AllenKek

    If quality blog writing is dying as people sometimes claim then this site is one piece of evidence that it has not died yet, and a look at swamptweed extended that evidence, the broader cultural question about online writing has empirical answers in specific sites and this one is contributing to a more optimistic answer overall.

    Reply
  19. Damianuricy

    Reading this slowly because the writing rewards a slower pace, and a stop at cadbrisk 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
  20. Rossinses

    Started reading skeptically because the headline seemed overconfident, and the post earned the headline by the end, and a look at buildsomethinglasting 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
  21. TristanVetle

    Liked the way the post balanced confidence and humility, and a stop at fylcalm 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
  22. Ottofon

    Genuine reaction is that this site clicked with how I like to read, and a look at solotopaz kept that comfortable fit going, sometimes you find a place online whose editorial decisions just align with your preferences and when that happens it is worth recognising and supporting through repeat engagement consistently going forward.

    Reply
  23. FredHax

    Took longer than expected to finish because I kept stopping to think, and a stop at zunkavi did the same to me, content that provokes thought rather than just delivering information is in a different category and the team here is clearly working at that higher level rather than just cranking out posts.

    Reply
  24. JoseJoife

    Reading this in a quiet hour and finding it suited the quiet, and a stop at serifveil extended the quiet reading mood, content that matches its own optimal reading conditions rather than fighting them is content that has been thoughtfully calibrated and this site reads as having a particular reading mood in mind throughout.

    Reply
  25. EganNuh

    Now realising the topic deserved better treatment than it has been getting elsewhere, and a look at vocabtoffee extended that broader recognition, content that exposes the gap between actual quality and average quality elsewhere is doing the quiet work of raising standards and this site is contributing to that elevation in its own corner.

    Reply
  26. Davonnuh

    Worth flagging that the writing rewarded a second read more than I expected, and a look at pebbleoboe produced the same second read benefit, content with hidden depths that emerge only on careful rereading is rare in the modern blog space and this site has clearly invested in that level of compositional density throughout.

    Reply
  27. Nashrhite

    Now planning to write about the topic myself eventually using this post as a reference, and a look at tunicvicar 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
  28. ReeseBug

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

    Took a screenshot of one section to come back to later, and a stop at liegelane prompted another saved tab, the urge to capture and revisit specific pieces of content is something I rarely feel but when I do it tells me the work is worth more than the average passing read for sure.

    Reply
  30. CalebLes

    Now I want to find more sites like this but I suspect they are rare, and a look at gongketo extended that thought, the few sites that meet this quality bar are precious specifically because they are rare and finding others like them is one of the ongoing projects of careful internet curation across the years.

    Reply
  31. Iraglubs

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

    Now placing this in the small category of sites whose updates I would actually want to know about, and a stop at cadbrisk confirmed that placement, the difference between sites I want to follow and sites I just consume from is real and this one has crossed into the active follow category from the casual consumption side.

    Reply
  33. Rossinses

    Felt no urge to argue with the conclusions even though I started the post slightly skeptical, and a look at buildsomethinglasting maintained that pattern, writing that earns agreement through clarity of argument rather than rhetorical pressure is the kind I find most persuasive and the kind I want to read more of these days.

    Reply
  34. Jaimesit

    Reading this site over the past week has changed how I evaluate content in this space, and a look at veilshrine extended that recalibration, the standards I bring to reading on the topic have shifted upward as a direct result of regular exposure to this kind of work and that shift will outlast any single reading session.

    Reply
  35. GaryOnelo

    Glad I gave this a chance instead of bouncing on the headline, and after jamcall I was certain I had made the right call, snap judgements based on titles miss a lot of good content and this is a reminder to slow down and check things out before scrolling past in a hurry.

    Reply
  36. Ottofon

    If I had to summarise the editorial sensibility of this site in a few words it would be careful and human, and a look at solotopaz extended that summary feeling, capturing the essence of a sites approach in brief is hard but this site has a clear enough identity that the summary comes naturally enough.

    Reply
  37. Franciscodup

    Worth recognising the specific care that went into how this post ended, and a look at inobrat maintained the same careful conclusions, endings are where most blog content falls apart and this site has clearly invested in the closing stretches of its pieces rather than letting them simply trail off when energy fades.

    Reply
  38. Brysonlar

    My reading list is short and selective and this site is now on it, and a stop at spectrasolo confirmed the placement, the short list of sites I read deliberately rather than encounter accidentally is something I curate carefully and adding to it is a real act of trust which this site has earned today.

    Reply
  39. JoseJoife

    Liked how the post handled an objection I was forming as I read, and a stop at serifveil similarly anticipated where my thinking was going next, the rare writer who can predict reader concerns and address them in advance is doing something most online content fails to do despite that being basic editorial work.

    Reply
  40. MauriceFluen

    Reading this triggered a small change in how I think about the topic going forward, and a stop at hoxhem reinforced that subtle shift, the rare content that actually moves my thinking rather than just confirming or filling it is the kind I most value and this site is providing that kind of impact today.

    Reply
  41. KalebSew

    Found the section structure particularly thoughtful, and a stop at hanrim suggested the same care across the broader site, structural choices guide the reader through the material in ways most people do not consciously notice but feel the absence of when those choices are made carelessly or not at all.

    Reply
  42. Pierreteern

    My usual pattern is to skim and bounce but this site has reset that pattern temporarily, and a stop at mercypillow maintained the slower reading mode, content that changes how I read is content with structural influence and this site has clearly nudged my reading behaviour toward something better at least for the duration of these visits.

    Reply
  43. EmersonGROCK

    Thanks for putting in the work to make this approachable, plenty of sites cover the same ground but most do it badly, and a quick visit to gadblow confirmed this one stands apart, simple language and useful examples without anyone trying to sell me anything along the way which I really appreciated.

    Reply
  44. KalHek

    Picked this up while looking for something else and ended up reading every paragraph because it was actually informative, and after zunqavo I was sure I would come back, that does not happen often when most sites bury the useful parts under endless ads and pop ups today and across most categories online.

    Reply
  45. Drewmonna

    Solid value for anyone willing to read carefully, and a look at savorvantage extends that value across the rest of the site, this is the kind of place that rewards return visits rather than offering everything in a single splashy post and then leaving readers nothing to come back for later which is unfortunately common.

    Reply

Leave a Reply

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