[root@localhost ~]# vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target [Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
#EnvironmentFile=/etc/sysconfig/rdisc
#ExecStart=/sbin/rdisc $RDISCOPTS [Install]
WantedBy=multi-user.target

 

[Unit]:服务的说明
Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
[Install]运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3

  

 
# 设置开机启动
[root@localhost ~]# systemctl enable nginx
 
# 停止开机自动启动
[root@localhost ~]# systemctl disable nginx
 
# 启动nginx服务
[root@localhost ~]# systemctl start nginx
 
# 查看服务当前状态
[root@localhost ~]# systemctl status nginx
 
# 重启nginx服务
[root@localhost ~]# systemctl restart nginx.service
 
 
# 查看所有已经启动的服务
[root@localhost ~]# systemctl list-units --type=service

centos7 nginx 启动脚本的更多相关文章

  1. CentOS7 nginx启动脚本

    vi /lib/systemd/system/nginx.service [Unit] Description=nginx After=network.target [Service] Type=fo ...

  2. linux nginx 启动脚本

    linux nginx 启动脚本 [root@webtest76 ~]# vi /etc/init.d/nginx #!/bin/bash # nginx Startup script for the ...

  3. Nginx 启动脚本/重启脚本

    第一步先运行命令关闭nginx sudo kill `cat /usr/local/nginx/logs/nginx.pid` 第二步 vi /etc/init.d/nginx 输入以下内容 #!/b ...

  4. nginx启动脚本,手动编辑

    nginx启动脚本,手动编辑 #! /bin/bash # chkconfig: - # description: nginx service XDIR=/www/server/nginx DESC= ...

  5. centos LNMP第一部分环境搭建 LAMP LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/php/{p.conf.default,p.conf} php运行方式SAPI介绍 第二十三节课

    centos  LNMP第一部分环境搭建 LAMP安装先后顺序  LNMP安装先后顺序 php安装 安装nginx  编写nginx启动脚本   懒汉模式  mv   /usr/local/php/{ ...

  6. Nginx 启动脚本

    Nginx 启动脚本 1.vim /etc/init.d/nginx #!/bin/bash # chkconfig: - 30 21 # description: http service. # S ...

  7. LNMP 1.4 nginx启动脚本和配置文件

    编写Nginx启动脚本,写入下面这段,授权755 vim /etc/init.d/nginx #!/bin/bash # chkconfig: - # description: http servic ...

  8. shell脚本之nginx启动脚本、统计日志字段、for循环实战、跳板机

    1.NGINX启动脚本 #!/bin/bash # chkconfig: 235 32 62 # description: nginx [ -f /etc/init.d/functions ] &am ...

  9. nginx启动脚本和配置文件

    1.编写Nginx启动脚本,并加入系统服务 vim /etc/init.d/nginx并在其中写入如下内容:#!/bin/bash# chkconfig: - 30 21# description: ...

随机推荐

  1. MySQL快速回顾:计算字段与函数

    9.1 计算字段 存储在数据库表中的数据一般不是应用程序所需要的格式.比如: 如果想要在一个字段中既显示公司名,又显示公式的地址,但这两个信息一般包含在不同的表列中. 城市.州和邮政编码存储在不同的列 ...

  2. C#实现把查询出的Table作为参数更新到数据库

    1.ImportData主方法 把传入为object数组类型,按照下标取出对应的参数,此处为Table和Username public object[] ImportData(object[] Par ...

  3. Go的内存对齐和指针运算详解和实践

    uintptr 和 unsafe普及 uintptr 在Go的源码中uintptr的定义如下: /* uintptr is an integer type that is large enough t ...

  4. C#反射与特性(八):反射操作的示例大全

    目录 1,InvokeMember 1.1 InvokeMember 参数 1.2 实践使用 InvokeMember 和成员的重载方法 微信平台,此文仅授权<NCC 开源社区>订阅号发布 ...

  5. bfs + 路径输出

    You are given two pots, having the volume of A and B liters respectively. The following operations c ...

  6. python中常⽤的excel模块库

    python中常用的excel模块库&安装方法 openpyxl openpyxl是⼀个Python库,用于读取/写⼊Excel 2010 xlsx / xlsm / xltx / xltm⽂ ...

  7. spring Cloud-eureka的保护模式

    eureka的首页出现以下警告 EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY'RE NOT. REN ...

  8. # 团队项目-Beta冲刺2(七个小矮人)

    团队项目-Beta冲刺2(七个小矮人) 一.格式描述 这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/GeographicInformationScien ...

  9. 使用FileZilla Pro S3协议访问七牛云对象存储

    偶然发现FileZilla还有Pro版本,主要是比免费版多了一些协议支持,也偶然发现七牛云支持了S3协议接口,这样刚好弥补了其没有FTP的不足,于是找官方文档,折腾一下,使用FileZilla Pro ...

  10. selenium,统计某分支下有多少个同类子分支的方法(用于循环获取同类型子分支属性值)

    利用selenium自动化统计微博阅读数 查看微博阅读数的元素路径 微博列表中第一条微博的元素路径“//*[@id="Pl_Official_MyProfileFeed__20"] ...