Ubuntu: Error When Installing Nginx on Ubuntu 16.04



Question:

I keep on getting this error when trying to install nginx. I tried to reinstall it several times, but this error keeps on popping out and I can't start nginx.

Appreciate any help!

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 Mon 2017-03-27 21:38:51 PHT; 10ms ago    Process: 28178 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)    Process: 28174 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)    Mar 27 21:38:49 nico-Aspire-E5-575G nginx[28178]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)  Mar 27 21:38:49 nico-Aspire-E5-575G nginx[28178]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)  Mar 27 21:38:50 nico-Aspire-E5-575G nginx[28178]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)  Mar 27 21:38:50 nico-Aspire-E5-575G nginx[28178]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)  Mar 27 21:38:51 nico-Aspire-E5-575G nginx[28178]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)  Mar 27 21:38:51 nico-Aspire-E5-575G nginx[28178]: nginx: [emerg] still could not bind()  Mar 27 21:38:51 nico-Aspire-E5-575G systemd[1]: nginx.service: Control process exited, code=exited status=1  Mar 27 21:38:51 nico-Aspire-E5-575G systemd[1]: Failed to start A high performance web server and a reverse proxy server.  Mar 27 21:38:51 nico-Aspire-E5-575G systemd[1]: nginx.service: Unit entered failed state.  Mar 27 21:38:51 nico-Aspire-E5-575G systemd[1]: nginx.service: Failed with result 'exit-code'.  dpkg: error processing package nginx-core (--configure):   subprocess installed post-installation script returned error exit status 1  dpkg: dependency problems prevent configuration of nginx:   nginx depends on nginx-core (>= 1.10.0-0ubuntu0.16.04.4) | nginx-full (>= 1.10.0-0ubuntu0.16.04.4) | nginx-light (>= 1.10.0-0ubuntu0.16.04.4) | nginx-extras (>= 1.10.0-0ubuntu0.16.04.4); however:    Package nginx-core is not configured yet.    Package nginx-full is not installed.    Package nginx-light is not installed.    Package nginx-extras is not installed.   nginx depends on nginx-core (<< 1.10.0-0ubuntu0.16.04.4.1~) | nginx-full (<< 1.10.0-0ubuntu0.16.04.4.1~) | nginx-light (<< 1.10.0-0ubuntu0.16.04.4.1~) | nginx-extras (<< 1.10.0-0ubuntu0.16.04.4.1~); however:    Package nginx-core is not configured yet.    Package nginx-full is not installed.    Package nginx-light is not installed.    Package nginx-extras is not installed.    dpkg: error processing package nginx (--configure):   dependency problems - leaving unconfigured  No apport report written because the error message indicates its a followup error from a previous failure.                                                                                                            Processing triggers for systemd (229-4ubuntu16) ...  Processing triggers for ureadahead (0.100.0-19) ...  Processing triggers for ufw (0.35-0ubuntu2) ...  Errors were encountered while processing:   nginx-core   nginx  E: Sub-process /usr/bin/dpkg returned an error code (1)  


Solution:1

Something is already running on port 80, so when nginx tries to start and take that port it fails. Check to see what is running on your port 80 and stop it. You can find out what is using port 80 with:

sudo netstat -lnp | grep 0.0.0.0:80  

Once you find what is using the port, do a systemctl stop to stop it and try to start nginx again. Keep in mind that you will have to disable that other service permanently in order for nginx to work properly.


Solution:2

Based in the error message:

  Package nginx-full is not installed.    Package nginx-light is not installed.    Package nginx-extras is not installed.  

I recommend you to run sudo apt-get install nginx-full nginx-light nginx-extras


Solution:3

It looks like NGINX and some other server app are both binding to use port 80 as their default port.

The easy solution would be to change the NGINX port to be something else, which can be done by editing /etc/nginx/sites-available/default (or whatever config file) to bind to a different port.

Look for a line that says something like this:

Listen 80;  

Change the 80 to a free port (e.g. 851):

Listen 851;  

Restart NGINX, and it should start up again without issue.

Note that if you want to actually use NGINX as your web host, you will need to change your other webserver's config.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »