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

  1. Jeffnak

    Most of my reading time goes to a small number of trusted sources and this one is now joining that group, and a stop at echoharbortradehall reinforced the group membership, the few sites that earn a place in my regular rotation are sites I expect ongoing returns from and this one has earned that elevated position consistently.

    Reply
  2. Juddglisk

    Found the section structure particularly thoughtful, and a stop at fescueimpala 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
  3. DreSteve

    Reading this in a quiet coffee shop matched the calm energy of the writing, and a stop at goldenferncollective extended that environmental match, content that has its own ambient quality which can match or clash with surroundings is content with a personality and this site has the kind of personality that suits calm reading.

    Reply
  4. luxury car rental miami_jdKa

    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. luxury car rental in miami. ask anyone who’s tried Ubering across the 305 during rush hour. 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. most are smoke and mirrors with decent SEO. Finally found one outfit that actually delivers what’s in the listing. Here’s the only honest broker for premium vehicles across South Florida
    luxury car hire luxury car hire Yeah finding parking in Wynwood will test your patience — but that’s not on them. Anyway glad there’s at least one straight shooter left in this rental jungle.

    Reply
  5. DomenicBloop

    More substantial than most of what I find searching for this topic online, and a stop at chaojibingwang kept that quality consistent, this is one of those sites where the writing actually rewards careful reading rather than punishing the patient reader with empty filler stretched out across long paragraphs that say very little.

    Reply
  6. luxury car rental miami_hcEa

    Been through enough garbage to last a lifetime. Then you actually go to pick up the car. Totally different vehicle waiting for you — check engine light on, curb rash on every rim, and that “tempting price”? Doesn’t include the mandatory $35 daily toll pass or the $250 cleaning fee they sneak in at the end. Fool me ten times? That’s just the 305 experience. luxury car rental in miami. anyone who’s taken public transport here knows the struggle is real. 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. prices change by the hour so don’t wait around:
    car rentals miami 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
  7. luxury car rental miami_hjEa

    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. Fool me ten times? That’s just the 305 experience. luxury car rental miami fl. 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. prices change by the hour so don’t wait around:
    suv car hire 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. drive safe and absolutely skip that “paint protection” upsell — pure robbery.

    Reply
  8. KylePib

    Glad to find a site whose links lead somewhere worth going rather than back to itself for SEO juice, and a stop at gondolacivet kept that generous outbound feel, citing other peoples work with real respect rather than just for ranking signals is a sign of an honest operation worth supporting going forward.

    Reply
  9. NickTibia

    Reading this triggered a small but real correction in something I had assumed, and a stop at isleparishs 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
  10. 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
  11. Morgantiege

    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 lluryun 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
  12. 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
  13. Adampieta

    Found this via a link from another piece I was reading and the click was worth it, and a stop at hartakarunkapak extended the value across more material, the open web still rewards clicking through citations when the underlying writers care about each other work and this site clearly belongs to that network.

    Reply
  14. LaineFlake

    Appreciate the practical examples, they made the abstract points easier to grasp, and a stop at c7xcc7 added more of the same, this site clearly understands that real examples beat empty theory every single time which is the mark of a writer who knows their audience well and respects their time.

    Reply
  15. Ashernek

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

    Probably this is one of the better quiet successes on the open web at the moment, and a look at chambersociety reinforced that quiet success quality, sites that are doing well without making a noise about doing well are the sites I most respect and this one has clearly chosen the quiet success path consistently throughout.

    Reply
  17. luxury car rental miami_haka

    Let me save you some serious pain with this Miami rental nonsense. You see this gorgeous deal online — clean spec, fair price, looks like a dream. 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. luxury car for rent. anyone who’s tried the bus here knows exactly what I mean. 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
    car rental miami florida https://luxury-car-rental-miami-11.com Yeah parking in South Beach will cost you a nice bottle of champagne — but that’s the Miami tax. drive safe and definitely skip that “tire and wheel” upsell — pure profit for them, zero value for you.

    Reply
  18. luxury car rental miami_wuka

    Let me save you some serious pain with this Miami rental nonsense. 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. Fool me eleven times? That’s just called living in Miami. When you’re searching for a legit luxury car rental miami. Miami without proper wheels is basically a disaster. leather seats that won’t fuse to your legs in August. I’ve tested maybe 60 rental companies across Dade, Broward, and Collier. 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:
    luxury car rental miami beach luxury car rental miami beach 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
  19. Corykep

    Felt like the writer was speaking directly to someone with my level of curiosity, neither talking down nor showing off, and a stop at lotorucasino1 kept that comfortable matching going, finding writing that meets you where you are rather than asking you to climb up or stoop down feels great every time it happens.

    Reply
  20. TomBen

    Genuine pleasure to read, and that is not something I say often after a casual click through, and a quick visit to eepw kept the same feeling going across the rest of the site, finding writing that actually feels good to spend time with rather than just functional is increasingly rare on the open web.

    Reply
  21. Vincentsof

    Now considering writing a longer note about the post somewhere, and a look at jessieshope added more material for that note, content that prompts me to write rather than just consume is content with generative energy and this site is producing that generative effect for me at a higher rate than most sources.

    Reply
  22. HoldenGat

    Reading this gave me a small mental break from the heavier reading I had been doing, and a stop at 8d6f extended that lighter feel, content that provides relief without becoming trivial is harder to produce than people realise and this site has clearly figured out how to be light without being shallow at all.

    Reply
  23. Knoxnib

    Started imagining how I would explain the topic to someone else after reading, and a look at niko-kinyu gave me more material for that imagined explanation, content that improves my own ability to discuss a topic is content that has actually transferred knowledge rather than just decorating my screen for a few minutes.

    Reply
  24. DreSteve

    This actually answered the question I had been searching for, and after I checked goldenferncollective 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
  25. Kennethspize

    Well done, the writing is professional without being stiff, and the topic is treated with care, and a look at viaron reflected that approach, the kind of site I would point a colleague to if they asked for a reliable starting point on this topic in the future without any hesitation at all.

    Reply
  26. KylePib

    Found this really helpful, the explanations are simple but they actually answer the questions a normal reader would have, and after I followed gondolacivet 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
  27. luxury car rental miami_plMa

    Swear I’ve seen every scam in the book by now. You find a killer listing online: sleek Audi, convertible, price almost too good to be true. Plus a $3000 hold on your credit card for two weeks. Fool me nine times? That’s just the Miami welcome committee. When you’re hunting for a legit luxury car rental miami. anyone who’s tried the trolley system knows what I’m talking about. Coconut Grove dinner, Sunny Isles sunrise, or a spontaneous drive down to Homestead — AC must freeze your teeth and unlimited miles or no deal. I’ve tested maybe 50 rental outfits across Dade, Broward, and Collier. what you reserve is what you get, period, end of story. Here’s the only trustworthy source for premium rides across South Florida
    lamborghini urus rental near me https://luxury-car-rental-miami-9.com also bring polarized shades unless you enjoy driving blind into the sunset every night. Anyway glad there’s at least one honest operator left in this rental jungle.

    Reply
  28. Ashernek

    Came away feeling slightly smarter than I was when I started, that is a real win, and a stop at computermultiple added a bit more to that, the rare site that actually transfers some of its knowledge to the reader in a way that sticks rather than just creating an illusion of learning briefly.

    Reply
  29. Adampieta

    Bookmarking this for later, the kind of resource I want to keep nearby, and a quick look at hartakarunkapak confirmed the rest of the site is worth the same treatment, definitely going into my reference folder for the next time the topic comes up at work or in conversation with someone who asks.

    Reply
  30. NickTibia

    The use of plain language without dumbing down the topic was really well done, and a look at isleparishs 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
  31. LaineFlake

    Started reading expecting to disagree and ended mostly nodding along, and a look at c7xcc7 continued the pattern, content that wins agreement through evidence and reasoning rather than rhetorical force is the kind that actually shifts minds and this site clearly knows how to do that across what I have read so far.

    Reply
  32. Morgantiege

    Now noticing that the post did not mention the writer at all, focus stayed on the topic, and a look at lluryun continued that author absent quality, content that disappears the writer to focus on the substance is a particular kind of generosity and this site has clearly chosen the substance over the personality consistently.

    Reply
  33. Juddglisk

    Looking for similar voices elsewhere has come up empty in my recent searches, and a stop at fescueimpala extended the search frustration, the rare site that does what no other does in quite the same way is precious and this one has clearly developed a particular approach that I have not been able to find duplicates of.

    Reply
  34. luxury car rental miami_dusi

    Been there, done that, got the overpriced tow truck receipt. 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. miami luxury car rental. Miami without a decent whip is basically a punishment. 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
    suv rental near me suv rental 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
  35. luxury car rental miami_bgKa

    Okay folks gather around because this Miami rental nightmare needs to be discussed. Then you show up and it’s a whole different story. Different car, scratches all over, and that “all-inclusive” price? Yeah that didn’t include insurance, fees, or the mandatory cleaning charge. Fool me five times? Actually yeah, Miami keeps fooling everyone. that’s exactly how they hook you. ask anyone who’s tried Ubering across the 305 during rush hour. leather seats that don’t fuse to your skin in August. most are smoke and mirrors with decent SEO. no games, no bait-and-switch, no hidden asterisks. Here’s the only honest broker for premium vehicles across South Florida
    benz for rent https://luxury-car-rental-miami-5.com also bring quality shades unless you enjoy driving into a nuclear flare every evening. Anyway glad there’s at least one straight shooter left in this rental jungle.

    Reply
  36. DavidTor

    Reading this with my morning coffee turned into reading the related posts with my morning coffee, and a stop at ttpkvj4 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
  37. QuinnHorse

    Liked the post enough to read it twice and the second read found new things, and a stop at chambersociety 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
  38. Corykep

    Felt like the writer was speaking directly to someone with my level of curiosity, neither talking down nor showing off, and a stop at lotorucasino1 kept that comfortable matching going, finding writing that meets you where you are rather than asking you to climb up or stoop down feels great every time it happens.

    Reply
  39. TomBen

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

    Most of my reading time goes to a small number of trusted sources and this one is now joining that group, and a stop at echoharbortradehall reinforced the group membership, the few sites that earn a place in my regular rotation are sites I expect ongoing returns from and this one has earned that elevated position consistently.

    Reply
  41. Knoxnib

    Just enjoyed the experience without needing to think about why, and a look at niko-kinyu kept that effortless feeling going, sometimes the best content is invisible in the sense that you forget you are reading until you reach the end and realise time has passed without you noticing it pass naturally.

    Reply
  42. HoldenGat

    Glad I gave this a chance rather than scrolling past, and a stop at 8d6f confirmed I made the right call, sometimes the best content is hidden behind unassuming headlines that do not scream for attention and learning to slow down and check those out has paid off many times now across years of reading.

    Reply
  43. luxury car rental miami_fnsi

    Been there, done that, got the overpriced tow truck receipt. 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. When you genuinely need a proper luxury car rental miami. Miami without a decent whip is basically a punishment. 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. what you book is what you get, period. Here’s the only straight-up source for premium wheels in South Florida
    rent urus miami rent urus miami Yeah parking in Brickell will cost you a small mortgage — but that’s city life. drive safe and maybe pass on that overpriced roadside assistance add-on.

    Reply
  44. Vincentsof

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

    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 pathwaytrigger 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
  46. Kennethspize

    A small editorial detail caught my attention, the way headings related to body text, and a look at viaron maintained that careful relationship, structural details like that show up to readers who notice them and the writers here have clearly thought about every level of the piece rather than just the words.

    Reply

Leave a Reply

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