栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

Php和Nginx 整合

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Php和Nginx 整合

以CentOS-6.4-minimal为基础进行编译(在看这篇文章时建议先把php,Nginx编译):

nginx编译:http://freax.blog.51cto.com/6614733/1327589

参考文档:http://nginx.org/cn/docs/http/request_processing.html

第一步:启动nginx

cd /usr/local/nginx

./nginx   #启动nginx

setenforce 0 #暂时关闭selinux

service iptables stop #先关闭防火墙

编辑nginx配置文件

vim nginx.conf #打开后编辑把以下66-73注释都去掉,然后在71行加上 $document_root :这个变量可以是用来指定nginx根目录,原来没有

 64         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

 65         #

 66         location ~ .php$ {

 67             root           html;  #指定网站根目录

 68             fastcgi_pass   127.0.0.1:9000;

 69             fastcgi_index  index.php;

 70             fastcgi_param  script_FILENAME

 71             $document_root$fastcgi_script_name;   #两个变量之间不能有空格

 72             include        fastcgi_params;

 73         }

第二步:启动php-fpm:

cd /usr/local/php

cp etc/php-fpm.conf.default  etc/php-fpm.conf

./sbin/php-fpm



第三步:测试:

cd /usr/local/nginx/html

vi index.php  #写入以下内容

    echo phpinfo();

?>

#保存

第四步:

打开浏览器:你的服务器ip地址/index.php

你你将会看到一个php输出的页面

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/229604.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号