<td id="1e66k"></td>

      <p id="1e66k"><strong id="1e66k"><small id="1e66k"></small></strong></p>

      Centos8 Nginx 配置開機自動啟動

      Centos8 Nginx 配置開機自動啟動



      學習下載專區 【2021-01-16 14:43】


      第一步:創建 service文件

      vim /lib/systemd/system/nginx.service
      • /lib 與 /usr/lib 我這里配置時是一樣的,在那個文件夾配置都可以

      第二步:編寫 啟動腳本

      [Unit]
      
      Description=nginx service
      
      After=network.target
      
      [Service]
      
      Type=forking
      
      PIDFile=/home/app/nginx/log/nginx.pid
      
      ExecStart=/home/app/nginx/sbin/nginx
      
      ExecReload=/home/app/nginx/sbin/nginx -s reload
      
      ExecStop=/home/app/nginx/sbin/nginx -s stop
      
      PrivateTmp=true[Install]
      
      WantedBy=multi-user.target

      腳本介紹

      Description

      服務描述

      After

      如果該字段指定的 Unit 也要啟動,那么必須在當前 Unit 之前啟動

      Type=forking

      后臺運行

      PIDFile=/home/app/nginx/log/nginx.pid

      nginx.pid 文件需要在,nginx配置文件中查找。如果查不到,不配置此屬性也可以

      如果type是后臺運行,那么建議將此屬性加上。指定pid。

      ExecStart=/home/app/nginx/sbin/nginx

      啟動腳本

      ExecReload=/home/app/nginx/sbin/nginx -s reload

      重啟腳本

      ExecStop=/home/app/nginx/sbin/nginx -s stop

      停止腳本

      PrivateTmp=true

      是否使用私有tmp目錄

      WantedBy=multi-user.target

      運行級別下服務安裝的相關設置,可設置為多用戶,即系統運行級別為3

      第三步:保存退出,重新加載systemd

      systemctl daemon-reload

      重新加載,使 systemd生效

      第四步:驗證腳本

      # 查看服務狀態  systemctl status nginx.service
      # 停止服務      systemctl stop nginx.service
      # 啟動服務      systemctl start nginx.service
      # 重啟服務      systemctl restart nginx.service

      第五步:配置開機自啟

      #開啟開機自啟
      systemctl enable nginx.service
      #取消開機自啟
      systemctl disable nginx.service

      文件來源:https://www.cnblogs.com/easonchean/p/14199109.html


      友情鏈接:
      SQL數據庫修復專家
      • 關注微博
        聯系QQ
      • 二維碼
      • 掃一掃加關注

      ——信陽市速全網絡科技有限公司——

      版權所有:信陽市速全網絡科技有限公司

      豫ICP備19030104號-2

      日本不卡视频在线_H片国产在线观看播放免费_久久香蕉国产线看观看45_亚洲中文字幕精品无码中文