nginx 配置html后缀当php解析

2021/5/15 7:30:21

本文主要是介绍nginx 配置html后缀当php解析,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

修改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解析的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程