2

I am trying to install nginx on my freshly installed Ubuntu Server 15.10 with Mate desktop.

I did a quick update:

sudo apt-get update

Now trying to install nginx:

sudo apt-get install nginx

here is what I am getting:

server@Node1:~/nod$ sudo apt-get install nginx
Reading package lists... Done
Building dependency tree       
Reading state information... Done
nginx is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up nginx-core (1.9.3-1ubuntu1.1) ...
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.
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.9.3-1ubuntu1.1) | nginx-full (>= 1.9.3-1ubuntu1.1) | nginx-light (>= 1.9.3-1ubuntu1.1) | nginx-extras (>= 1.9.3-1ubuntu1.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.
 nginx depends on nginx-core (<< 1.9.3-1ubuntu1.1.1~) | nginx-full (<< 1.9.3-1ubuntu1.1.1~) | nginx-light (<< 1.9.3-1ubuntu1.1.1~) | nginx-extras (<< 1.9.3-1ubuntu1.1.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.
Errors were encountered while processing:
 nginx-core
 nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)

Here is output of 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 Sat 2016-02-27 20:32:18 EST; 32min ago
  Process: 6023 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 6020 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)

Feb 27 20:32:16 Node1 nginx[6023]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Feb 27 20:32:17 Node1 nginx[6023]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Feb 27 20:32:17 Node1 nginx[6023]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Feb 27 20:32:17 Node1 nginx[6023]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Feb 27 20:32:17 Node1 nginx[6023]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Feb 27 20:32:18 Node1 nginx[6023]: nginx: [emerg] still could not bind()
Feb 27 20:32:18 Node1 systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 27 20:32:18 Node1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Feb 27 20:32:18 Node1 systemd[1]: nginx.service: Unit entered failed state.
Feb 27 20:32:18 Node1 systemd[1]: nginx.service: Failed with result 'exit-code'.

This is my first experience with 15.10 and was hoping to be easier. I have little time to spend on server installation and contemplating to roll back to 14.xx. Please advise if you have any solutions.

Thank you.

4 Answers 4

5

In your case port 80 or port 98 is already in use by some other process. You need to find out which process is using those port(s) and kill that process or service.

sudo netstat -nlp

and then you can try starting nginx. BTW nginx is already installed in your case.

You can refer to this link1 or link2

1

If you have Apache installed.

Apply following commands.

Stop apache2

service apache2 stop

then install nginx

sudo apt-get install nginx 
1
  • That was my problem
    – insign
    Apr 8, 2017 at 6:27
0

I was having the same problem. The advice about Apache wasn't relevant, as I'd actively uninstalled it during setup.

Turns out I was seeing the result of a conflict between nginx's config file /etc/nginx/nginx.conf and the service script at /lib/systemd/system/nginx.service.

Specifically, the service script was starting nginx with some options, including daemon on:

$ cat /lib/systemd/system/nginx.service
...
[Service]
...
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
...

I ran /usr/sbin/nginx -g 'daemon on; master_process on;' directly on the terminal and got the following error:

nginx: [emerg] "daemon" directive is duplicate in /etc/nginx/nginx.conf:1

I took a look in /etc/nginx/nginx.conf and found (on line 1):

daemon off;

Commenting this out and running sudo apt-get -f install resolved the problem.

0

Heres the bug. You can manually edit a fix.

I have it on digitalocean repos. Using virtualmin?

https://github.com/webmin/webmin/issues/206

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .