1.nginx配置文件nginx.conf,配置
当你安装完nginx然后开启服务之后用域名或者ip访问后发现只能访问html文件,php文件访问的时候变成下载了,然后就要先配置nginx
[root@izbp1jfv6db6koeuf5v9d4z ~]# vi /etc/nginx/nginx.conf
再server里面加上如下配置。将/opt/lamp换成你的web目录
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /opt/lamp$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
然后重启nginx ,systemctl restart nginx
检查127.0.0.1:9000端口是否处于监听状态,执行netstat -antp,发现并没有被监听,说明需要启动。
执行php-cgi -b 127.0.0.1:9000 & 或者启动php-fpm ,system start php-fpm 启动之后,在执行netstat -antp查看结果
2.php配置文件php.ini配置
当你访问php文件提示 no input file specified 时就要配置php.ini文件
[root@izbp1jfv6db6koeuf5v9d4z ~]# vi /etc/php.ini
加上
-
cgi.fix_pathinfo=1 (这个是自己添加的)
-
doc_root=