今天在nginx里添加vhost的时候发现一个奇怪的nginx 403错误,无论是文件权限还是index索引设置都没问题,errlog提示directory index of “/home/www/” is forbidden 怎么查都发现不了问题,vhost配置文件如下

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
server {  
listen 80;  
<span style="color: #ff0000;">server_name test.kwxiaozhu.com</span >
index index.php index.htm index.html;  
root /home/kwxiaozh/;  
access\_log /var/log/nginx/access\_kwxiaozh.log main;  
error\_log /var/log/nginx/error\_kwxiaozh.log debug;

include wp2.conf;

location ~* \.(ico|css|js|gif|jpeg|jpg|png)(\?[0-9]+)?$ {  
expires max;  
break;  
}

location ~ .*\.php$  
{

fastcgi\_pass\_request_body off;  
client\_body\_temp\_path /tmp/client\_body_temp;  
client\_body\_in\_file\_only clean;  
fastcgi\_param REQUEST\_BODY\_FILE $request\_body_file;  
fastcgi_pass unix:/var/run/php5-fpm-kwxiaozh.sock;  
fastcgi_index index.php;  
include /etc/nginx/fastcgi_params;

}  
}

注意红字部分,无意间发现server_name后面没加;分号,加上一切正常,看来就是这个分号惹的祸啊。

不过也挺奇怪的,按说没加分号重启nginx的时候会提示错误的,怎么会没有呢?