導(dǎo)語
經(jīng)過編譯安裝以及解決問題,Nginx 已經(jīng)運行正常,但是此時 Nginx 并沒有添加進(jìn)系統(tǒng)服務(wù)。接下來會將 Nginx 添加進(jìn)系統(tǒng)服務(wù)并且設(shè)置開機啟動。
查看服務(wù)
首先查看 Nginx 的服務(wù)狀態(tài),輸入 systemctl status nginx,結(jié)果如下
沒有找到相關(guān)的服務(wù),下一步就是添加系統(tǒng)服務(wù)。
添加系統(tǒng)服務(wù)
在 /usr/lib/systemd/system 目錄中添加 nginx.service,根據(jù)實際情況進(jìn)行修改,詳細(xì)解析可查看下方參考資料中的文章。內(nèi)容如下
[Unit]Description=nginx - high performance web serverDocumentation=http://nginx.org/en/docs/After=network.target remote-fs.target nss-lookup.target [Service]Type=forkingPIDFile=/usr/local/nginx/logs/nginx.pidExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.confExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=true [Install]WantedBy=multi-user.target
添加完成后再來看下
設(shè)置開機自動啟動
首先測試一下,重啟然后來查看 Nginx 服務(wù)
確實沒有啟動。輸入 systemctl start nginx 啟動
可以使用 systemctl 啟動,說明之前添加的 nginx.service 沒有問題。然后輸入 systemctl enable nginx 設(shè)置開機啟動
最后重啟檢查下是否設(shè)置成功
沒有問題,到此關(guān)于 Nginx 的編譯安裝完成,接下來是 PHP 的安裝。
新聞熱點
疑難解答
圖片精選