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

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

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

  1. MiguelKag

    Honestly this hits the sweet spot between detail and brevity, no rambling and no shortcuts, and a quick visit to hupido kept that going across the related pages, the kind of place that respects your attention without trying to grab it through cheap tactics or attention seeking design choices that get tired fast.

    Reply
  2. Diegorhype

    Picked a single sentence from this post to remember, and a look at growwithconfidencenow gave me another to keep, content that produces memorable lines is doing more than just transferring information and the small selection of sentences I keep from each reading session is one of the actual returns I get from reading carefully.

    Reply
  3. Dylandep

    Worth recommending broadly to anyone who reads on the topic, and a look at buildsmartfoundations only confirms that, the rare combination of accessibility and depth in this site makes it suitable for both newcomers and people who already know the area which is hard to pull off in any blog format today and rarely managed.

    Reply
  4. Doriannerge

    Honestly enjoyed reading this more than I expected to when I first clicked through, and a stop at buildactionableprogress kept that pleasant surprise going, sometimes you stumble onto a site that just clicks with how you like to read and this is one of those for me right now today which is great.

    Reply
  5. GeneJon

    Reading this prompted me to clean up some old notes related to the topic, and a stop at seosprout extended that organising urge, content that triggers personal organisation rather than just consuming attention is content with motivating energy and this site has the kind of clarity that prompts active follow up rather than passive consumption.

    Reply
  6. Gavinpoche

    Working through this site has been a small antidote to the shallow content that fills most of my reading time, and a stop at findgrowthdirections 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
  7. ChadTem

    Thanks for putting in the work to make this approachable, plenty of sites cover the same ground but most do it badly, and a quick visit to createprogressframework confirmed this one stands apart, simple language and useful examples without anyone trying to sell me anything along the way which I really appreciated.

    Reply
  8. Laynenah

    Liked how the writer used real examples instead of theoretical ones to make the points stick, and a stop at buildyournextmove added even more concrete examples, this is the kind of practical approach that respects readers who actually want to apply what they learn rather than just nodding along passively without doing anything useful.

    Reply
  9. Daquanmooda

    A well calibrated piece that knew its scope and stayed inside it, and a look at createprogressmapping maintained the same scope discipline, scope creep is one of the failure modes of long blog posts and this site has clearly invested in the editorial discipline to prevent it which shows up in tightly contained pieces.

    Reply
  10. SamShorp

    Took the time to read every paragraph rather than skimming for the punchline, and a quick visit to buildstrategicdirection earned the same careful attention from me, that is the highest signal I can give about content quality because my default mode is rapid scanning rather than deliberate reading on most pages.

    Reply
  11. Alfredcrunk

    Quality work here, the post reads cleanly and the points stay focused throughout, and a stop at findnewopportunityflows kept the standard high, you can tell the writer cares about the final result rather than just hitting publish for the sake of having something new on the page to feed the search engines.

    Reply
  12. TomDyego

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

    Thanks for putting in the work to make this approachable, plenty of sites cover the same ground but most do it badly, and a quick visit to createprogressframework confirmed this one stands apart, simple language and useful examples without anyone trying to sell me anything along the way which I really appreciated.

    Reply
  14. KeenanTug

    Thanks for taking the time to write this, it is clear that some thought went into how each point would land, and after I went through startmovingforward I had a better grip on the topic, real value without the usual marketing noise people have to put up with online when searching for answers.

    Reply
  15. Finntoina

    I really like how the writer keeps the tone friendly without sounding fake or overly polished, and after a stop at surgesorrel the same calm pace was there, no rushing to make a point and no padding either, just clean honest writing that I can respect and come back to later again.

    Reply
  16. DominicAxior

    Once I had read three posts the editorial pattern was clear, and a look at bakeboxshop confirmed the pattern from a fourth angle, sites where the underlying approach reveals itself through accumulated reading rather than being announced are sites with real depth and this one has that quality clearly visible across multiple pieces consistently.

    Reply
  17. Stuartcar

    Reading this confirmed that my time researching the topic in other places had not been wasted, and a stop at discoveropportunityzones extended the confirmation, when independent sources agree that is a useful signal and this site is one of the more reliable sources I have found for cross checking what I read elsewhere on similar subjects.

    Reply
  18. Jettbab

    Bookmark added in three places to make sure I do not lose the link, and a look at createyourstorytoday got the same redundant treatment, sites I am afraid to lose are the rare keepers and this is clearly one of them based on what I have read so far across this and a couple of related posts.

    Reply
  19. DannyRor

    Started reading expecting to disagree and ended mostly nodding along, and a look at findgrowthopportunitiesnow 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
  20. HugoSNINA

    Felt the post had been written without looking over its shoulder, and a look at findbetterapproaches continued that confident posture, content written for its own sake rather than against imagined critics has a different quality and this site reads as written from a place of confidence rather than defensive justification of every claim.

    Reply
  21. RonBic

    Looking at this objectively the editorial quality is hard to deny even setting aside personal taste, and a stop at learnandrefine maintained the same objective quality, the gap between what I personally enjoy and what is objectively well crafted exists and this site clears both bars simultaneously which is rarer than it sounds.

    Reply
  22. Jaymit

    Reading this on a phone at a coffee shop and finding it perfectly suited to that context, and a stop at startnextphase continued the comfortable mobile experience, content that works across reading conditions without compromising on substance is increasingly important and this site has clearly thought about the whole reader experience here.

    Reply
  23. KeenanTug

    A memorable post for me on a topic I had thought I was tired of, and a look at startmovingforward suggested the same site can refresh other tired topics, sites that can revive my interest in subjects I had written off as exhausted are doing rare work and this one is clearly doing that for me today.

    Reply
  24. Adamwen

    Appreciate the work that went into laying this out so clearly, every section earns its place without filler, and a look at createvisionforward confirmed the same care, definitely the kind of place that deserves a return visit when the topic comes up again later in the future or for any related question.

    Reply
  25. Boyddap

    Speaking as someone who used to recommend blogs frequently and got out of the habit this site is rekindling that impulse, and a look at siloteapot extended the rekindling, the recovery of an old habit triggered by encountering work that justifies it is itself a small kind of pleasure and this site is providing that recovery experience.

    Reply
  26. Franciscodup

    If you scroll past this site without looking carefully you will miss something, and a stop at inobrat extended that mild warning, the surface of the site does not advertise its quality loudly which means careful attention is required to recognise what is being offered here which is itself a kind of editorial signal.

    Reply
  27. Milesbum

    Now adjusting my expectations upward for the topic based on this post, and a stop at startwithpurposefulsteps continued that bar raising effect, content that resets what I think is possible on a subject is doing real work in shaping my standards and this site is providing those bar raising experiences at a notable rate during sessions.

    Reply
  28. Doriannerge

    Honestly enjoyed reading this more than I expected to when I first clicked through, and a stop at buildactionableprogress kept that pleasant surprise going, sometimes you stumble onto a site that just clicks with how you like to read and this is one of those for me right now today which is great.

    Reply
  29. Gavinpoche

    I usually skim posts like these but this one held my attention all the way through, and a stop at findgrowthdirections did the same, that is a strong endorsement coming from me because I am usually quick to bounce when content gets repetitive or fails to deliver on its initial promise made in the headline.

    Reply
  30. DominicAxior

    Honest assessment is that this is one of the better short reads I have had this week, and a look at bakeboxshop reinforced that, the bar for short content is low because most of it sacrifices substance for brevity but this site manages both at once which is harder than it sounds for most writers attempting it.

    Reply
  31. Stuartcar

    Looking back on this reading session it stands as one of the better ones recently, and a look at discoveropportunityzones extended that ranking, the informal ranking of reading sessions against each other is something I do mentally and this session ranks high largely because of this site and a couple of related pages here.

    Reply
  32. Jettbab

    Reading this gave me material for a conversation I needed to have anyway, and a stop at createyourstorytoday 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
  33. ReedHok

    Closed it feeling I had taken something away rather than just consumed something, and a stop at learnandadvancefaster extended that taking away feeling, the difference between content I extract value from and content I just pass through is something I track informally and this site is consistently in the value extraction column for me.

    Reply
  34. HugoSNINA

    Reading this in three sittings because the day was fragmented, and the piece survived the fragmentation, and a stop at findbetterapproaches held up under similar reading conditions, content engineered for continuous attention is fragile in modern conditions and this site reads as durable across the realistic ways people consume content today.

    Reply
  35. DannyRor

    Came back to this twice now in the same week which is unusual for me, and a look at findgrowthopportunitiesnow suggested I will keep coming back, the kind of post that earns repeated visits rather than one and done reading is the gold standard for content quality and this site clearly hit that standard.

    Reply
  36. Willishet

    Came away with a slightly better mental model of the topic than I started with, and a stop at buildforwardthinking sharpened that further, content that improves the reader thinking apparatus rather than just dumping facts into it is the rare kind I genuinely value and seek out when I have time to read carefully.

    Reply
  37. Daquanmooda

    A particular pleasure to read this with a fresh coffee, and a look at createprogressmapping extended the pleasure across more pages, content that pairs well with quiet morning rituals is something I have come to value highly and this site has the kind of energy that fits naturally into a calm reading routine.

    Reply

Leave a Reply

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