zoukankan      html  css  js  c++  java
  • nginx开机自启动

     # 创建服务文件

    vim /usr/lib/systemd/system/nginx.service

    nginx.service脚本内容如下:

    [Unit]     #服务的说明
      Description=nginx    #描述服务
      After=network.target  #描述服务类别
    
    [Service]   #服务运行参数的设置
      Type=forking   #是后台运行的形式
      ExecStart=/usr/local/nginx/sbin/nginx   #为服务的具体运行命令
      ExecReload=/bin/kill -s HUP $MAINPID   #为重启命令
      ExecStop=/bin/kill -s QUIT $MAINPID   #为停止命令
      PrivateTmp=true   # True表示给服务分配独立的临时空间
    
    # 注意:启动、重启、停止命令全部要求使用绝对路径
    
    [Install]   # 服务安装的相关设置,可设置为多用户
      WantedBy=multi-user.target

    # 授权

    chmod -R 755 /usr/lib/systemd/system/nginx.service

    # 重新加载

    systemctl daemon-reload

    # 开启开机自启

    systemctl enable nginx.service

    # 重启服务器验证

    reboot

    # 启动nginx

    systemctl start nginx.service

     # 停止nginx

    systemctl stop nginx.service

    # 重启nginx

    systemctl restart nginx.service
  • 相关阅读:
    回答自己的提问
    <构建之法>13——17章的读后感
    <构建之法>10,11,12章的读后感
    <构建之法>8,9,10章的读后感
    作业5.2
    【作业报告】作业5 四则运算 测试与封装 5.1 改进版
    作业 5.1
    阅读
    做汉堡
    阅读《构建之法》
  • 原文地址:https://www.cnblogs.com/WorldOfLin/p/14530123.html
Copyright © 2011-2022 走看看