Home >Operation and Maintenance >Linux Operation and Maintenance >It is forbidden to upload directory to execute php script under linux
Can be achieved by modifying the nginx.conf configuration file.
The method is as follows:
Disable single directory:
location ~* ^/attachments/.*.(php|php5)$ { deny all; }
(Video tutorial recommendation: linux video tutorial)
Prohibit multiple directories :
location ~* ^/(attachments|upload)/.*.(php|php5)$ { deny all; }
Note:
1. The above configuration file code needs to be placed above location ~ .php{...}. If placed below, it will be invalid.
2. Attachments need to write relative paths, not absolute paths.
3. Don’t forget to restart nginx
service nginx restart
Recommended tutorial: linux tutorial
The above is the detailed content of It is forbidden to upload directory to execute php script under linux. For more information, please follow other related articles on the PHP Chinese website!