码迷,mamicode.com
首页 > Web开发 > 详细

nginx 配置html后缀当php解析

时间:2021-05-24 09:26:26      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:filename   sock   cgi   include   pass   ast   fastcgi   php-fpm   extension   

修改php-fpm.conf

security.limit_extensions = .php .html

查看php-fpm.conf内listen,如果是端口则nginx.conf server内容为

location ~ \.php|\.html(.*)$ 
    {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO  $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
        include        fastcgi_params;
    }

如果不为端口,且类似于*.sock,则nginx.conf server内容为

location ~ \.php|\.html(.*)$ 
    {
        fastcgi_pass   unix:/tmp/php-cgi-56.sock;
        fastcgi_index  index.php;
        fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO  $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
        include        fastcgi_params;
    }

 

 

重启php-fpm 和nginx 使配置生效

nginx 配置html后缀当php解析

标签:filename   sock   cgi   include   pass   ast   fastcgi   php-fpm   extension   

原文地址:https://www.cnblogs.com/jiafeimao-dabai/p/14768945.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!