私はArch Linuxを実行しています。
sudo systemctl start nginx.service
私の日記に次のようなメッセージが出ました。
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2019-05-15 11:17:03 BST; 45s ago
Process: 1542 ExecStart=/usr/bin/nginx -g pid /run/nginx.pid; error_log stderr; (code=exited, status=1/FAILURE)
May 15 11:17:03 systemd[1]: Starting A high performance web server and a reverse proxy server...
May 15 11:17:03 nginx[1542]: 2019/05/15 11:17:03 [emerg] 1542#1542: a duplicate listen 0.0.0.0:80 in /etc/nginx/nginx.conf:42
May 15 11:17:03 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
May 15 11:17:03 systemd[1]: nginx.service: Failed with result 'exit-code'.
May 15 11:17:03 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
ここではエラーを理解していません。どうすれば解決できますか?
修正する
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2019-05-15 11:36:36 BST; 9s ago
Process: 1667 ExecStart=/usr/bin/nginx -g pid /run/nginx.pid; error_log stderr; (code=exited, status=1/FAILURE)
May 15 11:36:36 systemd[1]: Starting A high performance web server and a reverse proxy server...
May 15 11:36:36 nginx[1667]: 2019/05/15 11:36:36 [emerg] 1667#1667: getpwnam("www-data") failed in /etc/nginx/nginx.conf:3
May 15 11:36:36 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
May 15 11:36:36 systemd[1]: nginx.service: Failed with result 'exit-code'.
May 15 11:36:36 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
答え1
ポート80でリッスンしている他のエントリがあります。次の行を確認してください。
duplicate listen 0.0.0.0:80
どの PID が聞いているかを確認するには、次の手順を試してください。
netstat -anp|grep :80
nginxの設定に問題がある場合は、次の最小設定を試してください。
daemon on;
worker_processes 2;
user www-data;
events {
use epoll;
worker_connections 128;
}
error_log logs/error.log info;
http {
server_tokens off;
include mime.types;
charset utf-8;
access_log logs/access.log combined;
server {
server_name localhost;
listen *:80;
error_page 500 502 503 504 /50x.html;
location / {
root html;
}
}
}