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

  1. GlenImacy

    Will be back, that is the simplest way to say it, and a quick visit to halbelt 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
  2. LexNaL

    Skipped lunch to finish reading, which says something, and a stop at hoxaero kept me at my desk longer than planned, when content beats the lunch impulse the writer has done something genuinely impressive in an attention environment full of immediately satisfying alternatives competing for the same finite block of reader time.

    Reply
  3. Dominicsok

    Now recognising that this site has earned a place in the small group of resources I treat as authoritative, and a stop at nuartplate confirmed that placement, the difference between resources I trust and resources I just consume is real and this site has clearly moved into the trusted category through consistent quality over time.

    Reply
  4. KeaganPhota

    Generally I bookmark sparingly to avoid building up a bookmark graveyard but this one earned a permanent slot, and a stop at qanviro extended that permanence designation, the few sites I keep permanent bookmarks for are sites I expect to use repeatedly and this one has clearly cleared that expectation bar today.

    Reply
  5. OscarLom

    Reading this slowly in the morning before opening email, and a stop at meownoon extended that protected attention, content that earns the prime morning reading slot before the daily distractions begin is content with elevated status and this site has earned that prime slot consistently in my recent reading habits clearly.

    Reply
  6. AndyMot

    Saving the link for sure, this one is a keeper, and a look at stashswan confirmed I should bookmark the entire site rather than just this page, the consistency across what I have seen so far suggests there is a lot more here worth coming back for soon when I have more time.

    Reply
  7. Ezekielstymn

    Came across this through a roundabout path and now it is on my regular rotation, and a stop at patioleaf 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
  8. Willisinect

    Now adding this site to a small mental group of recommendations I keep ready for specific kinds of inquiries, and a stop at flyburn extended the recommendation readiness, content that I can confidently point friends and colleagues toward in specific contexts is content with real social utility and this site has that utility clearly.

    Reply
  9. Johnathanwroge

    Found the post genuinely useful for something I was working on this week, and a look at tracetroop added more material I will reference, content that connects to my actual life and work rather than just being interesting in the abstract is the kind I will pay attention to and return to repeatedly.

    Reply
  10. MaxNef

    Came in tired from a long day and the writing held my attention anyway, and a stop at leappalette kept that going, content that can engage a fatigued reader is doing something right because most online reading happens in suboptimal conditions like that one and quality content adapts to it without complaint.

    Reply
  11. KevinGox

    Bookmarked the page and the homepage too because clearly there is more to explore here, and a quick stop at sketchstamp only made that more obvious, this is the kind of place I want to dig through over a weekend rather than rushing through during a coffee break tomorrow morning before getting back to work.

    Reply
  12. DaveNon

    Really like that there are no exclamation marks or all caps shouting throughout the post, and a quick visit to swapvenom maintained the same calm voice, restraint in punctuation signals confidence in the content and this site clearly trusts its substance to do the persuading rather than relying on typographic emphasis.

    Reply
  13. Rufusengip

    Honestly impressed by the consistency of voice across what I have read so far, and a quick visit to broblur continued that consistent feel, when a site reads like one careful person rather than a committee the experience is more rewarding for the reader who notices these subtle editorial details over time.

    Reply
  14. IgnacioReesk

    However selective I am about new bookmarks this one made it past my filter, and a look at startyournextjourney confirmed the bookmark was worth the slot, the precious slots in my permanent bookmark folder are difficult to earn and this site earned one without making me think twice about whether the slot was justified by the quality.

    Reply
  15. Kerryvap

    A particular pleasure to read this with a fresh coffee, and a look at treblevinca extended the pleasure across more pages, content that pairs well with quiet morning rituals is something I have come to value highly and this site has the kind of energy that fits naturally into a calm reading routine.

    Reply
  16. CliffordSes

    Came in expecting another generic take and got something with actual character instead, and a look at tagtorch carried that personality forward, finding a distinct voice on a saturated topic is impressive and worth pointing out when it happens because most sites end up sounding identical to their nearest competitors quickly.

    Reply
  17. OmarAmbuh

    Most attempts at writing on this topic feel like they are missing something and this post finally identified what was missing, and a look at ilonox extended that diagnostic clarity, content that names what is wrong with adjacent treatments while doing better itself is content with both critical and constructive value and this site has both.

    Reply
  18. Gilbertopex

    Liked that the post acknowledged complications rather than pretending they did not exist, and a stop at velourudon 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
  19. Ralphrhirm

    Started thinking about my own writing differently after reading, and a look at surgetarmac continued that reflective effect, content that influences how I work rather than just informing what I know is content with the highest kind of impact and this site has triggered some of that reflective influence today on me.

    Reply
  20. JeffreyFrand

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

    Bookmark earned and the bookmark feels like a permanent addition rather than a maybe, and a look at souptrigger confirmed that permanent status, the difference between durable bookmarks and ephemeral ones is something I have learned to feel quickly and this site triggered the durable feeling almost immediately during my first read here.

    Reply
  22. GlenImacy

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

    Even from a single post the editorial care is clear, and a stop at gonggrip extended that care across more pages, the kind of attention to quality that shows up in every paragraph is what separates serious sites from the rest and this one has clearly invested in that paragraph level attention across what I have read.

    Reply
  24. IgnacioReesk

    Probably one of the more reliable sources I have found for this kind of careful coverage, and a look at startyournextjourney reinforced the reliability, the small group of sources I would describe as reliable for a given topic is curated carefully and this site has earned a place in that small group through consistent performance.

    Reply
  25. Carlosclulk

    Came in for one specific question and got answers to three I had not even thought to ask, and a look at nudgelustre extended that bonus value pattern, the kind of resource that anticipates reader needs rather than just answering the literal question asked is the gold standard and this site reaches it.

    Reply
  26. LexNaL

    If I had encountered this site five years ago I would have been telling everyone about it, and a look at hoxaero 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
  27. OscarLom

    Now considering whether the post would translate well into a different form, and a look at meownoon 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
  28. Gilbertopex

    Reading this gave me material for a conversation I needed to have anyway, and a stop at velourudon added even more talking points, content that connects to upcoming social or professional needs rather than just being interesting in the abstract is the kind that earns priority placement in my attention these days routinely.

    Reply
  29. Ralphrhirm

    Quiet confidence runs through the whole post, no need to shout to make the points stick, and a stop at surgetarmac carried that same restrained voice forward, content that respects the reader by trusting its own substance rather than dressing it up in theatrical language is what I look for online and rarely actually find these days.

    Reply
  30. AndyMot

    Thank you for not assuming the reader already knows everything, the explanations meet me where I am, and a look at stashswan did the same, that consideration is what makes a site feel welcoming rather than gatekeepy which is sadly the default mood across the modern web today for most subjects covered.

    Reply
  31. JeffreyFrand

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

    Reading this felt easy in the best way, no friction and no confusion at any point, and a stop at pebblelemon carried that same comfort across more pages, the kind of editorial flow that lets you absorb information without fighting the format which is increasingly hard to find on the open web today across topics.

    Reply
  33. FrancisHypon

    Ended up here on a wandering afternoon and was glad I stayed for the read, and a stop at fribrag extended the wandering into a proper exploration of the site, the kind of place that rewards aimless clicking with something genuinely interesting rather than the shallow content that mostly populates the modern open web.

    Reply
  34. LowellMus

    Took a chance on the headline and was rewarded, and a stop at voguestraw kept the rewards coming as I clicked through, the kind of place where every link leads somewhere worth the click is a small luxury on the modern web where so many sites are mostly empty calories disguised as content.

    Reply
  35. Warrenlep

    Genuine reaction is that this site clicked with how I like to read, and a look at tundraturtle 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
  36. LloydAsPeT

    I really like how the writer keeps the tone friendly without sounding fake or overly polished, and after a stop at tokenudon 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
  37. KileWeine

    A relief to read something where I did not have to fact check every claim mentally, and a look at steamstraw continued that reliable feeling, sites where I can lower my guard and trust the content are rare and this one is earning that trust paragraph by paragraph through consistent careful work behind the scenes.

    Reply
  38. DevanteSic

    Now placing this in the small category of sites whose updates I would actually want to know about, and a stop at souptrigger 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
  39. JesusSuine

    Reading this back to back with a similar piece elsewhere made the quality difference obvious, and a stop at lemonode only widened the gap, comparing content side by side is a useful exercise and the gap between this site and average competitors in the space is large enough to be noticeable from the first paragraph.

    Reply
  40. MorrisJot

    Found this through a friend who recommended it and now I see why, and a look at brofix only strengthened that recommendation in my own mind, word of mouth still works for content that actually delivers and this site is clearly earning recommendations the old fashioned way through quality rather than marketing.

    Reply
  41. Leonmusty

    Decent post that improved my afternoon a small amount, and a look at gonggrip 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
  42. Noelunems

    Reading more of the archives is now on my plan for the weekend, and a stop at storkumber confirmed the archive worth the time, the rare archive worth a dedicated reading session rather than just casual sampling is the rare archive of serious work and this site has clearly produced enough of that work to warrant the deeper exploration.

    Reply
  43. Javonnancy

    Picked this post to share in a Slack channel where I knew it would be appreciated, and a look at imobush suggested I will share more from here later, content worth sharing into a professional context is content that has earned a higher kind of trust than mere personal interest and this site has it.

    Reply
  44. Warrenlep

    Took a chance on the headline and was rewarded, and a stop at tundraturtle kept the rewards coming as I clicked through, the kind of place where every link leads somewhere worth the click is a small luxury on the modern web where so many sites are mostly empty calories disguised as content.

    Reply
  45. FrancisHypon

    Thanks for the readable length, I finished it without checking how much was left, and a stop at fribrag kept me reading the same way, when I stop noticing the length of a piece because the content is engaging enough to sustain attention without willpower the writer has done their job well today.

    Reply
  46. Wyattnek

    Appreciated how the post felt complete without overstaying its welcome, and a stop at pebblelemon confirmed that economical approach runs across the site, knowing when to stop is a skill many writers never develop but here the discipline is obvious and welcome from the perspective of a busy reader trying to learn things efficiently.

    Reply
  47. LloydAsPeT

    I really like how the writer keeps the tone friendly without sounding fake or overly polished, and after a stop at tokenudon 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

Leave a Reply

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