(1)编译安装nginx
1
|
yum
install
pcre-devel zlib-devel openssl-devel -y
|
*pcre-devel是http rewrite模块依赖的类库
*zlib-devel是http gzip模块依赖的类库
*openssl-devel是http ssl模块依赖的类库
下载编译安装ngixn:
1
2
3
4
5
|
wget http:
//nginx
.org
/download/nginx-1
.6.2.
tar
.gz
tar
-zxvf nginx-1.6.2.
tar
.gz
cd
nginx-1.6.2 && .
/configure
--with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_gunzip_module
make
make
install
|
(2)安装PHP/PHP-FPM
PHP-FPM是FastCGI进程管理器,是PHP的一个补丁;
从上述的地址中分别下载PHP版和对PHP进行打PHP-FPM补丁:
1
2
3
4
|
wget http:
//cn2
.php.net
/get/php-5
.5.22.
tar
.gz
/from/this/mirror
-O php-5.5.22.
tar
.gz
tar
-zxvf php-5.5.22.
tar
.gz
cd
php-5.5.22 && .
/configure
--
enable
-fpm
make
&&
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
1
2
3
4
5
6
|
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
1
|
php-fpm &&
/usr/local/nginx/sbin/nginx
|
本文转自 bannerpei 51CTO博客,原文链接:http://blog.51cto.com/281816327/1620301,如需转载请自行联系原作者