Nginx 启动脚本
1、vim /etc/init.d/nginx
#!/bin/bash# chkconfig: - 30 21# description: http service.# Source Function Library. /etc/init.d/functions# Nginx SettingsNGINX_SBIN="/usr/local/nginx/sbin/nginx"NGINX_CONF="/usr/local/nginx/conf/nginx.conf"NGINX_PID="/usr/local/nginx/logs/nginx.pid"RETVAL=0prog="Nginx"start() {echo -n $"Starting $prog: "mkdir -p /dev/shm/nginx_tempdaemon $NGINX_SBIN -c $NGINX_CONFRETVAL=$?echoreturn $RETVAL}stop() {echo -n $"Stopping $prog: "killproc -p $NGINX_PID $NGINX_SBIN -TERMrm -rf /dev/shm/nginx_tempRETVAL=$?echoreturn $RETVAL}reload(){echo -n $"Reloading $prog: "killproc -p $NGINX_PID $NGINX_SBIN -HUPRETVAL=$?echoreturn $RETVAL}restart(){stopstart}configtest(){$NGINX_SBIN -c $NGINX_CONF -treturn 0}case "$1" instart)start;;stop)stop;;reload)reload;;restart)restart;;configtest)configtest;;*)echo $"Usage: $0 {start|stop|reload|restart|configtest}"RETVAL=1esacexit $RETVAL
3、加入chkconfig:chkconfig --add nginx
4、设置开机自启:chkconfig nginx on