脚本名称 nginx , 需要将该脚本复制到 /etc/init.d 并执行以下命令chmod +x nginxchkconfig --add nginx此方法仅限红帽系列的Linux,包括CentOS nginx #!/bin/sh # chkconfig: 345 86 14 # description: Startup and shutdown script for nginx NGINX_DIR=/opt/ngx 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` ;; 'stop' ) echo "Stopping nginx..." kill -15 `cat $NGINX_DIR/logs/nginx.pid` ;; 'list' ) ps aux | egrep '(PID|nginx)' ;; 'testconfig' ) $NGINX_DIR/sbin/nginx -t ;; *) echo "usage: `basename $0` {start|reload|stop|list|testconfig}" esac (责任编辑:IT) |