nginx 禁止根目录php,nginx站点禁止目录执行php
发布日期:2021-06-24 13:34:12 浏览次数:2 分类:技术文章

本文共 902 字,大约阅读时间需要 3 分钟。

代码加入到server内,如下 :

location ~* ^/(uploads|templets)/.*.(php|php5)$ {

deny all;

}

完整站点配置如下:

server {

listen 80;

root /www/web/yujianlong_com/public_html;

server_name yujianlong.com www.yujianlong.com;

index index.html index.php index.htm;

fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

error_page 400 /errpage/400.html;

error_page 403 /errpage/403.html;

error_page 404 /errpage/404.html;

error_page 503 /errpage/503.html;

location ~* ^/(uploads|templets)/.*.(php|php5)$ {

deny all;

}

location ~ \.php(.*)$ {

fastcgi_pass unix:/tmp/php-55-cgi.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $DOCUMENT_ROOT$fastcgi_script_name;

fastcgi_param PATH_INFO $2;

include fcgi.conf;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {

expires 1d;

}

location ~ .*\.(js|css|html|htm)?$ {

expires 12h;

}

location ~ /\.ht {

deny all;

}

location / {

try_files $uri $uri/ /?$args;

}

}

转载地址:https://blog.csdn.net/weixin_33212263/article/details/116120471 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:linux创建oracle用户命令,Linux 命令 - 切换用户,及创建oracle表空间一系列操作
下一篇:php 图片压缩 长宽不变,PHP 图片 保持高宽不变压缩之后imagejpeg($source,$file,100) 仍旧失真!...

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月06日 10时51分25秒