关键步骤:在编译安装好nginx和php后==>>修改nginx配置文件==>在nginx默认发布目录书写php的测试页==>浏览器进行测试

前面我已经编译安装好了,nginx和php,现在来修改nginx的配置文件,对nginx和php进行整合。

1.每个人编译安装后配置文件的所存放的位置都不一样,一定要注意,我这里自定义保存的位置在/usr/local/nginx/conf/nginx.conf(php模块是nginx自带的,只需要将php模块前的注释去掉,然后加以修改就ok)

[root@php ~]# vim /usr/local/nginx/conf/nginx.conf
65 location ~ \.php$ {   ##当浏览器访问到以php结尾的页面就交给php的9000端口来处理请求,反之则交给nginx的80端口处理
66 root html;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
70 include fastcgi.conf;   ##fastcgi.conf是php自带的配置文件
71 }

[root@php conf]# ls
fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utf
fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_params.default

2. 更改完配置文件检测刷新一下

[root@php conf]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@php conf]# nginx -s reload

3. 在nginx默认发布目录书写php的测试页

[root@php ~]# cd /usr/local/nginx/html/
[root@php html]# vim index.php 
[root@php html]# cat index.php 
<?php
phpinfo()
?>
}

4. 在浏览器IP/index.php访问测试

这样nginx结合php-fpm就ok了!!!

 


云野 » nginx结合php-fpm

发表回复