2.配置nginx支持php文件
vim /usr/local/nginx/conf/nginx.conf
修改用户为nginx:
改:2 #user nobody;
为:3 user www;
启用PHP支持,参照如下做修改,注意与原配置文件格式对齐
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
3.配置启动脚本
将nginx命令生成软链接到bin目录:
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
生成启动脚本,vim /etc/init.d/nginx。
!/bin/bash
chkconfig: - 99 2
description: Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$PROG
;;
stop)
kill -3 $(cat $PIDF)
;;
restart)
$0 stop &> /dev/null
if [ $? -ne 0 ] ; then continue ; fi
$0 start
;;
reload)
kill -1 $(cat $PIDF)
;;
*)
echo "Userage: $0 { start | stop | restart | reload }"
exit 1
esac
exit 0
给予执行权限,加入开机启动
chmod +x /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
启动命令
nginx 或者 service nginx start