11. 06.

(3)增加网站用户
#  useradd hao32 -d /www/wwwroot/hao32.com -s /sbin/nologin
#  useradd linuxsense -d /www/wwwroot/linuxsense.org -s /sbin/nologin

如果参数-d后的路径本身就存在, 会提示
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
这并不影响,
#  chown -R hao32:hao32 /www/wwwroot/hao32.com
#  chown -R linuxsense:linuxsense /www/wwwroot/linuxsense


(5)创建一个要等会要使用的用户列表USER_LIST
# vi /usr/local/nginx/conf/vhosts/USER_LIST
格式如下
去掉-a -p -C -u -f等参数, 分表是本机php要使用的ip地址, 端口, 用户
注意, 如果有两个用户就要两行, 主要不要有空白行

-a 127.0.0.1 -p 8407 -C 20 -u hao32 -f
-a 127.0.0.1 -p 8408 -C 200 -u linuxsense -f

(6)制作php-cgi,nginx等启动脚本, 并加入系统服务

# vi /etc/init.d/php-cgi
# chmod 755 /etc/init.d/php-cgi

编辑php-cgi启动脚本, 加入以下代码:

#!/bin/bash
#
# PHP-FastCGI Control Script for Red Hat based Linux.
# Written by hao32
# chkconfig: 3 89 89
# description: PHP Fast-CGI

# PHP Users Settings
USER_INFO=”/usr/local/nginx/conf/vhosts/USER_LIST”

# Source Function Library
. /etc/init.d/functions

PHP_SPAWN=”/usr/local/php-fcgi/bin/spawn-fcgi”
PHP_SBIN=”/usr/local/php-fcgi/bin/php-cgi”
PHP_PID=”/usr/local/nginx/var/php-fcgi.pid”

RETVAL=0
prog=”PHP FastCGI”

mkdir -p /var/run/php-fcgi 2> /dev/null

start() {
echo -n $”Starting $prog: ”
cat $USER_INFO | while read list
do
daemon $PHP_SPAWN $list $PHP_SBIN
done
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
touch /var/lock/subsys/php-fcgi
fi
echo
return $RETVAL
}

stop() {
echo -n $”Stopping $prog: ”
killproc php-cgi
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
rm -f /var/lock/subsys/php-fcgi
fi
echo
return $RETVAL
}

restart() {
stop
echo -ne “Restart…\n”
sleep 3
start
}

case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $”Usage: $0 {start|stop|restart}”
RETVAL=1
esac

exit $RETVAL

# vi /etc/init.d/nginx
# chmod 755 /etc/init.d/nginx

编辑nginx启动脚本, 加入以下代码

#!/bin/bash
#
# Nginx Control Script for Red Hat based Linux.
# chkconfig: 3 90 90
# description: Nginx Web Server Control

# Source Function Library
. /etc/init.d/functions

# Nginx Settings
NGINX_SBIN=”/usr/local/nginx/sbin/nginx”
NGINX_CONF=”/usr/local/nginx/conf/nginx.conf”
NGINX_PID=”/usr/local/nginx/var/nginx.pid”

RETVAL=0
prog=”nginx”

mkdir -p /var/run/nginx 2> /dev/null

start() {
echo -n $”Starting $prog: ”
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
touch /var/lock/subsys/nginx
fi
echo
return $RETVAL
}

stop() {
echo -n $”Stopping $prog: ”
killproc -p $NGINX_PID $NGINX_SBIN -TERM
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
rm -f /var/lock/subsys/nginx
fi
echo
return $RETVAL
}

reload() {
echo -n $”Reloading $prog: ”
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}

restart() {
stop
start
}

configtest() {
$NGINX_SBIN -c $NGINX_CONF -t
exit
}

case “$1″ in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $”Usage: $0 {start|stop|reload|restart|configtest}”
RETVAL=1
esac

exit $RETVAL


作者: hao32 | 可以转载, 转载时务必以超链接形式标明文章原始出处和作者信息及版权声明
网址:http://www.hao32.com/webserver/47.html

Tags: ,

发表评论: