nginx开机启动

Posted 网络终结者

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx开机启动相关的知识,希望对你有一定的参考价值。

#! /bin/bash
# chkconfig: - 85 15

DAEMON=/usr/local/nginx/sbin/nginx
CONFIGFILE=/usr/local/nginx/conf/nginx.conf
PIDFILE=/usr/local/nginx/nginx.pid


do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
$DAEMON -s stop || echo -n "nginx not running"
}
do_reload() {
$DAEMON -s reload || echo -n "nginx can‘t reload"
}
case "$1" in
start)
echo -n "Starting  nginx"
do_start
echo "."
;;
stop)
echo -n "Stopping  nginx "
do_stop
echo "."
;;
reload)
echo -n "Reloading nginx"
do_reload
echo "."
;;
restart)
echo -n "Restarting nginx"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
chmod 755 /etc/init.d/nginx

chkconfig --add /etc/init.d/nginx

chkconfig nginx on

 

以上是关于nginx开机启动的主要内容,如果未能解决你的问题,请参考以下文章

Nginx——Nginx启动报错Job for nginx.service failed because the control process exited with error code(代码片段

Linux配置Nginx,MySql,php-fpm开机启动的方法

window 怎么样让nginx开机自启动

WinSW(Windows service wrapper)开机自启动nginx配置

nginx设置开机启动

如何将Nginx注册为系统服务,开机自启动。