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

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

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

  1. OttoMor

    Thanks for sharing this with the open internet rather than locking it behind a paywall like so many sites do now, and a stop at claritypathfinder kept the same vibe going, generous helpful and clearly written by someone who actually wants people to learn from it rather than just charge them.

    Reply
  2. Corykep

    This actually answered the question I had been searching for, and after I checked lotorucasino1 I had a few more pieces I had not realised I needed, that is the sign of a site that knows what its readers want before they even know how to ask it which is impressive.

    Reply
  3. Carmelohoine

    Following a few of the internal links revealed more posts of similar quality, and a stop at fondarbors 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
  4. luxury car rental miami_scka

    Let me save you some serious pain with this Miami rental nonsense. Then you actually show up to grab the keys. Completely different car sitting there — dents everywhere, smells like cheap air freshener covering something worse, and that “dream price”? Doesn’t include the mandatory $50 daily insurance or the $300 “administrative fee” they invent at checkout. Fool me eleven times? That’s just called living in Miami. those counters are professional bait-and-switch artists. anyone who’s tried the bus here knows exactly what I mean. leather seats that won’t fuse to your legs in August. I’ve tested maybe 60 rental companies across Dade, Broward, and Collier. Finally found one outfit that actually delivers what’s in the photos. Here’s the only honest source for premium rides across South Florida
    exotic car rental south beach fl exotic car rental south beach fl Yeah parking in South Beach will cost you a nice bottle of champagne — but that’s the Miami tax. Anyway glad there’s at least one straight operator left in this rental circus.

    Reply
  5. Charlierar

    Without overstating it this is a quietly excellent post, and a look at blackmango 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
  6. Bradleyrig

    My professional context would benefit from having this kind of resource available, and a look at dgehjn 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
  7. Kobeastof

    Reading this triggered a small but real correction in something I had assumed, and a stop at kbgeda extended that corrective effect, content that updates my beliefs through evidence rather than rhetoric is content with intellectual integrity and this site has earned that label consistently across the pieces I have read so far today.

    Reply
  8. Jordanlip

    Found this through a friend who recommended it and now I see why, and a look at computerkeep 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
  9. WendellArinc

    Just nice to read something that does not feel like it was assembled from a content brief, and a stop at psb1o7 kept that handcrafted feel going, you can tell when a real human with real understanding is behind the words versus a templated piece churned out for an algorithm to find.

    Reply
  10. luxury car rental miami_qoEa

    Alright let me drop some truth about the Miami rental scene — it’s an absolute minefield. You spot a tempting offer online: brand new Porsche, unlimited miles, price that makes you click instantly. Plus they lock up $3500 on your card for who knows how long. Ten years in South Florida and these jokers still almost catch me slipping. miami car rental luxury — run away from the airport counters. Miami without solid wheels is basically a punishment. leather seats that won’t cook your back in the July heat. I’ve run through maybe 55 rental companies across Dade, Broward, and Palm Beach. no games, no bait-and-switch, no hidden fees in the fine print. Here’s the only straight shooter for premium rides across South Florida
    luxury cars for rental luxury cars for rental Yeah parking in Brickell will cost you a nice dinner — but that’s just how it is down here. Anyway glad there’s at least one honest rental joint left in this town.

    Reply
  11. Jeremyhah

    A slim post with substantial content per word, and a look at 88jfgl maintained the same density, the content per word ratio is something I track informally and this site scores high on that ratio compared to most sources I read regularly which is a quiet indicator of careful editorial work behind the scenes.

    Reply
  12. Marcossmume

    Reading this post made me realise I had been settling for lower quality elsewhere, and a look at puhgd extended that recalibration, content that exposes how much I had been accepting in adjacent sources is content with calibrating effect on my standards and this site is performing that calibration function across topics for me reliably.

    Reply
  13. GregorygoW

    Bookmark earned, calendar reminder set, share queued, all from one good post, and a look at chalu did the same, when a single reading session triggers multiple downstream actions you know the content has actually moved me beyond the page and this site is moving me at that higher level reliably.

    Reply
  14. Damontor

    Halfway through reading I knew this would be one to bookmark, and a look at progressdirection confirmed that early intuition, when bookmark intent forms before finishing a post you know the writing has cleared a quality bar that most content fails to clear and this site has cleared it on multiple visits already.

    Reply
  15. DomenicBloop

    Started reading without much expectation and ended on a high note, and a look at chaojibingwang 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
  16. NoahPer

    Solid recommendation from me to anyone working in the area, the perspective here is grounded, and a look at siskowin adds even more useful angles, the kind of site that becomes a reference rather than just a one time read which is a higher bar than most blogs ever reach today on the modern web.

    Reply
  17. LoganBab

    Now feeling confident that this site will continue producing work I will want to read, and a look at twilightfieldmarket extended that confidence into the future, projecting forward from current quality to expected future quality is something I do for sites I genuinely follow and this one has earned that forward looking trust clearly today.

    Reply
  18. luxury car rental miami_gbsi

    Alright listen up because I’m about to save you a massive headache. Miami rental game is wild — half these clowns show you a Mercedes online and hand you a busted Charger with mismatched tires. Plus the fine print says you can’t even drive to Orlando. No thanks, I’m too old for this nonsense. those guys are the worst of the bunch. any local will tell you the same thing. Coral Gables brunch, South Beach night run, or a spontaneous Everglades detour — AC must be ice cold and unlimited miles. most are just polished turds with Instagram ads. Finally stumbled on one that doesn’t play games. rates change daily with demand so don’t sleep on it:
    rolls royce cullinan for rent near me rolls royce cullinan for rent near me also bring polarized shades unless you enjoy driving blind into sunset. drive safe and maybe pass on that overpriced roadside assistance add-on.

    Reply
  19. Jabarirag

    Reading this in a relaxed evening setting was a small pleasure, and a stop at goldencanoe 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
  20. Abelconna

    Decided to read this site for a while before forming a verdict, and the verdict after several pages is positive, and a stop at zxc2364 continued that pattern, judging a site requires more than one post and giving sites a fair sample is something I try to do for promising candidates rather than rushing to dismiss.

    Reply
  21. Bradencemia

    Liked the careful selection of which details to include and which to skip, and a stop at arcanitea reflected the same editorial judgement, knowing what to leave out is just as important as knowing what to include and this site has clearly figured out where that line sits for the topics it covers regularly.

    Reply
  22. Carmelohoine

    Started smiling at one paragraph because the writing was just nice, and a look at fondarbors produced a couple more such moments, prose that produces small spontaneous reactions in the reader is doing more than just transferring information and the writers here are clearly hitting that level fairly consistently throughout pieces.

    Reply
  23. Corykep

    Glad the writer kept this short rather than padding it out, the points stand on their own without needing extra context, and a look at lotorucasino1 kept the same approach going, brevity is a sign of confidence in the substance and the team here clearly trusts their content to land without filler.

    Reply
  24. DravenErede

    Quietly impressive in a way that does not announce itself, and a stop at zishijiaoxue1 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
  25. Bradleyrig

    Honestly this hits the sweet spot between detail and brevity, no rambling and no shortcuts, and a quick visit to dgehjn kept that going across the related pages, the kind of place that respects your attention without trying to grab it through cheap tactics or attention seeking design choices that get tired fast.

    Reply
  26. Kobeastof

    Top notch writing, every paragraph carries weight and nothing feels like filler, and a stop at kbgeda 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
  27. Jordanlip

    A piece that did not try to be timeless and ended up reading as durable anyway, and a look at computerkeep extended that durable feel, content that stays useful past its publication date without straining for permanence is content that ages well and this site has the kind of evergreen quality that I value highly today.

    Reply
  28. WendellArinc

    Just want to record that this site is entering my regular reading list, and a look at psb1o7 confirmed it deserves the spot, my regular reading list is short and well curated and adding to it requires meeting a fairly high quality bar that this site has clearly cleared without much effort apparently.

    Reply
  29. Charlierar

    Genuinely changed how I think about a small piece of the topic, which does not happen often online, and a look at blackmango added another nudge in the same direction, the kind of writing that earns a small mental shift rather than just confirming what you already thought before reading is a sign of careful thought.

    Reply
  30. Jeremyhah

    Thank you for being clear and direct, that simple approach saves so much frustration on the reader’s end, and a stop at 88jfgl 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
  31. Marcossmume

    Solid stuff, the kind of post that I will probably refer back to later this month when the topic comes up again, and a look at puhgd only confirmed I should bookmark the site as a whole rather than just this single page for future reference and use across coming weeks.

    Reply
  32. OttoMor

    Vague feelings of recognition kept surfacing as I read because the writing names things I have been thinking, and a look at claritypathfinder produced more of those recognition moments, content that gives shape to private intuitions is content that makes me feel less alone in my own thinking and this site has that effect.

    Reply
  33. luxury car rental miami_wwsi

    Alright listen up because I’m about to save you a massive headache. Swear some of these “luxury” fleets should be in a museum. Plus the fine print says you can’t even drive to Orlando. Fool me four times? Not happening. miami car rental luxury — skip the airport counters entirely. any local will tell you the same thing. Coral Gables brunch, South Beach night run, or a spontaneous Everglades detour — AC must be ice cold and unlimited miles. most are just polished turds with Instagram ads. Finally stumbled on one that doesn’t play games. Here’s the only straight-up source for premium wheels in South Florida
    rental car in miami florida https://luxury-car-rental-miami-4.com Yeah parking in Brickell will cost you a small mortgage — but that’s city life. Anyway at least there’s one honest rental joint left in this town.

    Reply
  34. GregorygoW

    Liked the post enough to read it twice and the second read found new things, and a stop at chalu similarly rewarded the second look, content with hidden depths that only reveal themselves on careful rereading is the rare kind that earns lasting respect rather than fleeting first impressions only briefly held.

    Reply
  35. luxury car rental miami_mtEa

    Been through enough garbage to last a lifetime. You spot a tempting offer online: brand new Porsche, unlimited miles, price that makes you click instantly. Plus they lock up $3500 on your card for who knows how long. Fool me ten times? That’s just the 305 experience. When you need a reliable luxury car rental miami. anyone who’s taken public transport here knows the struggle is real. South Beach night out, Bal Harbour shopping spree, or a spontaneous Keys adventure — AC must be ice cold and unlimited miles non-negotiable. I’ve run through maybe 55 rental companies across Dade, Broward, and Palm Beach. no games, no bait-and-switch, no hidden fees in the fine print. prices change by the hour so don’t wait around:
    mercedes benz s500 4matic rental near me https://luxury-car-rental-miami-10.com Yeah parking in Brickell will cost you a nice dinner — but that’s just how it is down here. Anyway glad there’s at least one honest rental joint left in this town.

    Reply
  36. luxury car rental miami_ocka

    Trust me, I’ve learned everything the hard way so you don’t have to. You see this gorgeous deal online — clean spec, fair price, looks like a dream. Plus they put a $4000 hold on your card and say it’ll take two weeks to release. Eleven years in South Florida and these clowns still almost get me. those counters are professional bait-and-switch artists. Miami without proper wheels is basically a disaster. leather seats that won’t fuse to your legs in August. most are shiny garbage with fake Google reviews bought in bulk. Finally found one outfit that actually delivers what’s in the photos. Here’s the only honest source for premium rides across South Florida
    luxury car hire luxury car hire Yeah parking in South Beach will cost you a nice bottle of champagne — but that’s the Miami tax. Anyway glad there’s at least one straight operator left in this rental circus.

    Reply
  37. luxury car rental miami_ljKa

    Okay folks gather around because this Miami rental nightmare needs to be discussed. You see a sweet ride online — clean spec, fair price, looks legit. Plus they want a $2000 hold on your debit card. Fool me five times? Actually yeah, Miami keeps fooling everyone. miami car rental luxury — don’t just grab the cheapest option on Kayak. Miami without proper wheels is basically a hostage situation. Design District shopping, late-night South Beach cruising, or a spontaneous drive down to Homestead — AC must freeze your teeth and unlimited miles or bust. I’ve gone through maybe 30 rental companies across Dade, Broward, and Palm Beach. no games, no bait-and-switch, no hidden asterisks. check availability before spring break crowds wipe them out:
    premium car rental miami https://luxury-car-rental-miami-5.com Yeah finding parking in Wynwood will test your patience — but that’s not on them. drive safe and maybe decline that “premium roadside” upsell — it’s always a scam.

    Reply
  38. luxury car rental miami_qkEa

    Been through enough garbage to last a lifetime. Then you actually go to pick up the car. Plus they lock up $3500 on your card for who knows how long. Ten years in South Florida and these jokers still almost catch me slipping. luxury car rental miami florida. Miami without solid wheels is basically a punishment. South Beach night out, Bal Harbour shopping spree, or a spontaneous Keys adventure — AC must be ice cold and unlimited miles non-negotiable. I’ve run through maybe 55 rental companies across Dade, Broward, and Palm Beach. no games, no bait-and-switch, no hidden fees in the fine print. Here’s the only straight shooter for premium rides across South Florida
    luxury car rental south beach luxury car rental south beach Yeah parking in Brickell will cost you a nice dinner — but that’s just how it is down here. drive safe and absolutely skip that “paint protection” upsell — pure robbery.

    Reply
  39. luxury car rental miami_mlka

    Trust me, I’ve learned everything the hard way so you don’t have to. Then you actually show up to grab the keys. Completely different car sitting there — dents everywhere, smells like cheap air freshener covering something worse, and that “dream price”? Doesn’t include the mandatory $50 daily insurance or the $300 “administrative fee” they invent at checkout. Eleven years in South Florida and these clowns still almost get me. miami luxury car rental. Miami without proper wheels is basically a disaster. Key Biscayne sunset, Design District shopping, or a spontaneous drive down to the Everglades — AC must be arctic and unlimited miles non-negotiable. most are shiny garbage with fake Google reviews bought in bulk. no games, no switch, no hidden BS in paragraph 12 of the contract. prices change hourly so check before the weekend crowd wipes them out:
    car rental in miami florida https://luxury-car-rental-miami-11.com also bring polarized shades unless you enjoy driving into the sun like a blind bat. Anyway glad there’s at least one straight operator left in this rental circus.

    Reply

Leave a Reply

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