大网数据广告活动
服务器运维问答

open() "/run/nginx.pid" failed (13: Permission denied)

· 52CE 我爱测

Currently, I've set up a nextcloud server with nginx and I enabled it with sudo systemctl enable nginx.service . When I'm rebooting, than I'm getting an error message which complains about a proxy server and if I take a look into…

问题原文

原帖链接 · TornaxO7 · CC BY-SA 4.0

Currently, I've set up a nextcloud server with nginx and I enabled it with sudo systemctl enable nginx.service. When I'm rebooting, than I'm getting an error message which complains about a proxy server and if I take a look into sudo systemctl status nginx.service, than I'm getting this:

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.

If I run nginx -t than I'm getting this:

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

When I'm looking for a solution about this open() "/run/nginx.pid" failed (13: Permission denied) error, than I'm only getting solutions for docker + nginx like these posts:

It works after restarting manually the service with sudo systemctl restart nginx.service but I'm still getting the open() "/run/nginx.pid" failed (13: Permission denied) when I'm running nginx -t.

What am I doing wrong or what can I do in order to solve this problem?

已采纳解答

原帖链接 · Michael S · CC BY-SA 4.0

It may be a bug. "This behavior is a known bug, caused by a race condition between nginx and systemd. Systemd is expecting the PID file to be populated before nginx had the time to create it." https://www.cloudinsidr.com/content/heres-fix-nginx-error-failed-read-pid-file-linux/

EDIT

In any case, if the website is down again, here are the steps to fix it:

Step-By-Step guide

  1. Create a directory named nginx.service.d in /etc/systemd/system/:
mkdir -p /etc/systemd/system/nginx.service.d
  1. Add the following to /etc/systemd/system/nginx.service.d/override.conf:
[Service]
ExecStartPost=/bin/sleep 0.1
  1. Reload systemd manager configuration:
systemctl daemon-reload
  1. Restart NGINX:
systemctl restart nginx

Copy + Paste commands above

mkdir -p /etc/systemd/system/nginx.service.d
echo "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf
systemctl daemon-reload
systemctl restart nginx

Link to bug report

https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1581864

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-11-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。