nginx 启动脚本

2018-05-25 18:50:50 +08:00
 wqsfree

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

1277 次点击
所在节点    Linux
1 条回复
julyclyde
2018-05-26 10:32:01 +08:00
现在已经 systemd 时代了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/457820

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX