介绍Nginx配置支持PHP

1、添加 Nginx 配置

[[email protected] php-fpm.d]#cd /etc/nginx
[[email protected] conf]# vim nginx.conf
#配置如下
server
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /usr/local/nginx/html;
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}

2、添加 php 探测文件

[[email protected] ~]# cd /usr/local/nginx/html/
[[email protected] html]# vim index.php

3、验证 Nginx 关联 php-fpm

[[email protected] html]# systemctl restart php-fpm.service
[root@localhost ~]# ps -ef|grep php-fpm
root 69652 1 0 14:02 ? 00:00:00 php-fpm: master process
(/usr/local/php7/etc/php-fpm.conf)
nginx 69653 69652 0 14:02 ? 00:00:00 php-fpm: pool www
nginx 69654 69652 0 14:02 ? 00:00:00 php-fpm: pool www
nginx 69655 69652 0 14:02 ? 00:00:00 php-fpm: pool www
nginx 69656 69652 0 14:02 ? 00:00:00 php-fpm: pool www
nginx 69657 69652 0 14:02 ? 00:00:00 php-fpm: pool www

2)重载 Nginx 配置

[[email protected] html]# systemctl reload nginx
[[email protected] html]# systemctl status nginx

3)访问验证

介绍Nginx配置支持PHP_第1张图片

 

你可能感兴趣的:(nginx,php,运维)