nginx不能解析php怎么办

这篇文章将为大家详细讲解有关nginx不能解析php怎么办,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

首先先安装php-fpm

yum install php-fpm
service php-fpm start    #启动 php-fpm

然后修改nginx配置文件nginx.conf 识别php

vi /usr/local/nginx/conf/nginx.conf 加一段代码

location ~ \.php$ {
   #fastcgi_split_path_info ^(.+\.php)(/.+)$;
            root          /usr/share/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
            include        fastcgi_params;
#$document_root
        }

最后重启nginx和php-fpm

service nginx restart
service php-fpm restart

关于nginx不能解析php怎么办就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。