当前位置 主页 > 服务器问题 > nginx问题汇总 >

    Nginx配合Apache或Tomcat的动静分离基本配置实例(2)

    栏目:nginx问题汇总 时间:2018-11-30 16:34

    #编写nginx启动、停止、重启等SysV管理脚本,方便使用

    [root@localhost ~]# vi /etc/init.d/nginx
    #!/bin/bash# chkconfig: 345 99 20# description: Nginx servicecontrol scriptPROG="/usr/local/nginx/sbin/nginx"PIDF="/usr/local/nginx/logs/nginx.pid"case "$1" instart)$PROGecho "Nginx servicestart success.";;stop)kill -s QUIT $(cat $PIDF)echo "Nginx service stopsuccess.";;restart)$0 stop$0 start;;reload)kill -s HUP $(cat $PIDF)echo"reload Nginx configsuccess.";;*)echo "Usage: $0{start|stop|restart|reload}"exit 1esac
    [root@localhost ~]# chmod +x /etc/init.d/nginx[root@localhost ~]# service nginx restart[root@localhost ~]# chkconfig --add nginx[root@localhost ~]# chkconfig nginx on