zoukankan      html  css  js  c++  java
  • [转]centos7.2 下 nginx 开机启动

    1.在系统服务目录里创建nginx.service文件

    vi /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
      
    [Install]
    WantedBy=multi-user.target

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

    :wq   保存退出。

    2.设置开机启动

        
    systemctl enable nginx.service

    3.其他命令

    启动nginx服务

    systemctl start nginx.service

    设置开机自启动

    systemctl enable nginx.service

    停止开机自启动

    systemctl disable nginx.service

    查看服务当前状态

    systemctl status nginx.service

    重新启动服务

    systemctl restart nginx.service 

    查看所有已启动的服务

    systemctl list-units --type=service
  • 相关阅读:
    mysql慢日志设置
    CURL模拟登陆
    违法图片检测
    PHP取二进制文件头快速判断文件类型
    重写session
    mysql处理高并发,防止库存超卖
    mysql中使用update select
    PHP中使用Luhn算法校验信用卡及借记卡卡号
    红包算法
    DIV当textarea使用,在聚焦的时候将光标移动到内容的末尾
  • 原文地址:https://www.cnblogs.com/zhangzhijian/p/10688649.html
Copyright © 2011-2022 走看看