Nginx开机自启与脚本配置

本文介绍了如何在Centos6和Centos7系统中配置Nginx开机自启动,包括添加启动脚本,赋予执行权限,并通过chkconfig命令设置自启。同时,提供了一个用于按日期切割和清理Nginx日志的脚本,以保留30天的日志记录。
摘要由CSDN通过智能技术生成

 亲测说明: Centos6下运行没问题.Centos7下配置完成启动没问题,停止不行(暂未处理)

1.添加nginx启动脚本

[root@localhost ~]# vim /etc/init.d/nginx
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
#              It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/webserver/nginx/sbin/nginx    #改为你的ngxin安装目录下启动文件位置
nginx_config=/usr/local/webserver/nginx/conf/nginx.conf #改为你的ngxin的配置文件位置
nginx_pid=/usr/local/webserver/nginx/nginx.pid #改为你的nginx进程所在的位置
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值