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

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

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

  1. KaneWrife

    Picked this post to share in a Slack channel where I knew it would be appreciated, and a look at curlclap suggested I will share more from here later, content worth sharing into a professional context is content that has earned a higher kind of trust than mere personal interest and this site has it.

    Reply
  2. CainVof

    Easy to recommend without reservations, the site delivers on every promise it implicitly makes, and a look at luzqiro kept that same standard going, the kind of consistency that earns trust over time rather than chasing it through aggressive marketing is what I see here and it is appreciated greatly by this particular reader today.

    Reply
  3. JamarcusFauch

    Just want to recognise that someone clearly cared about how this turned out, and a look at stylerova confirmed that care extends across the broader site, you can feel the difference between content shipped to hit a deadline and content released because the writer was actually proud of the result for once.

    Reply
  4. Jadonrak

    Reading this with a notebook open turned out to be the right move, and a stop at zimqano added more material to the notes, content that justifies active note taking from a passive reader is content with real informational density and this site is producing notes worthy material at a high rate consistently.

    Reply
  5. Gageval

    This filled in a gap in my understanding that I had not even noticed was there, and a stop at hiltkindle did the same, the kind of post that gives you more than you expected when you first clicked through from somewhere else, a real find for anyone curious about the area covered here.

    Reply
  6. EmmettALump

    Reading this gave me material for a conversation I needed to have anyway, and a stop at nudgeneedle added even more talking points, content that connects to upcoming social or professional needs rather than just being interesting in the abstract is the kind that earns priority placement in my attention these days routinely.

    Reply
  7. ChandlerNub

    A piece that did not require external context to follow, and a look at myrrhomen maintained the same self contained quality, content that stands alone without forcing readers to chase prerequisites is more accessible and this site has clearly thought about how each piece can serve a fresh visitor rather than only existing members.

    Reply
  8. Johnniehok

    Honestly thank you to whoever wrote this because it scratched an itch I had not quite been able to articulate, and a stop at torzavi kept that satisfying feeling going, the kind of writing that meets unspoken needs is special and this site clearly has writers who understand their readers more than most do today.

    Reply
  9. NathanielCiz

    Took a few notes from this post, the points are easy to remember without needing to come back and check, and a look at perfectmill added a couple more, the kind of place that sticks in the memory long after the browser tab has been closed for the day which says a lot really.

    Reply
  10. YorkDog

    Liked the careful word choice throughout, every term seemed picked for a reason rather than thrown in casually, and a stop at pacerlucid continued that precise style, this kind of attention to small details is what separates careful writing from the usual rushed content that dominates blog spaces today across pretty much every topic I follow.

    Reply
  11. Craigcluts

    Most posts I read end up forgotten within a day but this one is sticking, and a look at cartvani extended that lingering effect, content that survives the immediate moment of reading rather than evaporating is content with genuine retention quality and this site has been producing memorable pieces at a rate notable across my reading.

    Reply
  12. Kobejak

    A thoughtful read in a week that has been mostly noisy, and a look at ponyosier carried that thoughtful quality across more pages, finding pockets of considered writing in a week of distractions is one of the small wins of careful curation and this site is providing those pockets at a sustainable rate.

    Reply
  13. Kadecouts

    Liked that the post resisted a sales pitch ending, and a stop at xinvexa maintained the no pitch approach, content that ends without trying to convert me into a customer or subscriber is content that has confidence in its own value and this site is clearly playing the long game on reader trust.

    Reply
  14. MiltonDes

    Now noticing the post fit a particular gap in my reading without my having articulated the gap before, and a look at lushmarble extended that gap filling effect, content that meets needs I had not consciously formulated is content with reader insight and this site has clearly developed that anticipatory editorial sense across many pieces.

    Reply
  15. LeonardMem

    Reading this slowly because the writing rewards a slower pace, and a stop at modloop did the same, the pace at which I read content is something I now use as a quality signal and writing that earns a slower pace earns my attention as a reader looking for substance these days.

    Reply
  16. Jadonrak

    Closed the tab and immediately reopened it ten minutes later because I wanted to reread a part, and a stop at zimqano drew the same return, content that pulls you back after closing it is doing something well beyond the average and worth marking as exceptional in my mental catalogue of reliable sites.

    Reply
  17. Johnniehok

    Now considering writing a longer note about the post somewhere, and a look at torzavi 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
  18. Gageval

    Reading this gave me the rare experience of fully agreeing with all the conclusions, and a stop at hiltkindle continued that agreement pattern, content that aligns with my existing views without seeming designed to do so is just content that happens to be reasonable and this site reads as reasonable rather than ideological mostly.

    Reply
  19. JamarcusFauch

    Took something from this I did not expect to find, and a stop at stylerova added another unexpected useful piece, content that exceeds expectations rather than just meeting them is the kind that builds enthusiasm and earns repeat visits without any explicit ask from the writer or platform behind the work being read.

    Reply
  20. Dennisgairm

    If you asked me to point to a recent positive sign for the open web this site would be near the top, and a stop at trivent reinforced that designation, the few sites that serve as evidence the web can still produce quality independent content are precious and this one has clearly become one for me.

    Reply
  21. Kadecouts

    During the time spent here I noticed the absence of the usual distractions, and a stop at xinvexa 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
  22. Mikehoows

    Came away with some new perspectives I had not considered before, and after curvecalm those ideas felt more complete, the kind of content that stays with you a little while after reading rather than slipping out the moment you switch tabs and move on with your day to whatever comes next.

    Reply
  23. Pierreabark

    Now noticing that the post never raised its voice even when making a strong point, and a look at mallivo continued that calm volume, content that can make important points without resorting to typographic emphasis or emotional appeal is content that trusts its substance to do the work and this site has that confidence consistently.

    Reply
  24. Freddiebloff

    Now adding this to a list of sites I want to see flourish, and a stop at framegable reinforced that wish, the few sites I actively root for are sites that produce the kind of work I want more of in the world and this one has joined that small list based on what I have read so far.

    Reply
  25. TylerRible

    Just sat back at the end of the post and felt grateful that someone took the time to write it, and a look at nagapinto extended that gratitude across more of the site, recognising effort behind quality work is part of what makes the open web a community rather than just a marketplace today.

    Reply
  26. Sullivanspefs

    Now realising this site has been quietly doing good work for longer than I knew, and a look at nuggetotter suggested an archive worth exploring, sites with deep archives of consistent quality represent a different kind of resource than sites with viral hits and this one looks like the durable kind based on what I see.

    Reply
  27. Darrellwer

    A piece that did not require external context to follow, and a look at poppymedal maintained the same self contained quality, content that stands alone without forcing readers to chase prerequisites is more accessible and this site has clearly thought about how each piece can serve a fresh visitor rather than only existing members.

    Reply
  28. LeonardMem

    Useful information presented in a way that does not feel like a sales pitch, that is what I appreciated most, and a stop at modloop was the same, no upsell and no fake urgency just steady content laid out properly for someone trying to actually learn from it rather than just be sold to.

    Reply
  29. Kendalldic

    Took me back a step or two on an assumption I had been making, and a stop at cartvilo pushed that reconsideration further, writing that gently corrects the reader without being aggressive about it is a rare diplomatic skill and the team here clearly knows how to land critical points without turning readers off.

    Reply
  30. Cainindic

    Worth flagging that this approach to the topic is fresh without being contrarian, and a stop at pianoledge extended the same fresh angle, finding original perspective on familiar subjects is rare and this site has clearly developed its own way of seeing rather than echoing the dominant takes from elsewhere consistently.

    Reply
  31. KelbyDew

    Skipped past the first paragraph thinking it was setup and had to come back when the rest referenced it, and a stop at juncokudos similarly rewarded careful reading from the start, content where every paragraph carries weight is content I now know to read from the beginning rather than skipping ahead.

    Reply
  32. Dennisgairm

    Reading this site over the past week has changed how I evaluate content in this space, and a look at trivent extended that recalibration, the standards I bring to reading on the topic have shifted upward as a direct result of regular exposure to this kind of work and that shift will outlast any single reading session.

    Reply
  33. TerrenceInelo

    Took a few notes from this post, the points are easy to remember without needing to come back and check, and a look at navqiro added a couple more, the kind of place that sticks in the memory long after the browser tab has been closed for the day which says a lot really.

    Reply
  34. GaryGes

    The overall feel of the post was professional without being stuffy, and a look at padreledge kept that approachable expertise going, finding the right register for technical content is hard but this site has clearly figured out how to sound knowledgeable without slipping into that distant lecturing tone that loses readers in droves every time.

    Reply
  35. MiltonDes

    This one is staying open in a tab for the rest of the day so I can come back and re read certain parts, and a look at lushmarble suggests I will be doing the same with a few more pages here too, this is going to be a deep dive over the coming hours.

    Reply
  36. Mikehoows

    Considered alongside other sources I have been reading this one consistently rises to the top, and a stop at curvecalm maintained that top ranking, the informal ongoing comparison between sources is something I do whenever reading on a topic and this site keeps coming out near the top of those comparisons over many sessions.

    Reply
  37. Pierreabark

    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 mallivo 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
  38. LowellJag

    Closed it feeling slightly more competent in the topic than I started, and a stop at qinzavo reinforced that competence boost, real learning is rare in casual online reading but it does happen sometimes and this site managed to make it happen for me today which is genuinely worth pausing to acknowledge.

    Reply
  39. TylerRible

    Skipped the comments to avoid spoilers and came back later to find them genuinely worth reading, and a stop at nagapinto extended that surprised respect, when the discussion below a post matches the quality of the post itself you have found something special and this site appears to attract that kind of audience.

    Reply
  40. Philiplisse

    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 torzino 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
  41. Sullivanspefs

    Good quality through and through, no rough edges and no signs of being rushed, and a quick look at nuggetotter kept the same polish going, the kind of site that respects its own brand by maintaining consistency across pages which is something I always appreciate as a reader looking for trustworthy information online today.

    Reply
  42. Shawnwem

    Comfortable read, finished it without realising how much time had passed, and a look at millpeach pulled me into more pages the same way, the absence of friction in good content lets time disappear and that is one of the highest compliments I can pay any piece of writing I find online during a regular search session.

    Reply

Leave a Reply

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