目前,我已经设置了一个 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
。
我做错了什么或者我能做些什么来解决这个问题?
sudo nginx -t
这个评论应该是一个答案。
Run nginx -t as root. This is a red herring. – Michael Hampton Nov 15 at 0:27
这可能是一个错误。“这种行为是一个已知的错误,由 nginx 和 systemd 之间的竞争条件引起。Systemd 期望在 nginx 有时间创建它之前填充 PID 文件。” https://www.cloudinsidr.com/content/heres-fix-nginx-error-failed-read-pid-file-linux/