为了安全起见, 我们一般会对上传目录禁止执行 php 指令码
修改 nginx.conf 配置档案
禁止单目录:
location ~* ^/attachments/.*.(php|php5)$ {
deny all;
}

禁止多目录:
location ~* ^/(attachments|upload)/.*.(php|php5)$ {
deny all;
}

需要注意两点:
1 、以上的配置档案程式码需要放到 location ~ .php{…} 上面,如果放到下面是无效的
2 、 attachments 需要写相对路径,不能写绝对路径
3 、不要忘记重启 nginx 呀,service nginx restart