启动脚本
第一步
先运行命令关闭nginx
sudo kill `cat /usr/local/nginx/logs/nginx.pid`
第二步
vi /etc/init.d/nginx
输入以下内容
Python代码 收藏代码
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
保存退出
第三步
chmod 777 /etc/init.d/nginx
第四步
/sbin/chkconfig nginx on
检查一下
sudo /sbin/chkc
windows下配置nginx开机自动启动_计算机软件及应用_IT/计算机_专业资料。资源分享 编程语言 w e b 前端 w e b 服务器 操作系统 数据库应用 柳明的博客 资源...
linux+nginx开启自动启动_计算机软件及应用_IT/计算机_专业资料。nginx开机启动设置Linux+Nginx 开机启动配置 vi /etc/init.d/nginx #!/bin/bash # nginx ...
nginx开机启动_计算机软件及应用_IT/计算机_专业资料。配置nginx开机自动启动的脚本Nginx开机自动启动 vi /etc/init.d/nginx #!/bin/bash # nginx Startup ...
一、Tomcat 开机启动 linux 下配置完 tomcat 后,要想 tomcat 开机自动启动的话...同样的修改了 nginx 的配置文件 nginx.conf,也可以使用上面的命令重新加载新的...
让Nginx作为Windows服务开机自启动_计算机软件及应用_IT/计算机_专业资料。让 Nginx 作为 Windows 服务开机自启动二种方法: 第一种方法: 1. 安装相应的.NET ...
nginx开机启动_电脑基础知识_IT/计算机_专业资料 暂无评价0人阅读0次下载举报文档 nginx开机启动_电脑基础知识_IT/计算机_专业资料。nginx配置篇...
开机自动加载nginx_IT/计算机_专业资料。开机加载nginx今日推荐 ... nginx启动脚本 3页 1下载券 nginx 启动 停止 关闭 2页 1下载券 Tomcat + ...
设置nginx和php-fpm开机启动脚本_计算机软件及应用_IT/计算机_专业资料。这是一天的成果,这样做就可以不用每次都自己用命令去启动了...
nginx开机自动启动 2页 免费 nginx 启动 停止 关闭 2页 1下载券 nginx开机...#!/bin/bash # nginx Startup script for the Nginx HTTP Server # this ...
(开机自动启动) 添加 Nginx 为系统服务(开机自动启动) chkconfig --add mysql chkconfig mysql on 启动 Mysql service mysql start 安装 Nginx 安装 Nginx 所需的...
热门文档