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

Nginx + PHP/PHP-FPM安装配置示例

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

Nginx + PHP/PHP-FPM安装配置示例

(1)编译安装nginx

1yum install pcre-devel zlib-devel openssl-devel -y

*pcre-devel是http rewrite模块依赖的类库

*zlib-devel是http gzip模块依赖的类库

*openssl-devel是http ssl模块依赖的类库

下载编译安装ngixn:


wget http://nginx.org/download/nginx-1.6.2.tar.gz tar -zxvf nginx-1.6.2.tar.gzcd nginx-1.6.2 && ./configure --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_gunzip_modulemakemake install


(2)安装PHP/PHP-FPM

PHP-FPM是FastCGI进程管理器,是PHP的一个补丁;

http://php-fpm.org/download/

http://php.net/downloads.php

从上述的地址中分别下载PHP版和对PHP进行打PHP-FPM补丁:

1234wget http://cn2.php.net/get/php-5.5.22.tar.gz/from/this/mirror -O php-5.5.22.tar.gztar -zxvf php-5.5.22.tar.gzcd php-5.5.22 && ./configure --enable-fpmmake && make install

*如果缺少xml2相关错误,需安装libxml2以及libxml2-devel


(3)配置PHP-FPM

默认情况下配置文件模板放在/usr/local/etc

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

其中默认监听地址和端口为http://127.0.0.1:9000


(4)配置nginx支持PHP


location ~ /.php$ {    root  html;     fastcgi_pass http://127.0.0.1:9000;      fastcgi_index index.php     fastcgi_param script_FILENAME $document_root$fastcgi_script_name;}

关于nginx的fastcgi模块的参考:http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html


(5)启动nginx和php/php-fpm

1php-fpm && /usr/local/nginx/sbin/nginx




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

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

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