(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:
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的一个补丁;
http://php-fpm.org/download/
http://php.net/downloads.php
从上述的地址中分别下载PHP版和对PHP进行打PHP-FPM补丁:
1234 | 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
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 |