一段时间没使用nginx后,发现无法启动
问题:
输入nginx -tc /etc/nginx/nginx.conf
显示正常
但是输入 systemctl reload nginx
提示
Job for nginx.service invalid.
查错:
输入 systemctl status nginx.service -l
提示
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2018-10-01 20:04:22 CST; 38s ago
Docs: http://nginx.org/en/docs/
Process: 27162 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)
Oct 01 20:04:19 VM_205_38_centos nginx[27162]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Oct 01 20:04:20 VM_205_38_centos nginx[27162]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Oct 01 20:04:20 VM_205_38_centos nginx[27162]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Oct 01 20:04:21 VM_205_38_centos nginx[27162]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Oct 01 20:04:21 VM_205_38_centos nginx[27162]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Oct 01 20:04:22 VM_205_38_centos nginx[27162]: nginx: [emerg] still could not bind()
Oct 01 20:04:22 VM_205_38_centos systemd[1]: nginx.service: control process exited, code=exited status=1
Oct 01 20:04:22 VM_205_38_centos systemd[1]: Failed to start nginx - high performance web server.
Oct 01 20:04:22 VM_205_38_centos systemd[1]: Unit nginx.service entered failed state.
Oct 01 20:04:22 VM_205_38_centos systemd[1]: nginx.service failed.
解决
vim /etc/nginx/conf.d/default.conf
更改listen的端口,因为原来的端口被占用( Address already in use)