Simple in general IIS, IIS6 as shown in the following illustration:
In the Edit feature permission ..., we directly remove the script execution permissions. (Figure 3)
Apache is typically restricted by the. htaccess file
The Apache environment rules are as follows: Apache executes PHP script restrictions to add these rules to the. htaccess file
Copy Code code as follows:
Rewriteengine on Rewritecond%!^$
Rewriterule uploads/(. *). (PHP) $–[f]
Rewriterule data/(. *). (PHP) $–[f]
Rewriterule templets/(. *). (PHP) $–[f]
To run PHP in the Apache module, you can add the following code to the vhosts configuration file:
Prevent upload directory from executing php file permissions
<Directory/www/www.jb51.net/upload>
php_flag engine off
</Directory>
<directory ~ "^/ Www/.*/upload ">
<files ~". php > Order
allow,deny deny to all
</Files>
</ Directory>
The NGINX environment rules are as follows: Nginx Execute PHP script restrictions
LNMP has a disadvantage is that directory permissions are not as good as Apache, and sometimes the Web site program has uploaded vulnerabilities or similar pathinfo vulnerabilities, which led to the upload of the PHP trojan, and to the Web site and the server to bring greater danger. It is recommended to remove the PHP permissions from the Site directory and return 403 errors when accessing the PHP file under the upload directory.
To edit the Nginx virtual host configuration First, add the following in front of the fastcgi location statement:
Copy Code code as follows:
Location ~/(data|uploads|templets)/.*\. (PHP|PHP5)? $ {
Deny all;
}
Here are the additions:
The following configurations are added to the server at the Nginx configuration
Copy Code code as follows:
Location ~/attachments/.*\. (PHP|PHP5)? $ {
Deny all;
}
Prevent attachments directory from executing PHP file permissions
2. Multiple catalogs
Copy Code code as follows:
Location ~/(attachments|upload)/.*\. (PHP|PHP5)? $ {
Deny all;
}
Prohibit attachments and upload directories from executing PHP file permissions
After the configuration is finished, reload Nginx can be done again.
All right, this is it, do these should not have any problems basically enough!