Nginx가 중지되지 않고 nginx.pid가 누락되었습니다 [FAILED] 그리고 nginx.conf그것은

Nginx를 중지하고 싶지만 이렇게 실패합니다.

$ sudo service nginx stop
Stopping nginx:                                            [FAILED]

그리고 nginx.conf그것은 nginx.pid의 위치에 선이 있습니다.

# /etc/nginx/nginx.conf
pid        /var/run/nginx.pid;

그러나 nginx.pid디렉토리 에는 없습니다 /var/run/.

locate nginx.pid 이 출력을 보여줍니다.

/var/run/nginx.pid
/var/run/nginx.pid.oldbin

그러나 updatedb검색과 일치하는 것이 없습니다. 에서 nginx / 1.4.4를 사용하고 CentOS release 6.5 (Final)있습니다.

nginx 데몬을 중지하려면 어떻게해야합니까?

2014/01/07 수정

이 결과는 ps -ef | grep nginxnginx 데몬이 여전히 실행중인 것 같습니다.

ironsand 17065 16933  0 15:55 pts/0    00:00:00 grep --color nginx
root     19506     1  0  2013 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
ironsand 19507 19506  0  2013 ?        00:00:25 nginx: worker process

그리고이 sudo service nginx restart오류가 발생합니다. nginx오래된 것이 아직 살아 있기 때문에 시작하지 못하는 것 같습니다 . 그리고이 /var/log/nginx/error.log-2014017오류도 포함되어 있습니다.

Stopping nginx:                                            [FAILED]
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
                                                           [FAILED]


답변

먼저 마스터 프로세스를 종료하여 nginx를 중지하는 것이 좋습니다. nginx가 제대로 종료되지 않은 것은 init 스크립트를 사용하여 중지 할 수 없기 때문일 수 있습니다.

ps -ef | grep nginx

nginx 마스터 프로세스의 PID가 표시됩니다. 위에서 언급 한 것처럼 :

루트 19506 10 2013? 00:00:00 nginx : 마스터 프로세스 / usr / sbin / nginx -c /etc/nginx/nginx.conf

사용하여 죽여라

죽이기 -19 19506

nginx 프로세스가 실행 중이거나 포트 80이 사용 중인지 다시 확인하십시오. 프로세스가 포트 80에 바인드 된 경우 PID를 식별하고 종료 될 수 있는지 확인하십시오.

ps -ef | grep nginx

netstat -tulpn | grep 80

파일 시스템이 올바른지 확인하고 / var 파일 시스템을 읽고 쓸 수 있습니다. 그런 다음 nginx를 시작하십시오

서비스 nginx 시작


답변

문제

나를 위해 pid 파일 이름은 두 파일에서 다릅니다.

  • /usr/lib/systemd/system/nginx.service
    • pid /var/run/nginx.pid;
  • /etc/nginx/nginx.conf
    • PIDFile=/run/nginx.pid

이 둘은 일치해야합니다.

고치다:

그래서 /usr/lib/systemd/system/nginx.service에서 조정 한 후 다음을 수행했습니다.

systemctl daemon-reload
systemctl start nginx

그런 다음 올바르게 나타났습니다.


답변

나는이 문제가 있었고, 달리는 ps -ef | grep nginx것은 받아 들여진 대답에 의해 제안 된 마스터 프로세스를 죽 였음에도 불구하고 계속 회전하는 노동자를 보여줍니다.

[~]# ps -ef | grep nginx
nginx    10730     1  0 Sep14 ?        00:00:16 nginx: cache manager process
nginx    18469     1  0 Oct09 ?        00:11:02 nginx: worker process
nginx    25779     1  0 Oct13 ?        00:01:31 nginx: worker process
nginx    26458     1  0 15:45 ?        00:00:00 nginx: worker process

그래서 그것을 고치는 나의 해결책 은 간단합니다 :pkill nginx && service nginx restart


답변

내 문제는 내가 pid두 개의 다른 conf 파일에 지정 했다는 것 입니다. 하나의 참조를 제거한 다음 .pid파일 을 삭제하고 nginx를 다시 시작하면 정상적으로 작동하기 시작했습니다.


답변

이것은 nginx가 이전에 시작된 경우 즉시 충돌하고 있음을 나타냅니다. /var/log/nginx*프로세스가 수행중인 작업 을 확인하기 위해 내용을 확인 했습니까 ?

편집 : 또한 OS와 nginx 버전을 알려 주면 더 자세한 답변을 줄 수 있습니다.


답변

더 많은 정보가 필요하지만 원하는 ngnix 인스턴스가 아닌 다른 웹 서버 가 이미 실행 중이므로 찾아야합니다. 포트 80이 사용 중이지만 오류가 발생했습니다. 뭐

시도 netstat -tulpn-로컬 주소 아래에서 : 80으로 끝나는 항목을 찾고 있습니다. 또한 프로그램 이름과 PID를 제공하여 식별 할 수 있습니다. 여기 내 것이 있습니다-lighttpd를 실행 중이며 세 번째 줄에 표시됩니다.

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:5000          0.0.0.0:*               LISTEN      4684/rtorrent
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      923/php-fpm.conf)
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      972/lighttpd
tcp        0      0 0.0.0.0:6901            0.0.0.0:*               LISTEN      4684/rtorrent
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      720/sshd
tcp6       0      0 :::22                   :::*                    LISTEN      720/sshd
udp        0      0 0.0.0.0:6881            0.0.0.0:*                           4684/rtorrent

다른 웹 서버를 올바로 종료하고 (시작이 시작되면 정상적인 ‘kill’이 작동하지 않을 수 있으므로) ngnix를 시작하십시오. 이 경우 init 스크립트를 편집하여 다른 웹 서버의 시작을 중지하거나 다른 전원으로 구성을 조정할 수 있습니다.


답변

우분투 10.10과 비슷한 문제가 있었고 / opt / nginx / sbin에서 실행중인 컴파일 된 버전의 nginx가있었습니다.

/opt/nginx/conf/nginx.conf 및 /etc/nginx/nginx.conf 파일을 모두 확인하고 일치하는지 확인하십시오.

다음을 사용하여 nginx.pid 위치 테스트와 일치하도록 /etc/init.d/nginx 시작 파일을 조정하십시오.

sudo /etc/init.d/nginx configtest # should show no failures
sudo /etc/init.d/nginx start      # should show starting
sudo /etc/init.d/nginx status     # should show running
sudo /etc/init.d/nginx stop       # should show stopping -- (wait for a few)
sudo /etc/init.d/nginx status     # should show can not access PID file for nginx
sudo netstat -tap  # should not show nginx program running with open local address