V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
wqsfree
V2EX  ›  Linux

nginx 启动脚本

  •  
  •   wqsfree · 2018-05-25 18:50:50 +08:00 · 1254 次点击
    这是一个创建于 2134 天前的主题,其中的信息可能已经有所发展或是发生改变。

    nginx 的启动脚本,nginx,nginx.conf, nginx.pid 请根据自己的路径进行修改,只需要修改这三个路径即可,放到 /etc/init.d/目录下,增加执行权限 chmod a+x /etc/init.d/nginx 开机自启动 chkconfig – add nginx,chkconfig nginx on

    文章出处地址 https://zhuopin.app/?p=54

    #!/bin/bash

    chkconfig: – 30 21

    description: http service.

    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=”/var/run/nginx/nginx.pid ” RETVAL=0 prog=” Nginx ”

    start() { echo -n $” Starting $prog: ” mkdir -p /dev/shm/nginx_temp daemon $NGINX_SBIN -c $NGINX_CONF RETVAL=$? echo return $RETVAL }

    stop() { echo -n $” Stopping $prog: ” killproc -p $NGINX_PID $NGINX_SBIN -TERM rm -rf /dev/shm/nginx_temp RETVAL=$? 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 return 0 }

    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 $REVAL

    julyclyde
        1
    julyclyde  
       2018-05-26 10:32:01 +08:00
    现在已经 systemd 时代了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2681 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 15:46 · PVG 23:46 · LAX 08:46 · JFK 11:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.