zoukankan      html  css  js  c++  java
  • centos7 nginx 启动脚本

    [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
  • 相关阅读:
    jmeter测试mysql数据库之JDBC请求
    接口测试浅谈
    python import xxx 与 from xxx import xx 模块引入的区别
    交互模式下测试python代码及变量的四则运算
    python入门之一python安装及程序运行
    zabbix命令之:zabbix_get命令
    snmpwalk工具使用
    zabbix基础知识
    Centos7.5 rpm安装zabbix_agent4.0.3
    mysql常用命令
  • 原文地址:https://www.cnblogs.com/lmx1002/p/9850188.html
Copyright © 2011-2022 走看看