1,在redhat5.5安装的nginx,直接
[root@wincenter ~]# yum install nginx
2,nginx需要支持php,必须通过php-fpm,这个在安装php时添加参数
–enable-fpm
3,之前安装了php,需要重新编译安装,添加参数
[root@wincenter php-5.6.8]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/sbin/apxs --with-mysql --enable-fpm
4,安装完毕后在/usr/local/php/etc目录下有个php-fpm.conf.default文件,直接copy一份出来
[root@wincenter etc]# cp php-fpm.conf.default php-fpm.conf
5,修改php-fpm.conf,去掉pid = run/php-fpm.pid的注释,以便启停
[global] ; Pid file ; Note: the default prefix is /usr/local/php/var ; Default Value: none pid = run/php-fpm.pid
6,启动php-fpm
[root@wincenter etc]# /usr/local/php/sbin/php-fpm
7,检查php-fpm
[root@wincenter etc]# ps -ef | grep php-fpm | grep -v grep root 8370 1 0 19:46 ? 00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf) nobody 8371 8370 1 19:46 ? 00:00:02 php-fpm: pool www nobody 8373 8370 1 19:46 ? 00:00:02 php-fpm: pool www
7,关闭php-fpm
[root@wincenter etc]# kill -INT `cat /usr/local/php/var/run/php-fpm.pid`
8,让nginx支持php,还需修改nginx的配置文件/etc/nginx/nginx.conf,将以下几行注释去掉
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; include fastcgi_params; }
9,重启nginx,servic nginx restart
10,创建测试文件
# vim /usr/share/nginx/html/index.php
11,在浏览器访问http://localhost/index.php
遇到问题:
1,yum install 时报错
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
解决方法:
rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
2,configure 时报错,这是因为同时添加了apache和nginx的SAPI,分别为apxs和fpm
You've configured multiple SAPIs to be build. You can build only one SAPI module and CLI binary at the same time.
解决方法:去掉apxs的配置参数
3,
error: xml2-config not found. Please check your libxml2 installation
缺少libxml2,安装即可
yum install libxml2 libxml2-devel sudo apt-get install libxml2-dev
3,
nginx: [emerg] bind() to 0.0.0.0:8081 failed (13: Permission denied)
SELinux导致的,添加端口,或者直接关闭即可
4,
[pool www]pm.max_spare_servers(0) must be a positive value failed topost process the configuration
修改php-fpm.conf文件内容
pm.start_servers=20 pm.min_spare_servers=5 pm.max_spare_servers=35
Leave a Reply