>PROBLEM
Installing nginx:
apt install nginx
Returns:
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. invoke-rc.d: initscript nginx, action "start" failed. ● 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 Sat 2020-09-26 22:49:18 UTC; 7ms ago Docs: man:nginx(8) Process: 21405 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE) Process: 21404 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Sep 26 22:49:17 mind4y.com nginx[21405]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use) Sep 26 22:49:17 mind4y.com nginx[21405]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) Sep 26 22:49:17 mind4y.com nginx[21405]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use) Sep 26 22:49:18 mind4y.com nginx[21405]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) Sep 26 22:49:18 mind4y.com nginx[21405]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use) Sep 26 22:49:18 mind4y.com nginx[21405]: nginx: [emerg] still could not bind() Sep 26 22:49:18 mind4y.com systemd[1]: nginx.service: Control process exited, code=exited status=1 Sep 26 22:49:18 mind4y.com systemd[1]: Failed to start A high performance web server and a reverse proxy server. Sep 26 22:49:18 mind4y.com systemd[1]: nginx.service: Unit entered failed state. Sep 26 22:49:18 mind4y.com systemd[1]: nginx.service: Failed with result 'exit-code'. dpkg: error processing package nginx-full (--configure): subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of nginx: nginx depends on nginx-full (<< 1.10.3-1+deb9u4.1~) | nginx-light (<< 1.10.3-1+deb9u4.1~) | nginx-extras (<< 1.10.3-1+deb9u4.1~); however: Package nginx-full is not configured yet. Package nginx-light is not installed. Package nginx-extras is not installed. nginx depends on nginx-full (>= 1.10.3-1+deb9u4) | nginx-light (>= 1.10.3-1+deb9u4) | nginx-extras (>= 1.10.3-1+deb9u4); however: Package nginx-full is not configured yet. Package nginx-light is not installed. Package nginx-extras is not installed. dpkg: error processing package nginx (--configure): dependency problems - leaving unconfigured Errors were encountered while processing: nginx-full nginx E: Sub-process /usr/bin/dpkg returned an error code (1)
>SOLUTION
The issue is caused by port collision. In this case Apache is already using port 80.
The tip is given by the log at line:
nginx[21405]: nginx: [emerg] listen() to 0.0.0.0:80
Switch Nginx or Apache to another port.
In this case, Nginx is switched to port 81.
1. Edit:
/etc/nginx/sites-enabled/default
Switch from:
server {
listen 80 default_server;
listen [::]:80 default_server;
To:
server {
listen 81 default_server;
listen [::]:81 default_server;
2. Start nginx
systemctl start nginx
3. Test:
nginx -t
>EXTRA
If desired to reinstall Nginx, uninstall first:
apt update
apt purge nginx
apt autoremove
- verifying dependencies:
apt -f install
apt autoremove
- verifying dependencies:
apt -f install
>ENV
debian 9
No comments:
Post a Comment