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

ubuntu14.04安装nginx+php5-fpm

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

ubuntu14.04安装nginx+php5-fpm

安装php5-fpm

# apt-get install php5-fpm

安装完成以后修改/etc/php5/fpm/conf.d/www.conf:

;listen = /var/run/php5-fpm.sock

listen = 127.0.0.1:9000

重载php5-fpm配置

# /etc/init.d/php5-fpm reload

检查一下是否监听了9000端口:

# netstat -tln 

如果出现了9000端口,说明php5-fpm正常启动。


安装nginx(参考Ubuntu 14.04安装Nginx1.60)

安装完成之后配置/etc/nginx/conf.d/default.conf:

要执行php关键要修改如下部分:

#location ~ .php$ {

#        root           html;

#        fastcgi_pass   127.0.0.1:9000;

#        fastcgi_index  index.php;

#        fastcgi_param  script_FILENAME  /scripts$fastcgi_script_name;

#        include        fastcgi_params;

#    }

去掉前面的#号,修改root为你自己目录,修改/scripts$fastcgi_script_name为$document_root$fastcgi_script_name。修改之后如下:

location ~ .php$ {

        root           /var/www;

        fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;

        fastcgi_param  script_FILENAME  $document_root$fastcgi_script_name;

        include        fastcgi_params;

   }

注意:

root如果不指定会出现找不到文件的错误。

/scripts如果不修改会出现如下错误

[error] 5152#0: *7 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"

也可以不指定root直接把$document_root写成真实地址。

如果不修改/etc/php5/fpm/conf.d/www.conf的话,也可以设置fastcgi_pass  后的127.0.0.1:9000;为unix:/var/run/php5-fpm.sock;

然后重载nginx配置:

# /etc/init.d/nginx reload

在/var/www目录中新建一个index.php文件,在浏览器地址栏输入localhost,回车!

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

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

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