nginx自启动

创建脚本

cd /etc/init.d
vim start.sh

将以下内容复制到start.sh中并且保存退出

#!/bin/sh
#chkconfig:2345 80 90
#decription:auto_run

#logs_path log_path
='/usr/local/logs/autoStart.log'; #error information direct to the log exec 2>>$log_path; exec 1>>$log_path; #method for echo message to the log print(){ echo [`date +"%Y-%m-%d %T"`]: $1>>$log_path; } #main /usr/local/nginx/sbin/nginx; print "启动成功";

在/usr/local下创建logs

cd /usr/local
mkdir logs

添加可执行

chmod +x start.sh 
chkconfig --add start.sh 
原文地址:https://www.cnblogs.com/longchengruoxi/p/11451234.html