Nginx PHP-FPM增加PHP後綴解析

在很多情況下,我們需要把.html也使用php解析。更改nginx配置文件

        location ~ \.(php|do|aspx)?$ {    #這裏增加後綴
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

這個時候訪問這些後綴的時候會報403錯誤,原因是php-fpm限制了後綴的解析

2016/08/04 11:03:35 [error] 6225#0: *65 FastCGI sent in stderr: "Access to the script '/var/www/html/index.aspx' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 127.0.0.1, server: www.abc.com, request: "HEAD /index.aspx HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1"

更改php-fpm.conf配置文件

security.limit_extensions = .php .aspx .do

重啓php-fpm服務即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章