Ubuntu Nginx 开机自启动
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for nginx webserver on Debian. Place
in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate
command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx'### BEGIN INIT INFO
#
Provides:
nginx
#
Required-Start:
$all
#
Required-Stop:
$all
#
Default-Start:
2 3 4 5
#
Default-Stop:
0 1 6
# Short-Description: starts the nginx web server
#
Description:
starts nginx using start-stop-daemon
### END INIT INFO# Author: licess
# website: http://lnmp.orgPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=nginx
NGINX_BIN=/data/apps/nginx/sbin/$NAMECONFIGFILE=/data/apps/nginx/conf/$NAME.conf
PIDFILE=/data/logs/nginx/$NAME.pidcase "$1" in
start)
echo -n "Starting $NAME... "if netstat -tnpl | grep -q nginx;then
echo "$NAME (pid `pidof $NAME`) already running."
exit 1
fi$NGINX_BIN -c $CONFIGFILE
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;stop)
echo -n "Stoping $NAME... "if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit 1
fi$NGINX_BIN -s stop
if [ "$?" != 0 ] ; then
echo " failed. Use force-quit"
exit 1
else
echo " done"
fi
;;status)
if netstat -tnpl | grep -q nginx; then
PID=`pidof nginx`
echo "$NAME (pid $PID) is running..."
else
echo "$NAME is stopped"
exit 0
fi
;;force-quit)
echo -n "Terminating $NAME... "if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit 1
fikill `pidof $NAME`
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;restart)
$0 stop
sleep 1
$0 start
;;reload)
echo -n "Reload service $NAME... "if netstat -tnpl | grep -q nginx; then
$NGINX_BIN -s reload
echo " done"
else
echo "$NAME is not running, can't reload."
exit 1
fi
;;configtest)
echo -n "Test $NAME configure files... "$NGINX_BIN -t
;;*)
echo "Usage: $0
{start|stop|force-quit|restart|reload|status|configtest}"
exit 1
;;esac
# chmod +x /etc/init.d/nginx
# sysv-rc-conf
上次忘记说了,这次补一下 这个【1\2\3\4\5\0\6\S】启动选项最后有个【 S
】的选项,他的意思表示开机后就会运行的服务。
运行级别说明:
S 表示开机后就会运行的服务
0 表示关机
1 表示单用户模式
(类似windows的安全模式)
2 表示无网络服务的多用户模式
3 表示多用户模式
4 系统预留(暂没使用)
5 表示多用户图形模式
6 表示重启
打X 表示开启该服务。
sysv-rc-conf nginx on
service nginx -s reload | stop | restart | start
Ubuntu Nginx 开机自启动的更多相关文章
- centos7.x设置nginx开机自启动
设置nginx开机自启动(centos7.x) 第一步:进入到/lib/systemd/system/目录 [root@iz2z init.d]# cd /lib/systemd/system/ 第二 ...
- Centos下安装并设置nginx开机自启动
一.在centos环境下安装下载并安装nginx,由于nginx需要依赖一些环境才能安装,主要依赖g++.gcc.openssl-devel.pcre-devel和zlib-devel这些环境,首先得 ...
- 设置Apache(httpd)和Nginx 开机自启动
方法1: 进入目录: vi /etc/rc.d/rc.local #设置apache 和 nginx 开机自启动/usr/sbin/apachectl start/usr/sbin/nginx s ...
- centos7下安装、配置Nginx、设置Nginx开机自启动
测试环境: [root@centos-linux ~]# cat /etc/redhat-releaseCentOS Linux release 7.6.1810 (Core) [root@cento ...
- Ubuntu14.04配置nginx开机自启动项
原文: https://www.jianshu.com/p/2e03255cfabb ubuntu配置开机自动启动服务 ---------------------------------------- ...
- Linux(CentOS)系统下设置nginx开机自启动
Nginx 是一个很强大的高性能Web和反向代理服务器.下面介绍在linux下安装后,如何设置开机自启动.首先,在linux系统的/etc/init.d/目录下创建nginx文件,使用如下命令:vi ...
- 设置Nginx开机自启动
Nginx 是一个很强大的高性能Web和反向代理服务器.虽然使用命令行可以对nginx进行各种操作,比如启动等,但是还是根据不太方便.下面介绍在linux下安装后,如何设置开机自启动. 首先,在lin ...
- Centos8配置Nginx开机自启动
第一步:创建service文件,并编辑(可理解为开机时自动启动Nginx的脚本服务文件) vim /lib/systemd/system/nginx.service /lib 与 /usr/lib 里 ...
- 十一、设置Nginx开机自启动
一.创建nginx.service文件 [root@svr7 ~]# vim /lib/systemd/system/nginx.service [Unit]Description=nginx ser ...
随机推荐
- windows下tensorflow的安装
一.直接python安装 1.CPU版本: pip3 install --upgrade tensorflow 2.GPU版本:pip3 install --upgrade tensorflow-gp ...
- APP加固技术历程及未来级别方案:虚机源码保护
传统App加固技术,前后经历了四代技术变更,保护级别每一代都有所提升,但其固有的安全缺陷和兼容性问题始终未能得到解决.而下一代加固技术-虚机源码保护,适用代码类型更广泛,App保护级别更高,兼容性更强 ...
- 08-图8 How Long Does It Take
原题: Given the relations of all the activities of a project, you are supposed to find the earliest co ...
- Mysql--数据的操作
1.插入数据 1.1 插入完整数据记录 语法1: 例子: 语法2: 例子: 1.2 插入数据记录一部分 语法: 例子: 1.3 插入多条数据记录 1.插入多条完整的数据 语法: 例子: 插入多条部 ...
- Ceph luminous 安装配置
Ceph luminous 安装配置 #环境centos7 , Ceph V12 openstack pike 与 ceph 集成 http://www.cnblogs.com/elvi/p/7897 ...
- mysql 各数据类型的 大小及长度
数字型 类型 大小 范围(有符号) 范围(无符号) 用途 TINYINT 1 字节 (-128,127) (0,255) 小整数值 SMALLINT 2 字节 (-32 768,32 767) (0, ...
- yii2数据条件查询-where专题
条件查询 $customers = Customer::find()->where($cond)->all(); $cond就是我们所谓的条件,条件的写法也根据查询数据的不同存在差异,那么 ...
- 计算rem
(function(doc, win) { var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? ' ...
- FastDFS迁移步骤
1.在新的机器上安装FastDFS 2.将新的storage接到老的tracker机器上,用来同步数据(/usr/local/fastdfs/bin/fdfs_storaged) 数据同步完成后,需要 ...
- 分享一波eclipse常用快捷键
Eclipse快捷键 一个Eclipse骨灰级开发者总结了他认为最有用但又不太为人所知的快捷键组合.通过这些组合可以更加容易的浏览源代码,使得整体的开发效率和质量得到提升. 1. ctrl+shift ...