Archive for VPS

把 WordPress 博客迁移到 vps

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

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

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

 
# 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配置文件里面加上下面的内容

 
        location /wp-content/backwpup {
                deny all;
        }

这样就把 WordPress 迁移完成了。

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

Comments (3) »