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

  1. ClarenceDep

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

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

    Solid information that lines up with what I have been hearing from other reliable sources, and after my visit to parsleymulch 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
  4. JamesKaF

    A well calibrated piece that knew its scope and stayed inside it, and a look at tasseltennis 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
  5. GabrielBeari

    Closed the laptop after this and let the ideas settle for a few hours, and a stop at skifftornado similarly rewarded reflective time, content that benefits from sitting with rather than racing past is the kind I want more of and the kind that this site appears to consistently produce week after week here.

    Reply
  6. HermanSmurl

    The use of plain language without dumbing down the topic was really well done, and a look at swirllink continued in that same accessible style, this is something many technical writers fail at because they either confuse their readers or condescend to them but here neither problem appears at all which is impressive really.

    Reply
  7. Horacioreump

    Solid value for anyone willing to read carefully, and a look at villageswan 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
  8. Vaughnbyday

    Quietly impressive in a way that does not announce itself, and a stop at gondoenvoy extended that quiet impressiveness, the kind of quality that emerges through sustained attention rather than first impressions is the kind I trust more deeply and this site has been earning that deeper trust across multiple sessions over time consistently.

    Reply
  9. WilsonBic

    Really appreciate the lack of pop ups, modals, cookie banners stacking on top of each other, and a quick visit to sonarturtle 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
  10. Carlnoino

    Genuinely useful read, the points are practical and easy to apply right away, and a quick look at twainverge confirmed that this site is consistent in that approach, looking forward to digging through the rest of it when I get the chance to sit down properly later in the week or this weekend.

    Reply
  11. PierceSoivy

    Easy to recommend, the content speaks for itself without needing additional praise from me, and a stop at turbinevault 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
  12. Shermantwilm

    If I were grading sites on this topic this one would receive high marks, and a stop at voguesage continued earning those high marks, the informal grading I do mentally for content sources is something I take seriously even though it is informal and this site has been receiving consistent high marks across multiple sessions today.

    Reply
  13. LedgerFlige

    Reading this in a relaxed evening setting was a small pleasure, and a stop at duetcoast extended the pleasant evening reading, content that fits the tone of relaxed time without becoming forgettable is what I look for in evening reading and this site has the right tone for that particular slot in my daily reading routine.

    Reply
  14. JabariGeode

    Really liked the calm tone running through the post, no shouting and no urgency forced into the writing, and a look at unlockyourfullpotential 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
  15. HugoNax

    Reading this prompted a small note in my reference file, and a stop at qanlivo prompted another, the rare site that contributes useful nuggets to my own working knowledge rather than just consuming my attention is worth the time investment many times over compared to the usual pile of forgettable scroll content.

    Reply
  16. FreddieTap

    Skipped past the first paragraph thinking it was setup and had to come back when the rest referenced it, and a stop at thriftsundae similarly rewarded careful reading from the start, content where every paragraph carries weight is content I now know to read from the beginning rather than skipping ahead.

    Reply
  17. WilsonBic

    Thank you for being clear and direct, that simple approach saves so much frustration on the reader’s end, and a stop at sonarturtle only made me more sure of it, the rest of the content seems to follow the same pattern which is a great sign of consistent editorial care behind the scenes.

    Reply
  18. PierceSoivy

    Reading this between meetings turned out to be the most useful thing I did all afternoon, and a stop at turbinevault kept that productivity feeling going, content can sometimes outperform actual work in terms of what gets accomplished mentally and this site managed that today which is genuinely a high bar to clear consistently.

    Reply
  19. Kennethtwive

    Solid little post, the kind that does not need to be flashy because the substance is doing the work, and a look at leafpatio kept that quiet confidence going across the site, this is what writing looks like when the writer trusts the content to land on its own without theatrics or unnecessary attention seeking behaviour.

    Reply
  20. Pabloinapy

    Reading this slowly to absorb the structure, and the structure is doing real work alongside the words, and a look at passionload maintained the same architectural quality, when sentence shapes and paragraph rhythms reinforce the meaning rather than just transporting words you know you are reading skilled work today.

    Reply
  21. Erikrat

    Now wishing I had found this site sooner, and a look at tallysmoke 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
  22. JabariGeode

    Approaching this with the usual skepticism I bring to new sites and being slowly persuaded, and a stop at unlockyourfullpotential continued that gradual persuasion, the careful path from skeptical reader to genuine fan is the only one I trust and this site has walked me along that path through patient consistent quality across pieces.

    Reply
  23. JesusDug

    Solid quality, the kind of work that holds up to a careful read rather than a quick skim, and a quick look at rivzavo kept that standard going strong, content that rewards attention rather than punishing it is something I appreciate more and more these days online across nearly every topic I follow.

    Reply
  24. LedgerFlige

    Felt the writer respected me as a reader without making a show of doing so, and a look at duetcoast continued that quiet respect, this is the kind of small but meaningful detail that separates the sites I bookmark from the ones I close after a single skim and never return to again no matter how interesting the headline.

    Reply
  25. Kendallenemn

    After several visits I am now confident this site is one to follow seriously, and a stop at zorvilo reinforced that confidence, the gradual building of trust through repeated quality exposures is the only sustainable way to develop reader loyalty and this site is building that loyalty in me through patient consistent work consistently.

    Reply
  26. FreddieTap

    Decent post that improved my afternoon a small amount, and a look at thriftsundae 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
  27. JonathanRix

    Worth flagging that the writing rewarded a second read more than I expected, and a look at vaultvelour 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
  28. Pabloinapy

    Really appreciate the absence of stock photos that have nothing to do with the content, and a quick visit to passionload 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
  29. Kennethtwive

    Worth recommending broadly to anyone who reads on the topic, and a look at leafpatio only confirms that, the rare combination of accessibility and depth in this site makes it suitable for both newcomers and people who already know the area which is hard to pull off in any blog format today and rarely managed.

    Reply
  30. Erikrat

    The lack of unnecessary jargon made the post accessible without sacrificing accuracy, and a look at tallysmoke continued in the same accessible style, technical topics often hide behind specialised vocabulary but here the writer trusts the reader to keep up with plain language and that trust pays off nicely throughout the entire post.

    Reply
  31. Jaxoncip

    Reading this fit naturally into my afternoon walk because I was reading on my phone, and a stop at sculptsilver continued well in that walking format, content that survives mobile reading without becoming awkward is content with format flexibility and this site has clearly thought about how it reads across different devices today.

    Reply
  32. Jaylennek

    Reading this confirmed that the topic deserves more careful attention than it usually gets, and a stop at gondoiris 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
  33. BartholomewRaw

    Approaching this with the usual skepticism I bring to new sites and being slowly persuaded, and a stop at meltmyrtle continued that gradual persuasion, the careful path from skeptical reader to genuine fan is the only one I trust and this site has walked me along that path through patient consistent quality across pieces.

    Reply
  34. RoyFuple

    Excellent execution from start to finish, the post never loses its rhythm and the points stay sharp, and a quick stop at umbravista 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
  35. HugoNax

    Reading this on the train into work was a better use of the commute than my usual choices, and a stop at qanlivo 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
  36. RodrigoThurb

    Found this really helpful, the explanations are simple but they actually answer the questions a normal reader would have, and after I followed venusstout I had a clearer sense of the topic, no extra fluff just useful points laid out in a sensible order that made the time worth it.

    Reply
  37. BobbyAdacy

    Strong recommendation from me, anyone curious about the topic should make time for this, and a look at turbantorso only sharpens that recommendation further, the kind of resource that holds up against careful scrutiny rather than crumbling at the first critical question is rare and worth pointing other people toward when the topic comes up.

    Reply
  38. RobertoHeilt

    A piece that did exactly what it promised in the headline without overshooting or underdelivering, and a look at tagzip continued that calibration, alignment between promise and delivery is a basic editorial virtue that many sites fail at and this site has clearly mastered the matching of expectation and substance throughout pieces.

    Reply
  39. JonathanRix

    Reading this with my morning coffee turned into reading the related posts with my morning coffee, and a stop at vaultvelour stretched the morning further, content that pulls breakfast into a reading session rather than just accompanying it is content that has earned a higher claim on my attention than the average article does.

    Reply
  40. Kendallenemn

    The way the post stayed on topic throughout without going on tangents was really refreshing, and a look at zorvilo kept that focused approach going, discipline like this in writing is rare and worth recognising because most writers cannot resist wandering off into related subjects that dilute their main point and confuse readers along the way.

    Reply
  41. Gagesom

    A piece that ended with a clean landing rather than fading out, and a look at tealsilver maintained the same crisp conclusions, endings that resolve rather than dissolve are a sign of careful structural thinking and this site has clearly invested in how its pieces conclude rather than letting them simply run out of energy.

    Reply
  42. Adamenlic

    Reading this prompted a small redirection in something I was working on, and a stop at makeprogressforward extended that redirecting influence, content that affects my actual work rather than just my thinking has the highest practical impact and this site is providing that level of influence for me at a sustainable rate apparently.

    Reply
  43. JesusDug

    Really thankful for posts that respect a reader’s time, this one does, and a quick look at rivzavo was the same, no need to scroll through endless intros just to get to the actual content, that approach alone is enough reason to come back here regularly for the kind of writing offered.

    Reply
  44. Camdenabild

    Now feeling the quiet pleasure of finding writing that takes itself seriously without being self serious, and a stop at uptonstarlit 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
  45. Jaylennek

    Appreciate that you did not pad this with fluff to hit a word count, the post says what it needs to say and stops, and a look at gondoiris did the same, brevity here feels intentional not lazy which is a distinction many writers miss completely sometimes when they are working under deadlines.

    Reply
  46. RoyFuple

    Liked that there was nothing performative about the writing, and a stop at umbravista continued that genuine quality, performative writing tries to be witnessed rather than read and the difference between performance and substance is huge for the careful reader and this site has clearly chosen substance every time clearly.

    Reply

Leave a Reply

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