版本:nginx-1.4.0,php-5.4.13
nginx-1.4.0编译安装 php-5.4.13编译安装
—————————————–
a.创建主机pid文件
cd /usr/local/php/var/runtouch php-fpm-nodeA.pidtouch php-fpm-nodeB.pid |
cd /usr/local/php/etccp php-fpm.conf.default php-fpm-nodeA.conf#修改[global][www]pid = run/php-fpm-nodeA.pid error_log = log/php-fpm-nodeA.log user = www group = www listen = /tmp/php-cgi-nodeA.sockcp php-fpm.conf.default php-fpm-nodeB.conf#修改[global][www]pid = run/php-fpm-nodeB.pid error_log = log/php-fpm-nodeB.log user = www group = www listen = /tmp/php-cgi-nodeB.sock |
c.创建sock文件
touch /tmp/php-fpm-nodeA.socktouch /tmp/php-fpm-nodeB.sockchown www:www /tmp/php-fpm-nodeA.sockchown www:www /tmp/php-fpm-nodeB.sock |
d.编辑php-fpm启动脚本/etc/rc.d/init.d/php-fpm
prefix=/usr/local/phpexec_prefix=${prefix}vhost=$2php_fpm_BIN=${exec_prefix}/sbin/php-fpmphp_fpm_CONF=${prefix}/etc/php-fpm-$vhost.confphp_fpm_PID=${prefix}/var/run/php-fpm-$vhost.pidphp_opts="-d open_basedir=/WEB ROOT PATH/$vhost/:/tmp/ --fpm-config $php_fpm_CONF --pid $php_fpm_PID" |
e.启动php-fpm
/etc/rc.d/init.d/php-fpm start nodeA/etc/rc.d/init.d/php-fpm start nodeB |
参数 start|stop|force-quit|restart|reload (reload不关闭重新加载配置)
=============================
f.修改nginx.cnf,添加虚拟主机
server { listen 80; server_name nodeA.localhost; index index.php index.html; root /WEB ROOT PATH/nodeA/; location ~ \.php$ { fastcgi_pass unix:/tmp/php-cgi-nodeA.sock; fastcgi_index index.php; include fastcgi.conf; expires off; } location ~ ^.+\.(swf|spg|css|xml|js|jpg|gif|png|mp3)$ { expires 72h; } } server { listen 80; server_name nodeB.localhost; index index.php index.html; root /WEB ROOT PATH/nodeB/; location ~ \.php$ { fastcgi_pass unix:/tmp/php-cgi-nodeB.sock; fastcgi_index index.php; include fastcgi.conf; expires off; } location ~ ^.+\.(swf|spg|css|xml|js|jpg|gif|png|mp3)$ { expires 72h; } }