配置Kloxo下的lighttpd支持WP Super Cache
把博客搬到了昨天新买的VPS上,但是由于我的VPS装的Kloxo,这款控制面板会附带安装lighttpd和apache两个web服务器,由于apache太耗内存,而且我的站基本上是对静态文件和图片的处理,所以选择了轻量级的lighttpd,所以WP Super Cache之前在apache下的rewrite规则就全然无用了。但是如果又特别想用WP Super Cache怎么办呢?
于是开始查找lighttpd的WP Super Cache的rewrite规则怎么写,很快找到了一篇资料,按照上面的步骤进行,结果惨不忍睹,折腾了好几个小时都没搞定,最后还把Kloxo搞挂了,很失落。今天早上起床后迅速接着昨天晚上的步骤搞,几经折腾,终于搞定了,而且把lighttpd升级到了1.4.26 。 总结一下我整个配置过程吧:
1,安装make
我的VPS用的系统是CentOs5,貌似没有make,执行make时会提示“Make Command not Found ”,需要手动安装一下,稍后几个步骤会用到。
yum -y install gcc automake autoconf libtool make |
2,安装lua环境
因为在lighttpd下的WP Super Cache需要用到lua脚本,所以先要安装lua环境,具体步骤如下:
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz tar -xzvf lua-5.1.4.tar.gz cd lua-5.1.4 yum install libtermcap-devel yum install ncurses-devel yum install libevent-devel yum install readline-devel make linux make install |
这样,lua环境就算安装完毕了。
3,重新编译lighttpd
wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.26.tar.gz tar -xzvf lighttpd-1.4.26.tar.gz cd lighttpd-1.4.26 export LUA_CFLAGS="-I/usr/local/include" export LUA_LIBS="-L/usr/local/lib -llua" yum install openssl openssl-devel yum install flex autoconf zlib curl zlib-devel curl-devel bzip2 bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel yum install pcre-devel ./configure --with-pcre --with-lua --with-zlib --with-openssl --sbindir=/usr/sbin --sysconfdir=/etc/lighttpd make make install |
到这里lighttpd重新编译完毕。
4,修改lighttpd配置文件
vim /etc/lighttpd/lighttpd.conf |
找到server.modules,在其中加一行”mod_magnet”,如:
server.modules = ( "mod_rewrite", "mod_redirect", "mod_alias", "mod_access", "mod_magnet", ... ... |
6,上传rewrite.lua,添加重写规则
下载rewrite.lua,上传至博客根目录,进入Kloxo,选择域名,选择博客的域名,然后选择lighttpd地址重写规则,如图
加入如下规则:
$HTTP["host"] == "www.qifendi.com" {
server.error-handler-404 = "/index.php"
server.document-root = "/home/admin/xxx" #填写博客根目录
magnet.attract-physical-path-to = ( server.document-root + "/rewrite.lua" )
} |
7,重启lighttpd。
yum downgrade openssl /etc/init.d/lighttpd restart |
8,权限设置
访问博客,如果报500错误,将/wp-content/cache/和/wp-content/cache/supercache/权限设置为755 这时候虽然WP Super Cache还在报Mod rewrite may not be installed!,但是实际上已经有作用了。如果操作过程中不慎把Kloxo搞挂了,可以用下面的命令重启一下:
/etc/init.d/kloxo restart |
感谢您的浏览,如果您喜欢本站,可以通过Rss订阅本站,如需转载,请注明出处,谢谢!

恩,现在用的nginx了,关于Kloxo的介绍,您可以参考这里 http://www.ctohome.com/FuWuQi/Kloxo/
[回复]