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

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

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

  1. Edwardrix

    Picked a single sentence from this post to remember, and a look at siskatriton 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
  2. Petegurce

    However measured this site clears the bar I set for sites I take seriously, and a stop at stencilslick continued clearing that bar, the metrics I use for site quality are admittedly informal but they are consistent and this site has cleared them on multiple measurements across multiple visits which is meaningful for my evaluation.

    Reply
  3. Daxicolo

    Just sat back at the end of the post and felt grateful that someone took the time to write it, and a look at triggersyrup 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
  4. Pedrofar

    Thank you for being clear and direct, that simple approach saves so much frustration on the reader’s end, and a stop at zunvoro only made me more sure of it, the rest of the content seems to follow the same pattern which is a great sign of consistent editorial care behind the scenes.

    Reply
  5. SantiagoADent

    Came in for one specific question and got answers to three I had not even thought to ask, and a look at createactionsteps 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
  6. Malcolmcrify

    Just want to recognise that someone clearly cared about how this turned out, and a look at gooseholm 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
  7. CoreyOweme

    Honest assessment is that this is one of the better short reads I have had this week, and a look at tasselskein 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
  8. DaquanZisee

    Really thankful for posts that respect a reader’s time, this one does, and a quick look at vortexvandal was the same, no need to scroll through endless intros just to get to the actual content, that approach alone is enough reason to come back here regularly for the kind of writing offered.

    Reply
  9. GunnerDaL

    Got pulled in by the headline and stayed because the content actually delivered on the promise, and a stop at glybrow kept that trust intact, when a site lives up to its own framing it earns the right to keep showing up in my browser tabs going forward indefinitely from here on out really.

    Reply
  10. Dwaynetig

    Really appreciate that the writer did not assume I would read every other related post first, and a look at inobrisk 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
  11. HoldenSlalm

    Thanks for treating the topic with the seriousness it deserves without becoming pompous about it, and a stop at cepbell continued that balanced treatment, the gap between earnest and self serious is huge and writers who can stay on the right side of it earn my respect when I find them online today.

    Reply
  12. GlenkeymN

    Now realising the post solved a small problem I had been carrying for weeks, and a look at starchserene extended that problem solving function, content that connects to specific unresolved questions in my own life rather than just providing general interest is content with real practical impact and this site is providing that practical value.

    Reply
  13. RaymondSligE

    Honestly enjoyed every minute spent here, that is not something I say lightly, and a look at tasseltract confirmed I will be back, the bar for spending time online is high for me these days but this site clears it without effort which is high praise indeed from this reader who is usually rather demanding.

    Reply
  14. Sonnyceact

    Skipped the related products section because there was none, and a stop at peltpetal also lacked any aggressive monetisation, content that is not constantly trying to convert me into a customer or subscriber is content that has confidence in its own value and that confidence shows up as a different reading experience.

    Reply
  15. MaxwellChura

    Worth pointing out that the writer made the topic feel more interesting than I had been expecting, and a look at jamkeg continued that elevation effect, content that improves the apparent quality of its subject through skilled treatment is doing something real and this site has clearly developed that kind of editorial alchemy throughout.

    Reply
  16. Petegurce

    Now placing this in the small category of sites whose updates I would actually want to know about, and a stop at stencilslick confirmed that placement, the difference between sites I want to follow and sites I just consume from is real and this one has crossed into the active follow category from the casual consumption side.

    Reply
  17. SantiagoADent

    Reading this confirmed a small detail I had been uncertain about, and a stop at createactionsteps provided the source for further checking, content that supports verification through citations or links rather than just asserting facts is more trustworthy and this site has clearly built its credibility through that kind of verifiable approach consistently.

    Reply
  18. Edwardrix

    Loved the writing voice here, friendly without being fake and confident without being arrogant, and a stop at siskatriton 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
  19. EddieNancy

    Definitely a recommend from me, anyone curious about the topic should check this out, and a look at sheentabby adds even more reason for that, the depth and quality combine to make this site one I will be pointing people toward whenever similar conversations come up over the months ahead at work or socially.

    Reply
  20. Malcolmcrify

    Came in skeptical and left mostly convinced, that is the highest praise I can offer, and a look at gooseholm pushed me further in the same direction, content that survives a critical first read is rare and worth recognising because most blog posts crumble under any real scrutiny these days when you actually pay attention closely.

    Reply
  21. EdwinSiz

    Quietly enthusiastic about this site after the past few hours of reading, and a stop at vocabtrifle extended that enthusiasm, the calibration of enthusiasm to evidence is something I try to maintain and this site has earned a calibrated quiet enthusiasm rather than the loud excitement that usually fades within a day or two of finding something.

    Reply
  22. HoldenSlalm

    Just sat back at the end of the post and felt grateful that someone took the time to write it, and a look at cepbell 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
  23. Carmelolon

    Decided this was the kind of site I would defend in a discussion about good blog content, and a stop at hubbeat reinforced that, very few sites earn active defence rather than passive consumption and this one has clearly crossed that threshold for me without needing any explicit pitch from the writers themselves either.

    Reply
  24. GlenkeymN

    Skipped the related products section because there was none, and a stop at starchserene also lacked any aggressive monetisation, content that is not constantly trying to convert me into a customer or subscriber is content that has confidence in its own value and that confidence shows up as a different reading experience.

    Reply
  25. RaymondSligE

    Will recommend this to a couple of friends who have been asking about this exact topic, and after tasseltract I have even more reason to do so, the kind of site that earns word of mouth rather than chasing it through aggressive marketing or paid placements is always a treat to find online.

    Reply
  26. Marshallacure

    A thoughtful piece that did not strain to be thoughtful, and a look at tasseltrace continued that effortless quality, when thinking shows up in writing without the writer drawing attention to it you know you are reading something genuinely considered rather than something performing the appearance of consideration which is also common online.

    Reply
  27. ChaseAmisA

    A thoughtful read in a week that has been mostly noisy, and a look at vividbolt 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
  28. MiguelPoilt

    Reading this confirmed something I had been suspecting about the topic, and a look at hazmug pushed that confirmation toward greater confidence, content that lines up with independently held intuitions earns a special kind of trust and I will return to writers who consistently land that way for me without overselling positions.

    Reply
  29. Stevefet

    However many similar pages I have read this one taught me something new, and a stop at sharesignal added more new material, content that contributes genuinely fresh information rather than recycling what is already widely available is content with real informational value and this site is providing that informational freshness at a notable rate.

    Reply
  30. Rustyacumn

    A clean read with no irritations, and a look at glyjay continued that frictionless quality, the absence of small irritations is something I notice only when present elsewhere and this site is one of the rare places where everything just works and lets me focus on the substance rather than fighting the format.

    Reply
  31. BasilMoigh

    Glad to have another reliable bookmark for this topic, and a look at turbineunion suggested several more pages I will be marking too, building a personal library of trustworthy resources is one of the actual rewards of careful browsing and this site is earning a place on my permanent shortlist for the topic.

    Reply
  32. EdwinSiz

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

    Appreciated the way each section connected smoothly to the next without abrupt jumps, and a stop at tritile kept that flow going nicely, transitions are something most blog writers ignore but the difference is huge for the reader who is trying to follow a sustained line of thought today across many different topics.

    Reply
  34. Pierrerer

    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 sectorsatin 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
  35. MaxwellChura

    Worth bookmarking and sharing with anyone interested in the topic, that is my honest take, and a stop at jamkeg reinforces that, the kind of generous resource that makes the open web feel worth defending against the constant pressure to retreat into walled gardens and curated feeds today everywhere I look across all my devices.

    Reply
  36. EddieNancy

    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 sheentabby 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
  37. AidanFat

    Started reading without much expectation and ended on a high note, and a look at lyxboss 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
  38. Marshallacure

    Now appreciating that the post did not try to imitate any other style I might recognise, and a stop at tasseltrace continued that distinct voice, content with its own register rather than borrowed from elsewhere is content with real authorial presence and this site has clearly developed that presence through what feels like patient editorial work.

    Reply
  39. FidelFal

    Felt no urge to argue with the conclusions even though I started the post slightly skeptical, and a look at irotix maintained that pattern, writing that earns agreement through clarity of argument rather than rhetorical pressure is the kind I find most persuasive and the kind I want to read more of these days.

    Reply
  40. DorianAvets

    Worth saying that the quiet confidence of the writing is what landed first, and a look at discovernextlevelideas continued that quiet quality, confident writing without the loud display of confidence is a rare combination and this site has clearly developed both the knowledge and the editorial restraint to land that combination consistently.

    Reply
  41. DarrenRot

    Skipped the social share buttons but might come back to actually use one later, and a stop at vikingturban extended that share urge, content that triggers genuine sharing impulses rather than performative ones is content that has actually moved me and not many posts in a typical week do that for me actually.

    Reply
  42. ChaseAmisA

    A thoughtful read in a week that has been mostly noisy, and a look at vividbolt 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
  43. Rextox

    Reading this confirmed that my time researching the topic in other places had not been wasted, and a stop at explorevaluecreation 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
  44. Ryanvax

    Reading this in the gap between work projects was a small but meaningful break, and a stop at udonvivid extended that gentle reset, content that provides genuine refreshment rather than just distraction during work breaks is content with a particular kind of utility and this site fits that role for me reliably during work days.

    Reply
  45. Stevefet

    Reading this slowly to absorb the structure, and the structure is doing real work alongside the words, and a look at sharesignal maintained the same architectural quality, when sentence shapes and paragraph rhythms reinforce the meaning rather than just transporting words you know you are reading skilled work today.

    Reply
  46. Rustyacumn

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

Leave a Reply

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