
nginx
이 항목을 사용하여 설치했습니다 sources.list.d
.
deb http://nginx.org/packages/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/ubuntu/ xenial nginx
nginx 버전은 1.12.2-1~xenial
. 서버는 커널과 함께 Ubuntu 16.04 LTS를 실행하고 있습니다 4.4.0-36-generic
.
내 문제는 nginx
데몬이 시작되지 않는다는 것입니다.
$ sudo systemctl start nginx
Job for nginx.service failed because a timeout was exceeded. See "systemctl status nginx.service" and "journalctl -xe" for details.
안타깝게도 이러한 로그는 많은 정보를 제공하지 않습니다.
$ sudo journalctl -xe
Feb 05 10:43:50 SERVERNAME nginx[17035]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Feb 05 10:43:50 SERVERNAME nginx[17035]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Feb 05 10:45:21 SERVERNAME systemd[1]: nginx.service: Start operation timed out. Terminating.
Feb 05 10:45:21 SERVERNAME systemd[1]: Failed to start nginx - high performance web server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
Feb 05 10:45:21 SERVERNAME systemd[1]: nginx.service: Unit entered failed state.
Feb 05 10:45:21 SERVERNAME systemd[1]: nginx.service: Failed with result 'timeout'.
내가 알 수 있는 바에 따르면,nginx가 실제로 올바르게 시작됩니다. 이는 상위 프로세스가 하위 프로세스로부터 "시작했습니다" 메시지를 제대로 수신하지 못하는 것과 같습니다. 실행 중일 때(시스템이 시작되기를 기다리고 있음) 다음과 같이 성공적으로 컬링할 수 있습니다.
$ curl http://localhost:8000
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.12.2</center>
</body>
</html>
nginx
다른 버전이나 다른 것을 테스트하는 것 외에는 이것에 대해 길을 잃었습니다 . 어떤 아이디어가 있나요? 서버를 재부팅할 수 있지만 Linux 서버에서는 어리석게 느껴집니다.
업데이트 9:56 UTC: 1.13.8-1~xenial
동일한 문제로 테스트되었습니다.
답변1
결국 문제를 발견했는데 이것은 어리석은 문제였습니다 ...
nginx
구성 에 다음 설정이 있는 Docker 컨테이너에서 설정을 복사하여 구성을 시작했습니다 nginx
.
daemon off;
이는 Docker 시나리오에서 옳았습니다(프로세스가 nginx
로 실행 중 runit
, 즉 no systemd
-style init가 제어하지 않은 경우). 이는 결코 데몬화되지 않고 제어권을 systemd로 반환하지 않는 효과가 있었습니다. nginx
-> "시간 초과됨"으로 처리됩니다. 알 수 없는 문제"라고 말하며 systemd
죽일 것입니다.
그래서 이는 단순한 구성 오류로 끝났습니다. 이 서투른 실수를 저지르는 다른 사람들에게도 도움이 될 수 있기 때문에 여기에 게시하고 싶었습니다. :-)
이 키워드에 대한 전체 세부정보:http://nginx.org/en/docs/ngx_core_module.html#daemon
답변2
또한 문제가 될 수 있는 것은 nginx.conf에서 pid 지역화를 사용자 정의 설정하는 것입니다.
pid ../logs/nginx.pid;
nginx.service 파일(/lib/systemd/system/nginx.service)의 PIDFile 설정과 일치해야 합니다. PIDFile=/var/run/nginx.pid
여기는 그렇지 않아요 ;]
답변3
이는 nginx 구성을 openresty로 복사할 때도 발생할 수 있습니다. 구성에 다음 줄이 있었고 openresty는 서비스로 시작되지 않습니다.
pid /run/nginx.pid;