centos7下nginx添加到自定義系統服務中提示Access denied


安裝好nginx后,添加到系統服務中

在/usr/lib/systemd/system下創建nginx.service文件內容如下:

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
 
[Service]
Type=forking
PIDFile=/your nginx pid file path/nginx.pid
ExecStartPre=/your nginx path/sbin/nginx -t -c /your nginx path/conf/nginx.conf
ExecStart=/your nginx path/sbin/nginx -c /your nginx path/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target

添加完之后,開啟服務

systemctl enable nginx.service

但是提示錯誤:Access denied

搜了一下原因,是SELinux造成的。解決方案有兩種:

一,

systemctl daemon-reexec

二,這種方法會存在安全隱患

setenforce 0

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM