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

  1. HarveyOdoth

    Liked that the post landed without needing to manufacture controversy or take a contrarian stance for attention, and a stop at cartluma continued that grounded approach, content that earns attention through quality rather than provocation is the kind that builds long term trust rather than burning it on quick wins.

    Reply
  2. Lucatot

    Quietly building a case in my head for why this site deserves more attention than it currently seems to receive, and a look at plumvendor reinforced the case, the gap between quality and recognition is a recurring frustration in independent online content and this site is one of the cases that seems particularly egregious to me today.

    Reply
  3. EmmettSig

    Worth a quiet moment of recognition for the consistency I have noticed across multiple posts, and a stop at julyelm continued that consistent quality, sites that maintain quality across many pieces rather than peaking on one viral post are sites with real editorial discipline and this one has clearly developed that discipline carefully.

    Reply
  4. SeanCab

    Coming back to this one, definitely, and a quick visit to fortfalcon only made me more sure of that, the kind of writing that makes you want to set aside time later rather than rushing through it now while distracted by everything else competing for attention on the screen today across so many tabs.

    Reply
  5. LelandRam

    Really appreciate the lack of pop ups, modals, cookie banners stacking on top of each other, and a quick visit to styleluma confirmed the same clean approach across the rest of the site, technical decisions about user experience are part of what makes content actually pleasant to engage with for sure.

    Reply
  6. Joelnus

    Worth marking this site as one to come back to deliberately rather than by accident, and a stop at lullneon reinforced that intention, the difference between sites I find again by chance and sites I return to on purpose is meaningful and this one has clearly moved into the deliberate return category for me.

    Reply
  7. JosephThamp

    Will be back, that is the simplest way to say it, and a quick visit to brightfuturedeals reinforced the decision, this site has earned a spot in my regular rotation alongside a few other reliable places I check when I want something genuinely informative without all the usual modern web noise getting in the way.

    Reply
  8. NolanSmize

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

    Took my time with this rather than rushing because the writing rewards attention, and after discoverfashionhub 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
  10. Keatonhix

    Skipped the TLDR thinking I would read everything anyway, and ended up enjoying the path through the full post, and a stop at xavlumo similarly rewarded the patient read, summaries are useful but the journey through good writing is part of what makes the destination feel earned rather than just delivered cleanly.

    Reply
  11. Nicopluri

    Just want to record that this site is entering my regular reading list, and a look at hazegloss confirmed it deserves the spot, my regular reading list is short and well curated and adding to it requires meeting a fairly high quality bar that this site has clearly cleared without much effort apparently.

    Reply
  12. Fredericksoush

    Felt the writer was speaking my language without trying to imitate it, and a look at mivqaro continued that natural fit, when a writers default voice happens to match what you find easy to read the experience feels frictionless and that is something I notice and remember about specific sites going forward.

    Reply
  13. Marshallsaf

    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 zenvani 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
  14. Ignaciozep

    Solid quality, the kind of work that holds up to a careful read rather than a quick skim, and a quick look at jetfrost kept that standard going strong, content that rewards attention rather than punishing it is something I appreciate more and more these days online across nearly every topic I follow.

    Reply
  15. Peterhidge

    Big thanks to whoever wrote this, you saved me a lot of time hunting for the same info on other sites, and a stop at hiltgable only added more useful detail without going off topic, that kind of focus is honestly hard to come across these days when most posts wander everywhere.

    Reply
  16. Perrynes

    Well done, the writing is professional without being stiff, and the topic is treated with care, and a look at premiumdesigncollective reflected that approach, the kind of site I would point a colleague to if they asked for a reliable starting point on this topic in the future without any hesitation at all.

    Reply
  17. Bufordknigo

    Took the time to read the comments on this post too and they were also worth reading, and a stop at wattedge 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
  18. Patrickknors

    Now planning to write about the topic myself eventually using this post as a reference, and a look at liegepenny would also serve in that future piece, content that becomes raw material for my own writing rather than just informing my reading is content with multiplicative value and this site is generating that multiplicative effect.

    Reply
  19. RyderCatly

    Took some notes for a project I am working on, and a stop at luxrivo added more raw material to those notes, content that contributes to my own creative work rather than just being interesting in the moment is the kind I value most and the kind I will keep coming back to repeatedly.

    Reply
  20. IbrahimTah

    Appreciate the practical examples, they made the abstract points easier to grasp, and a stop at ivoryvendor added more of the same, this site clearly understands that real examples beat empty theory every single time which is the mark of a writer who knows their audience well and respects their time.

    Reply
  21. NolanSmize

    Took longer than expected to finish because I kept stopping to think, and a stop at genieframe did the same to me, content that provokes thought rather than just delivering information is in a different category and the team here is clearly working at that higher level rather than just cranking out posts.

    Reply
  22. LelandRam

    Worth pointing out the careful word choice in this post, no buzzwords and no jargon, and a look at styleluma 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
  23. Nicopluri

    Now feeling that this site is the kind I want to make sure does not disappear, and a look at hazegloss reinforced that quiet protective feeling, the rare sites whose disappearance would actually matter to me are the sites I want to support through return visits and recommendations and this one has joined that small protected list.

    Reply
  24. EmmettSig

    Worth a quiet moment of recognition for the consistency I have noticed across multiple posts, and a stop at julyelm continued that consistent quality, sites that maintain quality across many pieces rather than peaking on one viral post are sites with real editorial discipline and this one has clearly developed that discipline carefully.

    Reply
  25. EddieFlafe

    Once you find a site like this the search for similar voices begins, and a look at urbanzaro 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
  26. Ignaciozep

    A clean read with no irritations, and a look at jetfrost 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
  27. Peterhidge

    Worth observing that the post landed without needing a flashy headline to hook attention, and a stop at hiltgable did the same, content that earns engagement through substance rather than packaging is the kind I trust more deeply and this site has clearly chosen substance as the primary lever for reader engagement throughout.

    Reply
  28. GinoImamy

    Skipped the comments section but might come back to read it, and a stop at movlino hinted at a quality reader community, sites where the comments are worth reading separately from the post are increasingly rare and signal a particular kind of audience that has grown around the editorial vision over time gradually.

    Reply
  29. TonyPaivy

    Honestly enjoyed every minute spent here, that is not something I say lightly, and a look at cartmixo 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
  30. ArnoldLop

    Quietly impressive in a way that does not announce itself, and a stop at qenmora extended that quiet impressiveness, the kind of quality that emerges through sustained attention rather than first impressions is the kind I trust more deeply and this site has been earning that deeper trust across multiple sessions over time consistently.

    Reply
  31. Joelnus

    Thank you for being clear and direct, that simple approach saves so much frustration on the reader’s end, and a stop at lullneon 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
  32. RyderCatly

    Worth saying this site reads better than most paid newsletters I have tried, and a stop at luxrivo confirmed that comparison, the bar for free content is often lower than for paid but this site clears the paid bar consistently and that says something about the editorial approach behind the work being published here regularly.

    Reply
  33. TuckerTremn

    Reading this prompted a small note in my reference file, and a stop at seovista prompted another, the rare site that contributes useful nuggets to my own working knowledge rather than just consuming my attention is worth the time investment many times over compared to the usual pile of forgettable scroll content.

    Reply
  34. IbrahimTah

    Decided after reading this that I would check this site weekly going forward, and a stop at ivoryvendor reinforced that commitment, deciding to add a site to a regular rotation requires meeting a quality bar that very few places clear and this one cleared it cleanly without any noticeable effort or marketing push behind it.

    Reply
  35. Ernestbew

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

    Felt like I was reading something written by someone who actually thinks about the topic rather than reciting it, and a look at ebonfig reinforced that impression, the difference between recited content and considered content is huge and this site clearly belongs to the latter category which I appreciate as a careful reader looking for substance.

    Reply
  37. Jeffreigh

    Bookmark earned, share earned, return visit earned, all from one reading session, and a look at zenvaxo did the same, the trifecta of bookmark and share and return is rare in a single visit and represents the highest level of engagement I tend to offer any piece of online content these days here.

    Reply
  38. JosiahHop

    Quiet confidence runs through the whole post, no need to shout to make the points stick, and a stop at xavnora carried that same restrained voice forward, content that respects the reader by trusting its own substance rather than dressing it up in theatrical language is what I look for online and rarely actually find these days.

    Reply
  39. EddieFlafe

    Glad I gave this a chance instead of bouncing on the headline, and after urbanzaro 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
  40. Lucatot

    Just nice to read something that does not feel like it was assembled from a content brief, and a stop at plumvendor kept that handcrafted feel going, you can tell when a real human with real understanding is behind the words versus a templated piece churned out for an algorithm to find.

    Reply
  41. Germanglach

    Worth saying that this is one of the better things I have read on the topic in months, and a stop at lilacneedle reinforced that ranking, the topic is well covered by many sources but few do it with this level of care and the few that do deserve to be flagged so other readers can find them.

    Reply
  42. TonyPaivy

    Picked up a couple of new ideas here that I can actually try out, and after my visit to cartmixo I have even more notes saved, this is the kind of resource that pays you back for the time you spend on it which is rare to come across in this corner of the web.

    Reply
  43. BasilCen

    Reading this on the train into work was a better use of the commute than my usual choices, and a stop at tirzani extended that commute reading well, content that improves transit time rather than just filling it is content with practical benefit and this site has earned its place in my morning commute reading rotation.

    Reply
  44. Bufordknigo

    Stands apart from similar pages by actually being useful, that is high praise these days, and a look at wattedge kept that standard going, you can tell when a site is built around the reader versus around metrics and this one clearly belongs to the first category for sure based on what I read.

    Reply
  45. fastek 84

    Компания fastek https://fastek.by проектируем и поставляем надежные фасадные системы для коммерческих и жилых объектов, обеспечивая долговечность, энергоэффективность и безупречный внешний вид здания под ваши задачи.

    Reply
  46. Jeffjaf

    Honestly this was the highlight of my reading queue today, and a look at gladfir extended that across more pages I will return to, ranking what I read against what else I read each day is something I do informally and this site keeps moving up in those rankings the more I explore it.

    Reply
  47. TuckerTremn

    Over the course of reading several posts here a pattern of quality has emerged, and a stop at seovista 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
  48. KyrieBiz

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

    If the topic interests you at all this is a place to spend time, and a look at curatedglobalcommerce reinforced that recommendation, the broader question of where to invest topical reading time is one this site answers convincingly through the consistent quality across multiple pieces I have sampled during the current reading session today.

    Reply

Leave a Reply

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