Lnmp配置搭建了nginx的lnmp,也作了博客和论坛,我是这样做静态化的。
建一个discuz.conf 和 wordpress.conf 和nginx.conf放在同一个文件夹下,具体位置具体放置,我的是放在/usr/local/webserver/nginx/conf下面
discuz.conf 的内容如下
location / {
rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last;
rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$12 last;
32 last;
rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last;
rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;
}
wordpress.conf 的内容如下使用 (super cache 加速)
location /
{
autoindex off;
set $wp_super_cache_file ”;
set $wp_super_cache_uri $request_uri;
if ( $request_method = POST )
{
set $wp_super_cache_uri ”;
}
if ( $query_string )
{
set $wp_super_cache_uri ”;
}
if ( $http_cookie ~* “comment_author_|WordPress|wp-postpass_” )
{
set $wp_super_cache_uri ”;
}
if ( $wp_super_cache_uri ~ ^(.+)$ )
{
set $wp_super_cache_file /wp-content/cache/wp_super_cache/$http_host/$1index.html;
}
if ( -f $document_root$wp_super_cache_file )
{
rewrite ^(.*)$ $wp_super_cache_file break;
}
if (-f $request_filename)
{
expires 30d;
break;
}
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
(不使用 super cache 加速如下,建议使用上面的,全乎)
location / {
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;
}
}
在你的虚拟机配置中这样配置
在虚拟机配置的第一个大括号中加入一句引用(discuz)
include discuz.conf;
或者(wordpress)
include wordpress.conf;
检查nginx配置,没有错误,重启
给你个例子
这是我的bbs
server
{
listen 80;
server_name bbs.1dle.com;
index index.html index.htm index.php;
root /data0/htdocs/bbs;
include discuz.conf;
error_page 404 = /error/404.html;
error_page 502 = /error/502.html;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
log_format wwwlogs ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” $http_x_forwarded_for’;
access_log /data1/logs/wwwlogs.log wwwlogs;
}
(责任编辑:IT) |