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

  1. kyhni SPb_ueSn

    Народ всем привет Прошерстил 30 салонов — везде перекупы То ручки через месяц шатаются Короче, нашел наконец нормальную контору — кухни в спб от производителя с гарантией Кромка немецкая 2 мм В общем, сохраняйте в закладки — кухня глория https://kuhni-spb-nbg.ru Не ведитесь на салоны-прокладки с наценкой 200% Сам полгода выбирал теперь знаю

    Reply
  2. CoryInori

    Speaking from the perspective of having read widely on the topic this site offers something distinct, and a look at k786 reinforced that distinctness, the rare site that contributes something genuinely original to a saturated topic is the rare site worth following carefully and this one has demonstrated that original contribution capability today.

    Reply
  3. LoganUrbah

    Most of the time I feel the open web is in decline and then I find a site like this, and a stop at 93tv reinforced that mood lift, the cumulative effect of finding occasional excellent independent content versus the cumulative effect of finding mostly mediocre content is real for the long term reader maintaining web habits today.

    Reply
  4. Earlmet

    Recommended without hesitation if you care about careful coverage of this topic, and a stop at ynl3uklt reinforced the recommendation, the bar I set for unhesitating recommendations is fairly high and this site has cleared it through the cumulative weight of multiple consistently good pieces rather than through any single standout post which is meaningful.

    Reply
  5. Hoseaopibe

    Most blog writing on this subject reaches for the same handful of arguments and this post avoided them, and a look at 932ka continued the original treatment, content that finds its own path through territory other writers have flattened is content with real authorial energy and this site has plenty of that distinctive energy.

    Reply
  6. kyhni SPb_saOt

    Ребята всем привет Менеджеры врут про сроки и материалы То ЛДСП 16 мм а не 18 Короче, нашел нормальных производителей — заказать кухню по индивидуальным размерам Фасады на выбор из 50 цветов В общем, смотрите сами по ссылке — кухни на заказ спб каталог https://kuhni-spb-ytr.ru Проверяйте производителя по этому списку Сам полгода выбирал теперь знаю

    Reply
  7. kyhni SPb_ybSn

    Народ всем привет Качество пластилин То ручки через месяц шатаются Короче, нашел наконец нормальную контору — кухни в спб от производителя с гарантией Сделали за три недели как обещали В общем, вся инфа вот здесь — кухня на заказ спб от производителя недорого кухня на заказ спб от производителя недорого Проверяйте производителя по этому списку Сам полгода выбирал теперь знаю

    Reply
  8. CarternuT

    Speaking as someone who reads a lot on this topic this site has earned a high position in my source rankings, and a stop at careda reinforced that ranking, the informal ranking of sources for a topic is something I maintain mentally and this site has moved into the upper portion of those rankings clearly.

    Reply
  9. WillieSuets

    Started reading skeptically because the headline seemed overconfident, and the post earned the headline by the end, and a look at notfoundleads 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
  10. kyhni SPb_fgOt

    Слушайте кто ремонт затеял Оббегал все салоны в городе — везде одно и то же То ЛДСП 16 мм а не 18 Короче, нашел нормальных производителей — кухни в спб от производителя из массива Сделали за 2 недели включая замер В общем, жмите чтобы не потерять — кухня глория https://kuhni-spb-ytr.ru Проверяйте производителя по этому списку Перешлите другу кто тоже мучается

    Reply
  11. Earlmet

    Will share this on a forum I am part of where it will be appreciated by others working in the same area, and a look at ynl3uklt suggests there is more here worth passing along too, definitely a generous resource that deserves a wider audience than it probably has today across the open internet.

    Reply
  12. kyhni SPb_evOt

    Ребята всем привет Менеджеры врут про сроки и материалы То доставку три месяца ждать Короче, единственные кто делает совестливо — кухни СПб от производителя напрямую Сделали за 2 недели включая замер В общем, смотрите сами по ссылке — купить кухню на заказ спб https://kuhni-spb-ytr.ru Не ведитесь на салоны-прокладки с накруткой Перешлите другу кто тоже мучается

    Reply
  13. kyhni SPb_ceSn

    Ребята кто в Питере Цены задрали как на золото То ручки через месяц шатаются Короче, мужики с руками из правильного места — заказ кухни с установкой Сделали за три недели как обещали В общем, смотрите сами по ссылке — кухня на заказ спб от производителя недорого кухня на заказ спб от производителя недорого Не ведитесь на салоны-прокладки с наценкой 200% Сам полгода выбирал теперь знаю

    Reply
  14. Hoseaopibe

    During the time spent here I noticed the absence of the usual distractions, and a stop at 932ka extended that distraction free experience, content that does not fight my attention with pop ups and modals and aggressive prompts is content that respects me and this site has clearly chosen the respectful approach throughout.

    Reply
  15. kyhni SPb_hvSn

    Слушайте кто недавно кухню делал Прошерстил 30 салонов — везде перекупы То доставку месяц ждать Короче, нашел наконец нормальную контору — кухни на заказ в спб с фурнитурой Blum Сделали за три недели как обещали В общем, смотрите сами по ссылке — купить кухню на заказ в спб https://kuhni-spb-nbg.ru Не ведитесь на салоны-прокладки с наценкой 200% Сам полгода выбирал теперь знаю

    Reply
  16. kyhni SPb_gwEr

    Доброго времени Продаваны врут про материалы То сроки по полгода обещают Короче, единственные кто не наваривается в тридорога — заказать кухню по индивидуальным размерам Сделали 3D-проект бесплатно за час В общем, вся инфа вот здесь — кухня по индивидуальному проекту https://kuhni-spb-wxh.ru Не ведитесь на салоны в ТЦ которые просто заказывают у китайцев и ставят наценку 100% Перешлите тому кто тоже мучается выбором

    Reply
  17. Nedduh

    Now thinking about whether the writer might publish a longer form work I would buy, and a look at ludingtonmurals suggested the same depth would translate, content that makes me want to pay for related work in other formats is content that has earned commercial trust as well as attention trust and this site has both clearly.

    Reply
  18. LeoViets

    A piece that handled multiple complications without becoming confused, and a look at llinusllove continued that organisational clarity, holding multiple threads in a single piece without losing any of them is a sign of skilled writing and this site has clearly developed the editorial discipline to manage complexity without sacrificing readability throughout.

    Reply
  19. zakazat kyhnu_nnkl

    Ребята всем привет. Замучился я уже кухню искать. То кромка кривая через раз. Короче, нашел нормальных производителей — купить кухню в спб с установкой. Гарантия 5 лет на все. В общем, там цены и примеры работ — купить готовую кухню от производителя купить готовую кухню от производителя Проверяйте производителя по этому списку. Перешлите другу кто тоже мучается.

    Reply
  20. GaryJelry

    Reading this slowly to give it the attention it deserved, and a stop at naimei10 earned the same slow read, choosing to read slowly is a small act of respect for content quality and very few sites earn that respect from me but this one did so without any explicit ask which is the cleanest way.

    Reply
  21. Gradypek

    Bookmark earned and folder updated to track this site separately, and a look at candelillaa confirmed the folder upgrade was the right call, organising my reading list so that good sites do not get lost in a sea of casual bookmarks is something I do more carefully now and this site warranted its own spot.

    Reply
  22. JesusLen

    A handful of memorable phrases from this one I will probably use later, and a look at avanscreditipotecar2020 added a couple more, content that contributes language to my own communication rather than just facts is content with a different kind of utility and this site is providing that linguistic utility consistently across what I read.

    Reply
  23. Cecilkix

    Refreshing tone compared to the dry corporate posts on similar topics, and a stop at caama carried that personality through nicely, you can tell when a real person is behind the writing versus a content team chasing metrics and this site definitely falls into the former category clearly across what I have seen.

    Reply
  24. Nedduh

    Now recognising that this site has earned a place in the small group of resources I treat as authoritative, and a stop at ludingtonmurals 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
  25. CarternuT

    A handful of memorable phrases from this one I will probably use later, and a look at careda added a couple more, content that contributes language to my own communication rather than just facts is content with a different kind of utility and this site is providing that linguistic utility consistently across what I read.

    Reply
  26. LeoViets

    A piece that reads as if the writer trusted readers to fill in obvious gaps, and a look at llinusllove continued that respectful approach, content that does not over explain what the reader can infer is content that respects intelligence and this site has clearly chosen to write to capable readers rather than to the lowest common denominator.

    Reply
  27. zakazat kyhnu_dekl

    Ребята всем привет. Оббегал все салоны в городе — везде одно и то же. То кромка кривая через раз. Короче, реальный цех в СПб без наценок — купить кухню в спб с установкой. Цены ниже рыночных на треть. В общем, там цены и примеры работ — купить готовую кухню в спб от производителя https://zakazat-kuhnyu-dfg.ru Проверяйте производителя по этому списку. Сам полгода выбирал теперь знаю.

    Reply
  28. GaryJelry

    Reading this back to back with a similar piece elsewhere made the quality difference obvious, and a stop at naimei10 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
  29. kyhni SPb_jkpn

    Всем привет из культурной столицы Цены задрали как на золото То ДСП крошится Короче, реальное производство в Питере — заказ кухни с установкой Замер на следующий день В общем, там цены и каталог работ — кухня на заказ спб от производителя недорого кухня на заказ спб от производителя недорого Проверяйте производителя по этому списку Сам полгода выбирал теперь знаю

    Reply
  30. WillieSuets

    Just nice to read something that does not feel like it was assembled from a content brief, and a stop at notfoundleads 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
  31. Gradypek

    Just want to record that this site is entering my regular reading list, and a look at candelillaa 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
  32. BrendanWak

    Now sitting back and recognising that this was a small but real win in my reading day, and a stop at viralbet88i extended that quiet win, the cumulative effect of small reading wins versus the cumulative effect of small reading losses is real over time and this site is contributing to the wins side of that ledger.

    Reply
  33. Maxwellpence

    Adding to the bookmarks now before I forget, that is how good this is, and a look at banburya confirmed the rest of the site is worth saving too, this is one of those rare finds that justifies the time spent searching the web for once which is a relief in the current environment.

    Reply
  34. Darrenoxype

    Reading carefully this time rather than scanning, and the depth shows up in places I missed first time around, and a look at ssffgg77 rewarded the same careful approach, content that holds up to multiple reads is content I want more of in my regular rotation rather than disposable scroll fodder daily.

    Reply
  35. zakazat kyhnu_llMr

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

    Reply
  36. JesusLen

    Generally I do not leave comments but this post merits a small note, and a stop at avanscreditipotecar2020 extended that comment worthy quality, the urge to actively contribute to a sites community rather than passively consume from it is something specific content provokes and this site has provoked that engagement urge from me today.

    Reply
  37. kyhni SPb_lzoa

    Народ всем привет Менеджеры врут про материалы То фасады кривые Короче, нашел наконец нормальное производство — заказ кухни с доставкой и сборкой Кромка на немецком оборудовании В общем, вся инфа вот здесь — купить кухню в спб от производителя купить кухню в спб от производителя Не ведитесь на салоны в ТЦ Перешлите тому кто тоже мучается

    Reply

Leave a Reply

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