把 WordPress 博客迁移到 vps

原来的虚拟主机要到期了,vps正好空着,就打算迁移到vps上。

迁移起来基本没有遇到麻烦,很快就完成了。具体步骤是:

1.把 BackWPup 昨天的备份拷到了vps下解压出来。这里需要注意一下文件的权限问题。
2.照着 wp-config.php 建立了新的数据库和mysql帐号,通过 phpmyadmin 把数据库导入vps。
3.因为我的vps用的是nginx,所以需要处理一下htaccess文件。为 location 段增加以下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# WordPress pretty URLs
if (-f $request_filename) {
expires max;
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php?q=$1 last;
 
# Enable nice permalinks for WordPress
error_page  404  = //index.php?q=$uri;
 
 
#下面是 WP Super Cache 支持部分,如果没有WP Super Cache就不需要。
# if the requested file exists, return it immediately
if (-f $request_filename) {
expires 30d;
break;
}
 
set $supercache_file '';
set $supercache_uri $request_uri;
 
if ($request_method = POST) {
set $supercache_uri '';
}
 
# Using pretty permalinks, so bypass the cache for any query string
if ($query_string) {
set $supercache_uri '';
}
 
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache_uri '';
}
 
# if we haven't bypassed the cache, specify our supercache file
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /var/www/wp-content/cache/supercache/$http_host/$1index.html;
}
 
# only rewrite to the supercache file if it actually exists
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}
 
# all other requests go to WordPress
if (!-e $request_filename) {
rewrite . /var/www/index.php last;
}

4.登录博客后台,修改一下BackWPup文件的备份路径。
5.WP Super Cache 的路径也需要修改一下,打开 wp-content/advanced-cache.php 修改一下就可以了。

6.在处理一下 BackWPup 的备份目录,禁止下载备份。在nginx配置文件里面加上下面的内容

1
2
3
        location /wp-content/backwpup {
                deny all;
        }

这样就把 WordPress 迁移完成了。

备注:发现BackWPup插件自动备份出现了问题,会使php5-cgi 进程cpu使用率达到100%,并产生数G的日志占满磁盘空间。删除旧的备份计划,并建立新的备份计划就可以解决了。

 

随机日志

    3 Responses so far »

    1. 1

      Dianso said,

      四月 6, 2011 @ 下午 7:11

      好可爱的baby

    2. 2

      i2cq said,

      七月 10, 2011 @ 上午 11:10

      我也打算购买一个vps来做站,用的虚拟主机老是被封,然后被连累。
      现在一般vps大概多少钱,能推荐个吗?独立ip是另外算费用吗?

    3. 3

      GameXG said,

      七月 10, 2011 @ 上午 11:33

      vps 价格并不一致,一般配置的从2.99$/月到19$月都有。我现在用的这个是原来做活动已2.99$/月买的,限额是Memory: 256 MB、Burst: 512 MB、Disk Space: 10 GB、Bandwidth: 500 GB。我只用过两家的vps,也没什么推荐的。基本上所有的vps的ip不另收费,甚至很多vps会免费提供两个独立ip。如果只是防止被牵连,建议还是用虚拟主机+独立ip来解决,vps用起来比较麻烦,而且性价比不如虚拟主机。

    Comment RSS · TrackBack URI

    Say your words