为了安全起见,我们一般会对上传目录禁止运行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
———————


![[人与自然] 从高原之王到“都市囚徒”(附图)-微慑信息网-VulSee.com](http://www.nanfangdaily.com.cn/zm/20060420/xw/xz/200604200017_292512.jpg)

![[游戏] 最新版No-Steam CS1.6 Ver.3213版 S_CXV-微慑信息网-VulSee.com](http://game.tyfo.com/download/softimg/2005118154321.gif)
![[娱乐] 范冰冰章子怡等百位明星身份证照曝光(图)-微慑信息网-VulSee.com](http://img2.cache.netease.com/ent/2009/2/16/20090216133037d442e.jpg)


![[八卦] 王婷婷—揭秘一个大三女生的性爱录像-微慑信息网-VulSee.com](http://free.86hy.com/crack/pic/1.jpg)
![[随笔]今天国际警察节-微慑信息网-VulSee.com](http://photo.sohu.com/20041017/Img222528326.jpg)

青云网
