更新時間:2021-07-16 來源:黑馬程序員 瀏覽量:
把Nginx應用服務設置成為系統(tǒng)服務,方便對Nginx服務的啟動和停止等相關操作,具體實現(xiàn)步驟:
(1) 在/usr/lib/systemd/system目錄下添加nginx.service,內容如下:
vim /usr/lib/systemd/system/nginx.service
[Unit] Description=nginx web service Documentation=http://nginx.org/en/docs/ After=network.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s stop PrivateTmp=true [Install] WantedBy=default.target
(2)添加完成后如果權限有問題需要進行權限設置
chmod 755 /usr/lib/systemd/system/nginx.service
(3)使用系統(tǒng)命令來操作Nginx服務
啟動: systemctl start nginx 停止: systemctl stop nginx 重啟: systemctl restart nginx 重新加載配置文件: systemctl reload nginx 查看nginx狀態(tài): systemctl status nginx 開機啟動: systemctl enable nginx
將本頁面鏈接http://409rqu1.cn/news/20210716/172908.html發(fā)送給QQ:2217622915,免費獲取上面課程全套視頻、筆記和源碼。
猜你喜歡: