Nginx 开机自启动
Nginx 启动、停止、重启脚本配置
- 先停止Nginx
sudo kill `cat /usr/local/nginx/logs/nginx.pid
- 创建脚本
vi /etc/init.d/nginx
创建的文件输入以下内容:
#!/bin/bash
#
# nginx - this script starts and stops the nginx daemon
#
# 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 改变而进行修改
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx) ## 获取nginx 名称
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx