Nginx
open() ‘/run/nginx.pid’ 失敗 (13: Permission denied)
目前,我已經設置了一個 nextcloud 伺服器,
nginx
並使用sudo systemctl enable nginx.service
. 當我重新啟動時,我收到一條抱怨代理伺服器的錯誤消息,如果我查看一下sudo systemctl status nginx.service
,我會收到以下資訊:nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/etc/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Sat 2020-11-14 12:20:55 CET; 16min ago Nov 14 12:20:55 TORNAX-ARCH systemd[1]: Starting A high performance web server and a reverse proxy server... Nov 14 12:20:55 TORNAX-ARCH nginx[473]: 2020/11/14 12:20:55 [warn] 473#473: could not build optimal types_hash, you should increase either types_hash_max_size: 1024 or types_hash_bucket_si> Nov 14 12:20:55 TORNAX-ARCH nginx[473]: 2020/11/14 12:20:55 [emerg] 473#473: bind() to 192.168.178.35:443 failed (99: Unknown error) Nov 14 12:20:55 TORNAX-ARCH systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE Nov 14 12:20:55 TORNAX-ARCH systemd[1]: nginx.service: Failed with result 'exit-code'. Nov 14 12:20:55 TORNAX-ARCH systemd[1]: Failed to start A high performance web server and a reverse proxy server.
如果我跑步
nginx -t
,我會得到這個:2020/11/14 12:37:40 [warn] 68391#68391: could not build optimal types_hash, you should increase either types_hash_max_size: 1024 or types_hash_bucket_size: 64; ignoring types_hash_bucket_size nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 2020/11/14 12:37:40 [emerg] 68391#68391: open() "/run/nginx.pid" failed (13: Permission denied) nginx: configuration file /etc/nginx/nginx.conf test failed
當我正在尋找有關此
open() "/run/nginx.pid" failed (13: Permission denied)
錯誤的解決方案時,我只能獲得 docker + nginx 的解決方案,例如這些文章:
- https://stackoverflow.com/questions/57427162/nginx-emerg-open-var-run-nginx-pid-failed-13-permission-denied
- https://stackoverflow.com/questions/64393237/nginx-emerg-open-run-nginx-pid-failed-13-permission-denied
- https://dockerquestions.com/2020/10/16/nginx-emerg-open-run-nginx-pid-failed-13-permission-denied/
- https://github.com/Wonderfall/dockerfiles/issues/40
它在手動重新啟動服務後工作,
sudo systemctl restart nginx.service
但我仍然open() "/run/nginx.pid" failed (13: Permission denied)
在執行時得到nginx -t
。我做錯了什麼或者我能做些什麼來解決這個問題?
這可能是一個錯誤。“這種行為是一個已知的錯誤,由 nginx 和 systemd 之間的競爭條件引起。Systemd 期望在 nginx 有時間創建它之前填充 PID 文件。” https://www.cloudinsidr.com/content/heres-fix-nginx-error-failed-read-pid-file-linux/
sudo nginx -t
這個評論應該是一個答案。
Run nginx -t as root. This is a red herring. – Michael Hampton Nov 15 at 0:27