解决lnmp环境nginx无法解析php文件,html正常解析

来源:互联网 发布:手机主题软件 知乎 编辑:程序博客网 时间:2024/06/02 04:14
lnmp环境nginx无法解析php文件,html正常解析。
出现nginx无法解析php显示404 Not Found
一键安装lnmp环境,内含nginx。
首先先安装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
至此即可显示成功。
原创粉丝点击