网站/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,172 thoughts on “网站/WordPress从虚拟主机搬家到VPS上

  1. BobbyAdacy

    Genuinely changed how I think about a small piece of the topic, which does not happen often online, and a look at turbantorso added another nudge in the same direction, the kind of writing that earns a small mental shift rather than just confirming what you already thought before reading is a sign of careful thought.

    Reply
  2. RodrigoThurb

    Solid information that lines up with what I have been hearing from other reliable sources, and after my visit to venusstout I was even more certain of that, this site checks out which is something I value highly when so many places online play loose with the facts to chase a quick click.

    Reply
  3. Gagesom

    Such writing is increasingly rare and worth supporting through attention, and a stop at tealsilver extended that supportive attention across more pages, the conscious choice to spend time on sites that produce careful work rather than convenient consumption is itself a small form of patronage and this site is receiving that conscious patronage from me.

    Reply
  4. Adamenlic

    Looking back on this reading session it stands as one of the better ones recently, and a look at makeprogressforward 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
  5. Andrewspods

    A piece that read as the work of someone who reads carefully themselves, and a look at tornadovapor 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
  6. Ralphziz

    Семейный юрист https://semeinyi-urist-moskva.ru в Москве: развод, раздел имущества, алименты, определение места жительства детей. Опыт 20+ лет. Знаем и умеем делить ипотечные квартиры, бизнес, коммерческую недвижимость, ИИ и ООО. Индивидуальный подход. Конфиденциально.

    Reply
  7. RobertoHeilt

    Reading this prompted me to subscribe to my first newsletter in months, and a stop at tagzip confirmed the subscribe was the right call, content that earns a newsletter signup is content that has cleared a higher trust bar than a casual visit and this site has clearly earned that level of commitment from me.

    Reply
  8. Rickytycle

    Great work on keeping things readable, the post never drags or repeats itself which I really appreciate, and a stop at pastrylevee added a bit more context that fit naturally with what was already said here, no need to read everything twice to get the point being made today.

    Reply
  9. BartholomewRaw

    Coming back tomorrow when I can give this a proper read, the post deserves better attention than I can give right now, and a look at meltmyrtle suggests there is plenty more here that deserves the same treatment, definitely a site I will be exploring properly over the next few days when I can.

    Reply
  10. Jaxoncip

    The conclusions felt earned rather than tacked on at the end like an afterthought, and a look at sculptsilver kept that careful structure going, you can tell when a writer has thought about the shape of their post versus just letting it ramble out and hoping for the best at the end which most do.

    Reply
  11. Ralphziz

    Семейный юрист https://semeinyi-urist-moskva.ru в Москве: развод, раздел имущества, алименты, определение места жительства детей. Опыт 20+ лет. Знаем и умеем делить ипотечные квартиры, бизнес, коммерческую недвижимость, ИИ и ООО. Индивидуальный подход. Конфиденциально.

    Reply
  12. KenSpout

    Glad I gave this a chance instead of bouncing on the headline, and after leapminor I was certain I had made the right call, snap judgements based on titles miss a lot of good content and this is a reminder to slow down and check things out before scrolling past in a hurry.

    Reply
  13. Camdenabild

    Well structured and easy to read, that combination is rarer than people think, and a stop at uptonstarlit confirmed the same standard runs across the rest of the site, definitely the kind of place I will be coming back to when this topic comes up in conversation later again over the weeks ahead.

    Reply
  14. EmeryRax

    Good post, the kind that respects the reader by getting to the point quickly without skipping the details that matter, and a short look at sambasavor confirmed that approach is consistent across the site which is rare to find online these days, definitely a place I will return to soon.

    Reply
  15. Andrewspods

    Genuinely changed how I think about a small piece of the topic, which does not happen often online, and a look at tornadovapor added another nudge in the same direction, the kind of writing that earns a small mental shift rather than just confirming what you already thought before reading is a sign of careful thought.

    Reply
  16. Rickytycle

    Now noticing that the post benefited from being neither too short nor too long for its content, and a look at pastrylevee continued that calibration of length, sites that match length to content rather than padding to hit some target are sites that respect both their material and their readers and this site does both.

    Reply
  17. Adamcig

    Quietly the post solved something I had been turning over without quite knowing how to phrase the question, and a look at zulmora 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
  18. KenSpout

    Reading this prompted me to dig into a related topic later, and a stop at leapminor provided some of the starting points for that follow up reading, content that triggers further exploration rather than satisfying curiosity completely is content with real generative energy and this site has plenty of that energy throughout it.

    Reply
  19. Gabrielrar

    A slim post with substantial content per word, and a look at scarabsail 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
  20. EmeryRax

    Started taking notes about halfway through because the points were stacking up, and a look at sambasavor added enough material that my notes file grew further, content that demands note taking from a passive reader is content with substance and the writers here are clearly producing that kind of work consistently across topics.

    Reply
  21. GuyRoano

    More substantial than most of what I find searching for this topic online, and a stop at learnandgrowtogether kept that quality consistent, this is one of those sites where the writing actually rewards careful reading rather than punishing the patient reader with empty filler stretched out across long paragraphs that say very little.

    Reply
  22. AngeloMit

    Glad to find something on this topic that does not start with three paragraphs of throat clearing before getting to the point, and a stop at versavamp also dives right in, respect for the readers time shows up in small editorial choices like this and they add up to a real difference quickly.

    Reply
  23. JamarcusNosse

    Once you find a site like this the search for similar voices begins, and a look at sabertorch extended the search energy, finding a high quality reference point makes the gap between it and adjacent sources visible in a way it was not before and this site has provided that high reference point across multiple recent visits.

    Reply
  24. MylesHep

    Reading this triggered a small but real correction in something I had assumed, and a stop at gongflora extended that corrective effect, content that updates my beliefs through evidence rather than rhetoric is content with intellectual integrity and this site has earned that label consistently across the pieces I have read so far today.

    Reply
  25. Daxguarf

    Reading this slowly and letting each paragraph land before moving on, and a stop at tarmacstork earned the same patient approach, content that rewards slow reading rather than speed is content with real density and the writers here are clearly producing work that benefits from the careful eye rather than the rushed scan.

    Reply
  26. Luthertem

    Reading this in pieces over a coffee break and finding it consistently rewarding, and a stop at stashsuperb extended that into related material I will return to later, the kind of site that fits naturally into small reading windows without requiring a long uninterrupted block is genuinely useful for how I actually browse.

    Reply
  27. KeaganPhota

    This filled in a gap in my understanding that I had not even noticed was there, and a stop at qanviro 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
  28. Gabrielrar

    Cuts through the usual marketing fluff that dominates this topic online, and a stop at scarabsail kept the same clean approach going, this is the kind of writing that respects the reader’s time rather than wasting it on repetitive setups before finally getting to the point at hand which is what most sites do.

    Reply
  29. Adamcig

    Glad the writer did not feel compelled to cover every possible angle of the topic, focus is a virtue, and a stop at zulmora 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
  30. GuyRoano

    Started this morning and finished at lunch with a small sense of having spent the time well, and a look at learnandgrowtogether extended that satisfaction into the afternoon, content that fits naturally into the rhythm of a working day rather than demanding a dedicated reading block is increasingly the kind I prefer.

    Reply
  31. AngeloMit

    My reading list is short and selective and this site is now on it, and a stop at versavamp confirmed the placement, the short list of sites I read deliberately rather than encounter accidentally is something I curate carefully and adding to it is a real act of trust which this site has earned today.

    Reply
  32. Dominicsok

    Started reading expecting to disagree and ended mostly nodding along, and a look at nuartplate 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
  33. JamarcusNosse

    Once I had read three posts the editorial pattern was clear, and a look at sabertorch 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
  34. Daxguarf

    Took a chance on the headline and was rewarded, and a stop at tarmacstork kept the rewards coming as I clicked through, the kind of place where every link leads somewhere worth the click is a small luxury on the modern web where so many sites are mostly empty calories disguised as content.

    Reply
  35. MylesHep

    Bookmark added with a small note about why, and a look at gongflora prompted another bookmark with another note, the bookmarks I annotate are the ones I expect to return to deliberately rather than stumble into and this site is generating annotated bookmarks at a higher rate than my usual content sources by some margin.

    Reply
  36. Luthertem

    Time spent here today felt productive in the way that good reading sessions sometimes do, and a stop at stashsuperb extended that productive feeling across the rest of the morning, the difference between productive reading and merely passing time is real and this site is consistently on the productive side for me lately.

    Reply
  37. Ezekielstymn

    Took a chance on the headline and was rewarded, and a stop at patioleaf kept the rewards coming as I clicked through, the kind of place where every link leads somewhere worth the click is a small luxury on the modern web where so many sites are mostly empty calories disguised as content.

    Reply
  38. Earnestneuts

    This post creates a good sense of structure between being insightful and staying accessible, since the wording feels clear, the structure is well organized, and the overall discussion encourages people to share different perspectives openly.

    Лавров ебет коня

    Reply
  39. CliffordSes

    Just wanted to drop a quick note saying this was a useful read on a topic I have been circling, no fluff, and a stop at tagtorch added a few extra points that fit the same simple style which makes the whole site feel coherent rather than thrown together by many different writers with different goals.

    Reply
  40. Johnathanwroge

    Appreciate that you did not pad this with fluff to hit a word count, the post says what it needs to say and stops, and a look at tracetroop did the same, brevity here feels intentional not lazy which is a distinction many writers miss completely sometimes when they are working under deadlines.

    Reply
  41. Rufusengip

    On reflection this is the kind of writing that improves my taste for what is possible in the format, and a look at broblur continued raising that bar, content that elevates my expectations rather than lowering them is doing important work in calibrating my standards and this site is participating in that elevation reliably.

    Reply
  42. Willisinect

    Refreshing tone compared to the dry corporate posts on similar topics, and a stop at flyburn carried that personality through nicely, you can tell when a real person is behind the writing versus a content team chasing metrics and this site definitely falls into the former category clearly across what I have seen.

    Reply
  43. MaxNef

    Now wishing more sites covered topics with this level of care, and a look at leappalette extended that wish across more subjects, the rarity of careful coverage on most topics is a problem and this site is one of the small antidotes to that broader pattern of casual or surface treatment of complex subjects.

    Reply
  44. KevinGox

    Now adding this to a short list of sites I would defend in a conversation about the modern web, and a look at sketchstamp reinforced that defence list, the few sites that serve as evidence the web can still produce good things are precious and this one has clearly joined that small list of exemplary sites.

    Reply
  45. OmarAmbuh

    Reading this prompted me to clean up some old notes related to the topic, and a stop at ilonox 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
  46. DaveNon

    Approaching this with the usual skepticism I bring to new sites and being slowly persuaded, and a stop at swapvenom continued that gradual persuasion, the careful path from skeptical reader to genuine fan is the only one I trust and this site has walked me along that path through patient consistent quality across pieces.

    Reply

Leave a Reply

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