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/

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

  • 相关阅读:
    volatile 关键字介绍
    hystrix 线程数,超时时间设置测试
    idea git tag 管理
    wget 认知及常用命令【转载】
    yum 认知及使用
    zuul 性能分析
    java 内存分析
    eureka-8-Eureka 的健康检查
    eureka-7-多网卡下的ip选择
    鼠标拖动div宽/高值增加与减小
  • 原文地址:https://www.cnblogs.com/CGCong/p/13809633.html
Copyright © 2011-2022 走看看