centos7 給nginx tengine 創建服務,並實現開機自啓

centos7 配置 nginx tengine 服務及自啓

  • 環境:

    • CentOS Linux release 7.6.1810 (Core)

      [root@localhost]# cat /etc/redhat-release
      CentOS Linux release 7.6.1810 (Core)
      
    • nginx爲yum安裝,源爲nginx官方源

      [root@localhost]# nginx -v
      nginx version: nginx/1.16.1
      
    • tengine是編譯安裝

      • 編譯參數:

        [root@localhost]# /usr/local/tengine/sbin/nginx -V
        Tengine version: Tengine/2.3.2
        nginx version: nginx/1.17.3
        built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
        built with OpenSSL 1.0.2k-fips  26 Jan 2017
        TLS SNI support enabled
        configure arguments: --prefix=/usr/local/tengine --with-http_stub_status_module --with-http_ssl_module
        
  • 自啓配置

    • 一、建立服務

      • 服務目錄: /usr/lib/systemd/system/

        cd /usr/lib/systemd/system/
        vim nginx.service
        
        --------------nginx.service------------------
        [Unit]
        Description=nginx - high performance web server
        Documentation=http://nginx.org/en/docs/
        After=network-online.target remote-fs.target nss-lookup.target
        Wants=network-online.target
        
        [Service]
        Type=forking
        PIDFile=/var/run/nginx.pid
        ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
        ExecReload=/bin/kill -s HUP $MAINPID
        ExecStop=/bin/kill -s TERM $MAINPID
        
        [Install]
        WantedBy=multi-user.target
        
    • 二、測試能不能起來

      systemctl start nginx
      
    • 三、開啓自啓(前提是第二部能通過)

      systemctl stop nginx
      systemctl enable nginx
      systemctl start nginx
      
  • 附 tengine 服務配置文件

    • 服務目錄: /usr/lib/systemd/system/

      cd /usr/lib/systemd/system/
      vim tengine.service
      
      --------------tengine.service------------------
      [Unit]
      Description=tengine(nginx) - high performance web server
      Documentation=https://tengine.taobao.org/documentation.html
      After=network-online.target remote-fs.target nss-lookup.target
      Wants=network-online.target
      
      [Service]
      Type=forking
      PIDFile=/usr/local/tengine/logs/nginx.pid
      ExecStart=/usr/local/tengine/sbin/nginx -c /usr/local/tengine/conf/nginx.conf
      ExecReload=/usr/local/tengine/sbin/nginx -s reload
      ExecStop=/usr/local/tengine/sbin/nginx -s quit
      PrivateTmp=true
      
      [Install]
      WantedBy=multi-user.target
      
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章