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

    作者:陈耿聪 —— 夕狱

    出处:https://www.cnblogs.com/CGCong/

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    C# 获取 PC 序列号
    C# 获取进程退出代码
    PHP mail() 函数
    PHP ezmlm_hash() 函数
    PHP Mail 函数
    PHP libxml_clear_errors() 函数
    PHP setrawcookie() 函数
    创建用户
    [FJOI2018]领导集团问题
    C# 获取进程退出代码
  • 原文地址:https://www.cnblogs.com/CGCong/p/13809633.html
Copyright © 2011-2022 走看看