首先要編輯nginx的虛擬機器主機配置,在fastcgi的location語句的前面按下面的內容添加:
1、單個目錄去掉PHP執行許可權
location ~ /attachments/.*\.(php|php5)?$ {
deny all;
}
將attachments目錄的PHP執行許可權去掉。
2、多個目錄去掉PHP執行許可權
location ~ /(attachments|upload)/.*\.(php|php5)?$ {
deny all;
}
將attachments、upload這二個目錄的PHP執行許可權去掉。
附上一個完整的虛擬機器主機的例子供參考:
server
{
listen 80;
server_name www.45it.com;
index index.html index.htm index.php;
root /home/wwwroot/bbs.vpser.net;include discuz.conf;
location ~ /(attachments|upload)/.*\.(php|php5)?$ {
deny all;
}
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
access_log off;
}
添加完執行:/usr/local/nginx/sbin/nginx -t測試組態檔案,執行:/usr/local/nginx/sbin/nginx -s reload 載入設定檔使其生效。
註:注意順序,一定要放在 “location ~ .*\.(php|php5)?$” 一行上面,不然不會生效。
http://www.bkjia.com/PHPjc/767401.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/767401.htmlTechArticle首先要編輯nginx的虛擬機器主機配置,在fastcgi的location語句的前面按下面的內容添加: 1、單個目錄去掉PHP執行許可權 location ~ /attachments/.*\.(php|p...