Я должен перезапустить процесс. Что я делаю, когда я продолжаю видеть эти сообщения? Вам нужно больше команд?
$ 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()
$ service nginx start
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
$ systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-05-29 13:28:29 KST; 26s ago
Process: 24508 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 31955 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 31952 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 13077 (code=exited, status=0/SUCCESS)
May 29 13:28:27 ip-172-26-12-170 nginx[31955]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
May 29 13:28:27 ip-172-26-12-170 nginx[31955]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
May 29 13:28:28 ip-172-26-12-170 nginx[31955]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
May 29 13:28:28 ip-172-26-12-170 nginx[31955]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
May 29 13:28:29 ip-172-26-12-170 nginx[31955]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
May 29 13:28:29 ip-172-26-12-170 nginx[31955]: nginx: [emerg] still could not bind()
May 29 13:28:29 ip-172-26-12-170 systemd[1]: nginx.service: Control process exited, code=exited status=1
May 29 13:28:29 ip-172-26-12-170 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
May 29 13:28:29 ip-172-26-12-170 systemd[1]: nginx.service: Unit entered failed state.
May 29 13:28:29 ip-172-26-12-170 systemd[1]: nginx.service: Failed with result 'exit-code'.
В будущем вот что может пригодиться. Вы можете проверить синтаксис конфигурационных файлов Nginx, выполнив:
nginx -t -c /etc/nginx/nginx.conf
Вывод ошибки подскажет вам, в чем проблема а также номер строки.
или:
отладка с помощью команды:
$ service nginx configtest
, которая выдает что-то вроде:
Тестирование конфигурации nginx: nginx: [emerg ] неизвестная директива "stub_status" в / etc / nginx / sites-enabled / nginx_status: 11 nginx: файл конфигурации /etc/nginx/nginx.conf Сбой теста
Приложение в настоящее время прослушивает входящий порт 80
. Скорее всего, это другой случай nginx
.
С помощью команды netstat вы можете найти приложение, которое в данный момент прослушивает сокет. Также используйте grep для фильтрации выходных данных netstat
.
$ netstat -lpn | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 780/nginx: master p
tcp6 0 0 :::80 :::* LISTEN 780/nginx: master p
Последняя запись в списке 780/nginx
сообщает вам PID
процесса, который в данный момент прослушивает порт 80
.
С помощью ps вы можете увидеть структуру процесса, используя сокет:
$ ps f -g780
PID TTY STAT TIME COMMAND
780 ? Ss 0:00 nginx: master process nginx
781 ? S 0:00 \_ nginx: worker process
782 ? S 0:00 \_ nginx: worker process
783 ? S 0:00 \_ nginx: worker process
784 ? S 0:00 \_ nginx: worker process
785 ? S 0:00 \_ nginx: worker process
786 ? S 0:00 \_ nginx: worker process
787 ? S 0:00 \_ nginx: worker process
788 ? S 0:00 \_ nginx: worker process
С помощью kill Команда теперь вы можете завершить процесс, использующий сокет:
$ kill 780
Если это не прерывает процесс с помощью -9
:
$ kill -9 780
Затем попробуйте перезапустить ваш nginx
Сервис.