First of all, to edit the Nginx virtual host configuration, in front of the FASTCGI location statement, add the following content:
1, single directory remove PHP Execute permissions
Location ~/attachments/.*\. (PHP|PHP5)? $ {
Deny all;
}
Remove PHP execution permissions from the attachments directory.
2. Remove PHP execution permissions from multiple directories
Location ~/(attachments|upload)/.*\. (PHP|PHP5)? $ {
Deny all;
}
Remove the PHP Execute permissions for the two directories attachments, upload.
An example of a complete virtual host is included:
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;
}
Add execution:/usr/local/nginx/sbin/nginx-t Test configuration file, execute:/usr/local/nginx/sbin/nginx-s reload Load the configuration file for it to take effect.
Note: Notice the order, must be placed in "location ~. *\." (PHP|PHP5) $ "line above, otherwise it will not take effect.
http://www.bkjia.com/PHPjc/767401.html www.bkjia.com true http://www.bkjia.com/PHPjc/767401.html techarticle first of all to edit the Nginx virtual host configuration, in front of the FASTCGI location statement to add the following: 1, a single directory remove PHP execution permissions location ~/attachments/.*\. (Php|p ...