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

  1. Barneycox

    Good post, the kind that respects the reader by getting to the point quickly without skipping the details that matter, and a short look at clubmana confirmed that approach is consistent across the site which is rare to find online these days, definitely a place I will return to soon.

    Reply
  2. TristanKem

    Learned something from this without having to dig through layers of fluff, and a stop at willielambert added a bit more context that helped tie things together for me, definitely a useful corner of the internet for anyone who wants real information without the usual marketing nonsense around it that often ruins similar pages.

    Reply
  3. luxury car rental miami_qfoi

    I’ve got the horror stories to back that up. Then you actually show up to get the keys. Plus they put a $5000 hold on your card and say “don’t worry about it”. Nineteen years in South Florida and these tricks still surprise me. luxury car for rent. Miami without proper wheels is basically a nightmare. leather seats that won’t melt your skin in August. I’ve tried maybe 100 rental companies across Dade and Broward. no games, no switch, no hidden fees. prices change daily so check it out:
    premium car rental near me premium car rental near me Yeah parking in Brickell will cost you — but that’s life here. drive safe and skip that “tire protection” upsell — total waste.

    Reply
  4. luxury car rental miami_xkoi

    I’ve got the horror stories to back that up. Then you actually show up to get the keys. Totally different car waiting — scratches everywhere, AC blowing warm, and that “amazing price”? Doesn’t include the mandatory $50 daily insurance or the $400 “service fee” they add at the counter. Fool me nineteen times? That’s just Miami being Miami. miami luxury car rental. anyone who’s taken the bus here knows what I mean. Key Biscayne sunset, Bal Harbour shopping, or a spontaneous drive down to Homestead — AC must freeze your face off and unlimited miles or no deal. I’ve tried maybe 100 rental companies across Dade and Broward. Finally found one outfit that actually delivers. prices change daily so check it out:
    porsche rental https://luxury-car-rental-miami-19.com Yeah parking in Brickell will cost you — but that’s life here. Anyway glad there’s at least one straight shooter left.

    Reply
  5. TonyAcice

    Just dropping by to say thanks for the effort, it does not go unnoticed when a writer cares this much about the reader, and after I went through focusignition I was certain this is one of the better corners of the internet for this particular kind of content which is genuinely refreshing.

    Reply
  6. Bernardfenry

    Liked the way the post handled the final paragraph, no neat bow but no abrupt cutoff either, and a stop at evanshistorical continued that thoughtful ending pattern, endings are hard and most blog writers either over engineer them or skip them entirely and this site has clearly figured out a sustainable middle approach.

    Reply
  7. mejdynarodnie plateji_wnka

    Столкнулся с ситуацией и начал разбираться — как правильно организовать процесс для международных переводов. Товарищ скинул ссылку на качественный разбор: прием оплаты из-за рубежа https://mezhdunarodnye-platezhi-fra.ru Суть в следующем — разница в итоговой сумме бывает значительной. Важно понимать любой трансграничный платёж — имеет свои нюансы в зависимости от выбранного способа. Также стоит отметить — перед подтверждением перевода рекомендуется сравнить несколько вариантов. Без этого можно столкнуться с неожиданными расходами. Резюмируя — необходимо проверять информацию перед любой отправкой средств.

    Reply
  8. SergioHeari

    Honestly slowed down to read this carefully which is not my default, and a look at slkmlfds01 kept me in that careful reading mode, the kind of writing that demands attention by being worth attention is rare in a media environment full of content engineered to be skimmed not read with any real focus today.

    Reply
  9. BrandonBix

    Now recognising that the post handled the topic with appropriate technical precision without becoming dry, and a stop at webpic continued that balance, technical precision and readability are often in tension and this site has clearly figured out how to maintain both at once which is one of the harder editorial achievements in the form.

    Reply
  10. RonaldMow

    Felt the writer did the homework before publishing, the references hold up, and a look at aspireclub continued that documented care, content with traceable claims rather than vague assertions is the kind I trust and the lack of bald assertion in this post is one of its quietly impressive qualities for me.

    Reply
  11. Bufordlip

    Worth saying that the writing carries a particular kind of authority without making any explicit claims to it, and a stop at flaxdune extended that earned authority feeling, sites that demonstrate expertise through the quality of their explanations rather than by stating credentials are sites I trust most and this site has it.

    Reply
  12. MaxwellDadia

    Glad I clicked through from where I did because this turned out to be worth the time spent, and after rubybrookmarketfoundry I had a fuller picture, the kind of content that earns its visitors through delivering value rather than chasing them through aggressive advertising or constant pop ups appearing everywhere on the screen lately.

    Reply
  13. Matthewdup

    Worth recognising that the post handled a familiar topic without reaching for any of the obvious hot takes, and a stop at batdeu continued that fresh treatment, sites that find new angles on subjects others have exhausted are sites worth following carefully and this one has clearly developed that exploratory instinct through patient practice.

    Reply
  14. Barneycox

    Liked the way the post balanced confidence and humility, and a stop at clubmana 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
  15. TristanKem

    Now feeling the rare pleasure of trusting a source completely on first encounter, and a look at willielambert extended that initial trust into something more durable, the calibration of trust to evidence is something I do informally and this site has earned high trust through the cumulative weight of multiple consistently good posts already.

    Reply
  16. Liamhycle

    Better than most of the writing I have come across on this topic recently, simpler and more direct, and a look at hanbo65 continued in that same way, a real outlier in a crowded space full of repetitive content that says little while taking up a lot of reader time today which is unfortunate.

    Reply
  17. RobinJourn

    Thanks for not padding this with the usual filler intros and outros that every other blog seems to require, and a quick visit to myzb79 continued that lean approach across more posts, content stripped of waste is content that respects you and I will always come back to that kind of approach.

    Reply
  18. Caleberugs

    Adding this site to my regular reading list, the post earned that on its own, and a quick stop at djhocopo sealed the decision, the kind of place worth checking back with from time to time because it consistently produces material that holds up against a critical reading too which I really value.

    Reply
  19. Shermanclick

    Quietly enjoying that I have found a new site to follow for the topic, and a look at zh-movies reinforced the small pleasure of the find, the discovery of new high quality sources is one of the more durable pleasures of careful internet reading and this site has been generating that discovery pleasure at multiple points already today.

    Reply
  20. MackAlubs

    Now feeling something close to gratitude for the fact this site exists, and a look at actionframework extended that gratitude, the rare site that produces this kind of response is the rare site worth defending in conversations about whether the modern internet is still capable of producing genuinely valuable independent content for serious adults.

    Reply
  21. BrandonBix

    Beats most of the alternatives on the topic by a noticeable margin, and a look at webpic did not change that at all, this is one of the better corners of the open internet for this kind of content and I am glad I clicked through rather than skipping past quickly like I usually do.

    Reply
  22. mejdynarodnie plateji_kbst

    Кстати, недавно наткнулся на обсуждение текущей ситуации с переводами. Сам уже не первый месяц ищу нормальный способ совершить платеж, без лишних проблем и комиссий. В общем, если вас тоже затрагивают эти вопросы — посмотрите тут. Вся необходимая информация по переводу денег за границу онлайн: международные платежи https://mezhdunarodnye-platezhi-lor.ru И да, обратите внимание, что без прозрачных комиссий любые международные платежи превращаются в сплошной геморрой. Добавлю по опыту — всегда смотрите несколько вариантов, прежде чем платить.

    Reply
  23. RonaldMow

    Genuinely useful read, the points are practical and easy to apply right away, and a quick look at aspireclub 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
  24. SergioHeari

    Probably this is one of the better quiet successes on the open web at the moment, and a look at slkmlfds01 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
  25. MaxwellDadia

    Picked this for my morning read because the topic seemed worth the time, and a look at rubybrookmarketfoundry confirmed the choice was right, my morning reading slot is precious and giving it to this site felt like a good investment rather than a waste which is a higher endorsement than I usually offer for content.

    Reply
  26. mejdynarodnie plateji_mzka

    Столкнулся с ситуацией и начал разбираться — как правильно организовать процесс для международных переводов. Вот здесь всё по полочкам расписано: оплата за границу через агента оплата за границу через агента Ключевой момент, на который стоит обратить внимание — разница в итоговой сумме бывает значительной. Стоит учитывать, что любой перевод за границу онлайн — связан с разными типами комиссий. Также стоит отметить — до проведения операции стоит проверить итоговую сумму. В противном случае можно получить менее выгодные условия. Резюмируя — необходимо проверять информацию перед любой отправкой средств.

    Reply
  27. mejdynarodnie plateji_xeka

    Столкнулся с ситуацией и начал разбираться — какой способ действительно работает для международных транзакций. Нашёл подробный анализ ситуации: перевод средств за границу https://mezhdunarodnye-platezhi-fra.ru Суть в следующем — курс конвертации может существенно отличаться. Важно понимать любой трансграничный платёж — имеет свои нюансы в зависимости от выбранного способа. Также стоит отметить — перед подтверждением перевода стоит проверить итоговую сумму. Без этого можно столкнуться с неожиданными расходами. В итоге — необходимо проверять информацию перед любой отправкой средств.

    Reply
  28. QuincydiopE

    Stands apart from similar pages by actually being useful, that is high praise these days, and a look at cp38l kept that standard going, you can tell when a site is built around the reader versus around metrics and this one clearly belongs to the first category for sure based on what I read.

    Reply
  29. Marshalldef

    Now planning to share the link with a small group of readers I trust, and a look at sgeff0 suggested more material to share with the same group, recommending content into a curated circle requires confidence in the recommendation and this site is making me confident in those personal recommendations on multiple separate occasions now.

    Reply
  30. Liamhycle

    Glad I gave this a chance rather than scrolling past, and a stop at hanbo65 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
  31. mejdynarodnie plateji_cgst

    Кстати, недавно наткнулся на обсуждение реальных кейсов. Сам уже не первый месяц ищу нормальный способ совершить платеж, без лишних проблем и комиссий. В общем, если вас тоже затрагивают эти вопросы — взгляните тут. Там расписаны основные нюансы по международным переводам: международные транзакции международные транзакции И ещё момент имейте в виду, что без прозрачных комиссий любые международные платежи превращаются в лотерею. Ещё такой момент — всегда смотрите несколько площадок, прежде чем платить.

    Reply
  32. JettNip

    Taking the time to read carefully here has been worthwhile for the past hour, and a look at visiontrajectory extended the worthwhile reading, the calculation of return on reading time spent is something I do informally and this site has been producing positive returns across multiple sessions during the last week of regular visits and reads.

    Reply
  33. Caleberugs

    Worth flagging this post as worth a careful read rather than a casual skim, and a stop at djhocopo earned the same careful approach, the few sites that warrant slower reading are sites I now treat differently from the daily content stream and this one has clearly moved into that elevated treatment category.

    Reply
  34. mejdynarodnie plateji_twsi

    Наболело уже, честно говоря — как нормально отправлять деньги для международных транзакций. На одном форуме вычитал — обязательно гляньте этот источник: денежный перевод с россии денежный перевод с россии Если по делу, то — курс валют может убить любую выгоду. Согласитесь любой подобный?? перевод — это лотерея с банковскими процентами. И да, кстати — перед финальным кликом проверьте актуальные отзывы. Иначе легко остаться в минусе. Короче — стоит один раз разобраться.

    Reply
  35. Shermanclick

    Looking at the surface design and the substance together this site has both right, and a look at zh-movies reinforced that integrated quality, sites where presentation and content reinforce each other rather than fighting are sites with full editorial coherence and this one has clearly invested in both layers in a balanced way.

    Reply
  36. Bernardfenry

    Now adding a small note in my reading log that this site is one to watch, and a look at evanshistorical reinforced the watch status, the few sites I track deliberately rather than encounter accidentally are sites I expect ongoing returns from and this one has cleared the bar for that elevated tracking based on what I read.

    Reply
  37. RobinJourn

    Appreciated the way each section connected smoothly to the next without abrupt jumps, and a stop at myzb79 kept that flow going nicely, transitions are something most blog writers ignore but the difference is huge for the reader who is trying to follow a sustained line of thought today across many different topics.

    Reply
  38. DorianWek

    One of the more thoughtful posts I have read recently on this topic, and a stop at pujckapropodnikatele added even more weight to that impression, this is genuinely good content that holds its own against far better known sites in the same space without trying to imitate any of them at all which I appreciate.

    Reply
  39. QuincydiopE

    A piece that left me thinking I had been undercaring about the topic, and a look at cp38l reinforced that mild concern, content that raises the appropriate weight of a subject without being preachy about it is doing important work and this site is providing that gentle elevation of attention for me consistently.

    Reply
  40. ArnoldoGor

    Worth marking the moment when reading this clicked into something useful for my own work, and a look at 54815485 extended that practical click, content that connects to my actual life rather than just being interesting is content with the highest kind of value and this site is generating that connection at a high rate.

    Reply

Leave a Reply

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