服务器从lighttpd+apache迁到nginx
apache对资源要求总是很高,尽管前面挂了一个lighttpd,可以对静态资源做一些处理,
但涉及到动态处理的程序,必须还得使用apache。(当然,lighttpd可以处理所有工作,但
似乎存在一些bug,在此不多赘述)下面讲一下迁移过程吧。
上午还是被折腾了挺久,在apache上配置多个vhost挺熟了,但nginx还没试过。网上
search了一把,其实还很简单。但是迁我的wordpress的时候,出问题了,访问所有的页面
都是404,有些不解了。又注意到url为/2009/06/07/XXX,恍然大悟,原来处理前做了
分发。查了下lighttpd,apache的rewite规则,没有任何对wordpress的分发。实际不解了,
只好再baidu一把,原来.htaccess做了这个工作,但nginx不支持.htaccess功能。了解了这
些就简单了,把.htaccess重写一遍就可以了。
重写如下:
wordpress.conf
location / {
index index.html index.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
然后在nginx.conf需要的地方include wordpress.conf就可以了。
多谢
张久安
If you enjoyed this post, make sure you subscribe to my RSS feed!









No Comments, Comment or Ping
Reply to “服务器从lighttpd+apache迁到nginx”
You must be logged in to post a comment.