搜尋

首頁  >  問答  >  主體

大神幫忙檢查一下這個nginx.service檔案有沒有需要改動的地方?

在centos7.2上編譯安裝完nginx,需要寫一個nginx.service文件,以便可以使用systemctl enable nginx.service,這裡有個mysqld的範例http: //superuser.com/a/384670/577295
模仿寫了一個,但有些參數不確定正確與否,請大神幫檢查一下。

1

2

3

4

5

6

7

8

9

10

11

12

<code>    [Unit]

    Description=Nginx Server

    After=network.target

     

    [Service]

    ExecStart=/usr/local/nginx/sbin/nginx --defaults-file=/usr/local/nginx/conf/nginx.conf  --socket=/var/run/nginx/nginx.sock

    User=nginx

    Group=nginx

    WorkingDirectory=/usr

     

    [Install]

    WantedBy=multi-user.target</code>

問題:
1、有無需要改變的地方?
2、有沒有缺什麼?
3、--socket=/var/run/nginx/nginx.sock沒有這個文件,自己寫的話,裡面應該是什麼內容?

下面是編譯安裝的相關路徑:

1

2

3

4

5

6

<code>sed -e "s|%%PREFIX%%|/usr/local/nginx|" \

    -e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \

    -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \

    -e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \

    < man/nginx.8 > objs/nginx.8

make[1]: Leaving directory `/root/nginx-1.9.14'</code>

我想大声告诉你我想大声告诉你2861 天前549

全部回覆(2)我來回復

  • 世界只因有你

    世界只因有你2017-05-16 17:19:57

    我是新手,對於這個問題,我是這樣解決的。先yum安裝Nginx,然後查看Nginx的編譯選項,主要是關於目錄的選項。再自己下載原始碼,相關編譯選項設定成剛查看的,最後用編譯完的nginx執行檔取代yum安裝的執行檔。這樣就無需編寫那些服務腳本了。手機打字,亂亂的。

    回覆
    0
  • PHPz

    PHPz2017-05-16 17:19:57

    樓主不要生搬硬套
    nginx 沒有 --defaults-file 也沒有 --socket 參數
    不是隨便 cp *.service nginx.service 就能用的

    官方都已經給範例了
    https://www.nginx.com/resources/wiki/sta...

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    <code>[Unit]

    Description=The NGINX HTTP and reverse proxy server

    After=syslog.target network.target remote-fs.target nss-lookup.target

     

    [Service]

    Type=forking

    PIDFile=/run/nginx.pid

    ExecStartPre=/usr/sbin/nginx -t

    ExecStart=/usr/sbin/nginx

    ExecReload=/bin/kill -s HUP $MAINPID

    ExecStop=/bin/kill -s QUIT $MAINPID

    PrivateTmp=true

     

    [Install]

    WantedBy=multi-user.target</code>

    回覆
    0
  • 取消回覆