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

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

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

  1. SaulEpify

    A piece that reads as if the writer trusted readers to fill in obvious gaps, and a look at findclaritynow 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
  2. Jettres

    Started imagining how I would explain the topic to someone else after reading, and a look at explorecreativefreedom gave me more material for that imagined explanation, content that improves my own ability to discuss a topic is content that has actually transferred knowledge rather than just decorating my screen for a few minutes.

    Reply
  3. BartholomewGek

    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 violavenom 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
  4. JackGit

    Started reading without much expectation and ended on a high note, and a look at sequoiasnare continued that arc, content that builds rather than peaks early is a sign of a writer who knows how to structure a piece for sustained reader engagement rather than relying on a strong hook to do all the work.

    Reply
  5. JaylenNut

    My friends would appreciate a few of these posts and I will be sending links accordingly, and a look at maplecresttradingcorner added more pages to my share queue, content that earns shares to specific people in specific contexts is content with social utility and this site is generating those targeted shares from me consistently lately.

    Reply
  6. Felixsnova

    Worth a slow read rather than the fast scan I usually default to, and a look at oxaboon earned the same slower pace from me, content that resets my reading speed downward is content with substance worth absorbing and this site has produced that effect on me multiple times now over the last week here.

    Reply
  7. EdwardBob

    Speaking from the perspective of a fairly demanding reader the writing here clears the bar consistently, and a look at stitchtwine continued clearing that bar, the calibration of demanding reader is something I apply to all sources and this site has been one of the few that handles the demanding reading well across pieces sampled.

    Reply
  8. JorgeNof

    A memorable post for me on a topic I had thought I was tired of, and a look at hugtix 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
  9. Edmundskina

    Quietly the post solved something I had been turning over without quite knowing how to phrase the question, and a look at oldenmaple extended that quiet solving, content that addresses unformulated needs is content with reader insight and this site has demonstrated that insight at a high rate across the pieces I have read recently.

    Reply
  10. JadonPouff

    Found something new in here that I had not seen explained this way before, and a quick stop at superbtundra expanded the idea even further, the kind of writing that nudges your thinking forward a bit without forcing the issue is exactly what I look for online today and rarely actually find anywhere.

    Reply
  11. BartholomewGek

    Really appreciate that the writer did not assume I would read every other related post first, and a look at violavenom kept that self contained feel going where each piece can stand alone, accessibility for new readers is a sign of generous editorial thinking and this site has clearly invested in that approach.

    Reply
  12. TimothyVab

    A piece that handled the topic with appropriate weight without becoming portentous, and a look at goshfrost continued that calibrated seriousness, content that takes itself seriously without becoming pompous is something this site has clearly figured out and the balance shows up in every piece I have read across multiple sessions now.

    Reply
  13. ErickMus

    Taking the time to read carefully here has been worthwhile for the past hour, and a look at startmovingahead 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
  14. Jettres

    Worth pointing out the careful word choice in this post, no buzzwords and no jargon, and a look at explorecreativefreedom continued that disciplined vocabulary, sites that resist the pull of trendy language are sites that will read well in five years and this one is clearly built for that kind of long durability.

    Reply
  15. LandonTromy

    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 stereoskein 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
  16. DarrenAntet

    Reading the writers other posts after this one suggests the quality is consistent rather than peak, and a stop at isebrook confirmed the consistent quality reading, sites that hold the same level across many pieces rather than peaking on a few are sites with sustainable editorial discipline and this one has clearly developed that.

    Reply
  17. Stefanfof

    Just sat with this for a bit longer than I usually would because the points are worth thinking about, and after skiffvantage I had even more to chew on, the kind of post that nudges your thinking forward without forcing the issue is something I have always appreciated in good writing online.

    Reply
  18. JackGit

    Reading this post made me realise I had been settling for lower quality elsewhere, and a look at sequoiasnare extended that recalibration, content that exposes how much I had been accepting in adjacent sources is content with calibrating effect on my standards and this site is performing that calibration function across topics for me reliably.

    Reply
  19. BjornNet

    Picked this for my morning read because the topic seemed worth the time, and a look at findyourinspirationnow 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
  20. RossArody

    Loved the writing voice here, friendly without being fake and confident without being arrogant, and a stop at trebleupper carried the same tone forward, the kind of personality that makes a reader feel welcome rather than lectured at which is a balance plenty of writers struggle to find no matter how long they have been at it.

    Reply
  21. JaylenNut

    Reading this on a long flight and finding it the best thing I read across hours of trying, and a stop at maplecresttradingcorner kept the streak going, when content beats long flight reading you know it has substance because flight reading is a hard test of a piece given the alternatives available everywhere.

    Reply
  22. Paxtonfet

    A piece that handled multiple complications without becoming confused, and a look at gribump 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
  23. Emanuelstody

    Honestly the simplicity is what makes this work, the topic is not buried under filler words or overly complex examples, and a quick look at connectgrowthrive showed the same sensible style, I left with what I came for and no headache from over reading which is a real win these days.

    Reply
  24. SullivanUnodo

    Came in for one specific question and got answers to three I had not even thought to ask, and a look at jamsyx extended that bonus value pattern, the kind of resource that anticipates reader needs rather than just answering the literal question asked is the gold standard and this site reaches it.

    Reply
  25. Edmundskina

    Reading this gave me a small framework I expect to use going forward, and a stop at oldenmaple extended that framework, content that produces transferable mental models rather than just specific facts is content with multiplicative value and this site is providing those models at a rate that justifies extra attention from me regularly.

    Reply
  26. ErickMus

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

    Reading this gave me a small framework I expect to use going forward, and a stop at tildeserene extended that framework, content that produces transferable mental models rather than just specific facts is content with multiplicative value and this site is providing those models at a rate that justifies extra attention from me regularly.

    Reply
  28. TimothyVab

    A piece that read as the work of someone who reads carefully themselves, and a look at goshfrost continued that informed feel, writers who are also serious readers produce work with a different quality and this site reads as the product of someone steeped in good writing rather than just generating content for an audience.

    Reply
  29. Stefanfof

    Easily one of the better explanations I have read on the topic, and a stop at skiffvantage pushed it even higher in my mental ranking of useful resources, the kind of site that beats the average not by trying harder but by simply caring more about what it puts out daily which always shows.

    Reply
  30. Grahamovent

    Reading this slowly to give it the attention it deserved, and a stop at hekarc 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
  31. Ammonles

    Reading this in three sittings because the day was fragmented, and the piece survived the fragmentation, and a stop at tracesinger 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
  32. LandonTromy

    Took the time to read the comments on this post too and they were also worth reading, and a stop at stereoskein suggested the community quality matches the content quality, when the conversation around a piece is as good as the piece itself you know you have found a real corner of the internet.

    Reply
  33. Pablomum

    Now recognising that the post handled the topic with appropriate technical precision without becoming dry, and a stop at pyxedge 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
  34. JorgeNof

    Useful read, especially because the writer did not assume too much background from the reader, and a quick look at hugtix continued in the same way, a thoughtful site that meets people where they are which is something the modern web could use a lot more of for both casual and serious readers.

    Reply
  35. RossArody

    Took my time with this rather than rushing because the writing rewards attention, and after trebleupper I had even more to absorb, the kind of content that pays back the patient reader rather than punishing them with empty filler is something I look for and rarely find in regular searches lately.

    Reply
  36. Paxtonfet

    If I were grading sites on this topic this one would receive high marks, and a stop at gribump continued earning those high marks, the informal grading I do mentally for content sources is something I take seriously even though it is informal and this site has been receiving consistent high marks across multiple sessions today.

    Reply
  37. DarrenAntet

    Reading the writers other posts after this one suggests the quality is consistent rather than peak, and a stop at isebrook confirmed the consistent quality reading, sites that hold the same level across many pieces rather than peaking on a few are sites with sustainable editorial discipline and this one has clearly developed that.

    Reply
  38. ShermanVef

    Now planning to come back when I have the right kind of attention to read carefully, and a stop at cobqix 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
  39. BjornNet

    Got something practical out of this that I can apply later this week, and a stop at findyourinspirationnow added more details to think about, this is exactly the kind of content I bookmark for future reference rather than the throwaway listicles that dominate most search results these days for almost any common topic.

    Reply
  40. FrederickJak

    Found a small mental shift after reading this, the framing here is just a bit different from the standard takes online, and a look at vinylvessel extended that fresh perspective across more material, the rare site whose voice actually changes how you think about something rather than just confirming existing beliefs.

    Reply
  41. SullivanJaife

    Really like that the writer trusts the reader to follow simple logic without restating every previous point, and a stop at trumpetsash kept that respect going, treating an audience as capable adults rather than as people who need constant hand holding makes a noticeable difference in the reading experience for me.

    Reply
  42. Terrancedep

    Came here from another site and ended up exploring much further than I planned, and a look at findyournextmove only encouraged more exploration, the kind of place where one click leads to another not through manipulative design but through genuinely interesting content is rare and worth highlighting when found like this somewhere on the open internet.

    Reply
  43. Ammonles

    Over the course of reading several posts here a pattern of quality has emerged, and a stop at tracesinger confirmed the pattern, the difference between sites that hit quality occasionally and sites that hit it consistently is huge and this site has clearly demonstrated the consistent kind through what I have read this morning.

    Reply
  44. Emanuelstody

    Will be sharing this with a couple of people who care about the topic, and a stop at connectgrowthrive added more material worth passing along, the kind of site that is generous with quality content and does not make you jump through hoops to access it which is appreciated more than the team probably realises.

    Reply
  45. Pablomum

    Just wanted to say this was useful and leave a small note of thanks, and a quick visit to pyxedge earned a similar nod from me, the small acknowledgements add up over time and represent the real economy of trust that good content runs on across the open and increasingly fragmented modern internet.

    Reply

Leave a Reply

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