执行以下就可以实现nginx的自启动和重启 重载等控制了
ln -s /etc/init.d/nginx /etc/rc2.d/S80nginx
ln -s /etc/init.d/nginx /etc/rc3.d/S80nginx
cat /etc/init.d/nginx
#!/bin/sh
# description: Startup and shutdown script for nginx
NGINX_DIR=/usr/local/nginx
export NGINX_DIR
case $1 in
'start' )
echo "Starting nginx..."
$NGINX_DIR/sbin/nginx &
;;
'reload' )
echo "Reload nginx configuration..."
#kill -HUP `cat $NGINX_DIR/logs/nginx.pid`
kill -HUP `cat /home/nginx/nginx.pid`
;;
'stop' )
echo "Stopping nginx..."
#kill -15 `cat $NGINX_DIR/logs/nginx.pid`
kill -15 `cat /home/nginx/nginx.pid`
;;
'list' )
ps aux | egrep '(PID|nginx)'
;;
'testconfig' )
$NGINX_DIR/sbin/nginx -t
;;
*)
echo "usage: `basename $0` {start|reload|stop|list|testconfig}"
esac
阅读(2378) | 评论(0) | 转发(0) |