nginx+php的安装配置方法
nginx安装
安装nginx参考以下博文
https://mp.****.net/postedit/104157367
安装php-fpm
#yum -y install php-fpm
启动php-fpm:
#service php-fpm start
配置nginx:编辑 nginx配置文件
#vim /etc/nginx/conf.d/default.conf
修改以下内容:
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
location ~ .php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME fastcgi_script_name;
include fastcgi_params;
}
保存文件,退出。
重启nginx,生效配置:
#systemctl restart nginx
验证nginx是否支持php
编写php测试文件:
#vim /usr/share/nginx/html/test.php
加入以下内容:
保存文件,退出。
打开浏览器,在浏览器地址栏输入 http://服务器的ip地址/test.php 出现以下页面代表nginx+php已经配置成功