打开 nginx安装目录/conf/nginx.conf文件找到http花括号在里边加入以下代码
代码如下 |
复制代码 |
server
{
listen 80; #端口,通常默认就好(必须)
server_name www.111com.net 111com.net; #域名,多个用空格隔开(必须)
index index.html index.htm index.php; #默认首页文档,多个可以增加(必须)
root /data0/htdocs/www.111com.net; #虚拟主机目录(必须)
#--自动在域名前补齐www(非必要)--#
if ($host != 'www.111com.net' ) {
rewrite ^/(.*)$ http://www.111com.net/$1 permanent;
}
#--域名补齐结束--#
#--为WordPress伪静态--(非必要)--#
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;
}
#--WordPress伪静态结束--#
#--PHP支持--如果你搭建的是PHP环境则此段要加--#
location ~ .*.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
#--PHP支持结束--#
#--额外配置,如果线上运行最好去掉,如第一行代表开开检索(不安全)--#
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
#--额外配置--#
#日志打开(最新版本格式)
access_log /data1/logs/access_qttc.log logs;
}
|
把以上代码拷贝进nginx.conf以后,保存重启nginx即可生效。