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

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

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

  1. KendallNup

    Now setting this aside as a model of how to write thoughtfully on the topic, and a stop at cloverhedge extended that model status, content that becomes a reference for how a kind of writing should be done is content with influence beyond its own readership and this site is reaching that level for me clearly today.

    Reply
  2. TannerUndot

    Now considering the post as evidence that careful blog writing is still possible, and a look at elderchimney extended that evidence, the broader question of whether the modern web can sustain quality writing has obvious empirical answers in sites like this one and seeing them is reassuring even when they remain a minority overall today.

    Reply
  3. DanThori

    A satisfying piece in the way that good meals are satisfying rather than just filling, and a look at claritylane extended that satisfaction, the metaphor between content and meals is one I find useful and this site reads as a satisfying meal rather than the empty calories that most content provides for casual readers.

    Reply
  4. Elirep

    Working through this site has been a small antidote to the shallow content that fills most of my reading time, and a stop at actionbuildsresults extended that antidote function, sites that quietly improve the average quality of my reading by being themselves are sites worth supporting through return visits and recommendations consistently.

    Reply
  5. Fideljep

    Will be coming back to this for sure, too much good content to absorb in one sitting, and a stop at progressnavigation only added more pages I want to dig through, this site is going onto my regular rotation list because it consistently delivers something worth the visit lately rather than empty filler.

    Reply
  6. AbrahamSof

    Different feel from the algorithmically optimised posts that dominate the topic, and a stop at ideaforward reinforced that human touch, you can tell when a site is being run by someone who reads what they publish versus someone just hitting submit and moving on quickly to the next assignment without checking the result.

    Reply
  7. Ammonfoors

    Looking through the archives suggests this site has been doing this for a while at this level, and a look at focusnavigator confirmed the long term consistency, sites that have maintained quality across years rather than just a recent stretch are sites with serious editorial discipline and this one has clearly been at it for a while.

    Reply
  8. TrentonNop

    Thanks for putting this online without locking it behind email signups or paywalls, and a quick visit to borealberyl kept that open feel going, content that trusts the reader to come back rather than gating access is the kind of approach I will reward with regular return visits over time happily.

    Reply
  9. MartinLix

    Reading this prompted me to send the link to two different people for two different reasons, and a stop at quartzmeadowmarketgallery provided ammunition for a third share, content that suits multiple audiences without being generic enough to be useless to any of them is genuinely valuable and this site has that multi audience quality clearly.

    Reply
  10. Santiagopaw

    Now setting aside time on my next free afternoon to read more from the archives, and a stop at ideaelevation confirmed that time will be well spent, the rare site whose archive deserves a dedicated reading session rather than just casual sampling is the kind of resource worth scheduling around and this one qualifies clearly.

    Reply
  11. Tedcox

    Liked the careful selection of which details to include and which to skip, and a stop at claritysystem 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
  12. WesleyElulp

    A slim post with substantial content per word, and a look at forwardthinkingworks 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
  13. TerranceChite

    Reading this in segments because the day was busy, and the post survived the fragmented attention well, and a stop at focuspathway held up similarly under interrupted reading, content that can withstand modern distracted reading patterns rather than requiring a perfect block of focused time is increasingly the kind I prefer.

    Reply
  14. 1xbet indir_bcsl

    Mobil bahis uygulaması arıyordum uzun süredir. Play Store’da resmi olanı bulamayınca çok şaşırdım. Adımları doğru sırayla uyguladıktan sonra erişim sorunsuz açıldı. En sonunda sağlam bir kaynağa ulaştım ve size de tüm detayları aktarmak istedim, güncel bilgilere buradan bakabilirsiniz: 1xbet türkiye indir 1xbet türkiye indir. Valla bak net söyleyeyim — son sürümü bütün eksikleri kapatmış resmen.

    Hiçbir sıkıntı yaşamadım indirme aşamasında. İşin doğrusunu söylemek gerekirse — başka yerde vakit kaybetmeyin yani. Herkese hayırlı olsun…

    Reply
  15. 1xbet indir_lasl

    Mobil bahis uygulaması arıyordum uzun süredir. Play Store’da resmi olanı bulamayınca çok şaşırdım. Adımları doğru sırayla uyguladıktan sonra erişim sorunsuz açıldı. En sonunda sağlam bir kaynağa ulaştım ve size de tüm detayları aktarmak istedim, güncel bilgilere buradan bakabilirsiniz: 1xbet türkiye indir 1xbet türkiye indir. Yani anlatmak istediğim şu — son sürümü bütün eksikleri kapatmış resmen.

    kurulumu da oldukça kolaydı yani rahat olun. Birçok platform denedim ama en iyisi bu çıktı — en kullanışlı uygulama bu oldu artık. Şimdiden iyi şanslar ve bol kazançlar…

    Reply
  16. DanThori

    Bookmark earned and folder updated to track this site separately, and a look at claritylane 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
  17. TannerUndot

    If I were to recommend a starting point for the topic this site would be near the top of my list, and a stop at elderchimney reinforced that recommendation status, the small list of starting point recommendations I keep for friends asking about topics is short and this site is now firmly on it.

    Reply
  18. KendallNup

    Clean writing, easy to read, and never tries too hard to impress, that combination is harder to find than people think, and after my time on cloverhedge I am sure this site treats its readers well, no flashy tricks just useful content done right which is honestly all I want online.

    Reply
  19. GregoryDuent

    Thanks for the practical examples scattered through the post rather than abstract theory only, and a look at momentumexecution continued that grounded style, abstract points are easier to remember when paired with concrete situations and the writers here clearly understand how readers actually retain information from blog content reading sessions.

    Reply
  20. BillGlymn

    Glad the writer did not feel compelled to cover every possible angle of the topic, focus is a virtue, and a stop at loungeload reflected the same disciplined scope, knowing what to leave out is half of what makes good writing good and this post has clearly been edited with that principle in mind.

    Reply
  21. JacksonSuddy

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

    A genuine compliment to the writer for keeping the post focused on what mattered, and a look at borealberyl continued that disciplined focus, focus is a editorial choice that compounds across many small decisions and this site has clearly made those small decisions consistently across what I have read so far this week here.

    Reply
  23. Tristanunolf

    Now planning to come back when I have the right kind of attention to read carefully, and a stop at pearlcovemarketgallery reinforced that plan, choosing the right moment to read certain content is a quiet form of respect for the work and this site is generating those careful planning behaviours from me consistently as a reader.

    Reply
  24. Tedcox

    Thank you for keeping the writing honest and the points easy to verify against your own experience, and a stop at claritysystem reflected the same approach, no exaggeration just steady useful content that I can take with me into my own work without second guessing every sentence I happen to read here.

    Reply
  25. WesleyElulp

    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 forwardthinkingworks 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
  26. Borisbiazy

    Appreciate the practical examples, they made the abstract points easier to grasp, and a stop at actiondrivenclarity 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
  27. TerranceChite

    Better than most of the writing I have come across on this topic recently, simpler and more direct, and a look at focuspathway 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
  28. Juanvef

    Genuine reaction is that I will probably think about this on and off for a few days, and a look at forwardthinkinghub added fuel to that, the best content lingers in your head after you close the tab rather than evaporating immediately and this site clearly knows how to write that kind of memorable content.

    Reply
  29. BillGlymn

    Thanks again for the post, I learned a couple of things I can actually use later this week, and after I went over loungeload the rest of the site looked equally promising, definitely going to spend more time here when I get a free moment over the weekend to read more carefully.

    Reply
  30. Chrisbig

    Bookmark earned, share earned, return visit earned, all from one reading session, and a look at growthsystem did the same, the trifecta of bookmark and share and return is rare in a single visit and represents the highest level of engagement I tend to offer any piece of online content these days here.

    Reply
  31. Walterswert

    A slim post with substantial content per word, and a look at focusdesign 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
  32. GregBut

    Useful reading material, the kind I can hand off to someone newer to the topic without worrying about confusing them, and a quick look at rivercovevendorroom confirmed the same beginner friendly tone runs throughout the site which is great for sharing with people just starting their learning journey on this particular topic.

    Reply
  33. RiverRig

    Worth recognising the absence of the usual blog tropes here, and a look at flintanchor continued that fresh quality, sites that avoid the standard moves of the medium read as more original even when the content is on familiar topics and this one has clearly chosen its own path through the conventional terrain skilfully.

    Reply

Leave a Reply

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