Amin
Amin

Reputation: 741

NGINX installation error

Using Linux Mint 18.3 when I had nginx installed which was running well. I needed to uninstall it for some reason, and I uninstall it using command:

sudo apt purge nginx -y
sudo rm -rf /etc/nginx
sudo apt autoremove

then when I need it later again, I tried:

sudo apt install nginx -y

it says me following error: here are all the lines from terminal:

sudo apt install nginx -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  nginx-common nginx-core
Suggested packages:
  fcgiwrap nginx-doc
The following NEW packages will be installed:
  nginx nginx-common nginx-core
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/458 kB of archives.
After this operation, 1,482 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package nginx-common.
(Reading database ... 235105 files and directories currently installed.)
Preparing to unpack .../nginx-common_1.10.3-0ubuntu0.16.04.2_all.deb ...
Unpacking nginx-common (1.10.3-0ubuntu0.16.04.2) ...
Selecting previously unselected package nginx-core.
Preparing to unpack .../nginx-core_1.10.3-0ubuntu0.16.04.2_amd64.deb ...
Unpacking nginx-core (1.10.3-0ubuntu0.16.04.2) ...
Selecting previously unselected package nginx.
Preparing to unpack .../nginx_1.10.3-0ubuntu0.16.04.2_all.deb ...
Unpacking nginx (1.10.3-0ubuntu0.16.04.2) ...
Processing triggers for ureadahead (0.100.0-19) ...
ureadahead will be reprofiled on next reboot
Processing triggers for ufw (0.35-0ubuntu2) ...
Processing triggers for systemd (229-4ubuntu21.2) ...
Setting up nginx-common (1.10.3-0ubuntu0.16.04.2) ...
Setting up nginx-core (1.10.3-0ubuntu0.16.04.2) ...
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 Tue 2018-05-29 22:56:08 +06; 18ms ago
  Process: 2929 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

May 29 22:56:08 ahs-pc systemd[1]: Starting A high performance web server a.....
May 29 22:56:08 ahs-pc nginx[2929]: nginx: [emerg] open() "/etc/nginx/nginx...y)
May 29 22:56:08 ahs-pc nginx[2929]: nginx: configuration file /etc/nginx/ng...ed
May 29 22:56:08 ahs-pc systemd[1]: nginx.service: Control process exited, c...=1
May 29 22:56:08 ahs-pc systemd[1]: Failed to start A high performance web s...r.
May 29 22:56:08 ahs-pc systemd[1]: nginx.service: Unit entered failed state.
May 29 22:56:08 ahs-pc systemd[1]: nginx.service: Failed with result 'exit-...'.
Hint: Some lines were ellipsized, use -l to show in full.
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.3-0ubuntu0.16.04.2) | nginx-full (>= 1.10.3-0ubuntu0.16.04.2) | nginx-light (>= 1.10.3-0ubuntu0.16.04.2) | nginx-extras (>= 1.10.3-0ubuntu0.16.04.2); 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.3-0ubuntu0.16.04.2.1~) | nginx-full (<< 1.10.3-0ubuntu0.16.04.2.1~) | nginx-light (<< 1.10.3-0ubuntu0.16.04.2.1~) | nginx-extras (<< 1.10.3-0ubuntu0.16.04.2.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 No apport report written because the error message indicates its a followup error from a previous failure.
                                                         unconfigured
Errors were encountered while processing:
 nginx-core
 nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've tried force install also, like bellow:

sudo apt install -f nginx

but throws the same error!

Upvotes: 10

Views: 29140

Answers (4)

Joshua Pchumba
Joshua Pchumba

Reputation: 111

I did sudo apt-get --purge remove nginx-* To remove all the dependency on the system then

sudo apt-get install nginx

Upvotes: 2

Teodorico Maziviala
Teodorico Maziviala

Reputation: 426

I had the same issue, but my case was a bit different because I was running nginx-proxy with acme_helper docker container which it created a nginx conf file and saved that directory.

I fixed this by running these commands from @ZontarZon

sudo apt-get --purge remove nginx-*
sudo apt-get install nginx

Upvotes: 3

Jose Antonio
Jose Antonio

Reputation: 898

user@user:~$ sudo service apache2 stop
user@user:~$ sudo apt install nginx -y

enter image description here

Upvotes: 4

ZontarZon
ZontarZon

Reputation: 743

Go check out your error.log file, which is located at /var/log/nginx/error.log. I had a very similar error output once, and as it turned out, I had something else running port 80 as the default. Usually apache is to blame.

If your error.log spits something out that looks like listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) try out sudo lsof -i :80 and see what's running port 80, if this is the case. You'll have to kill whatever is on the port if you want nginx to run properly.

Another possibility is that you accidentally deleted your nginx.conf file or directory with the file, in which case I ran these:

sudo apt-get --purge remove nginx-*
sudo apt-get install nginx

If these don't work out, please post the error.log results.

Upvotes: 29

Related Questions