Nginx install don’t work [closed]

I have a problem with nginx , I deleted nginx because I did some modifications in nginx.conf and now I can’t install it …

apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libmemcached11 libmemcachedutil2
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  nginx-common nginx-full
Suggested packages:
  fcgiwrap nginx-doc
The following NEW packages will be installed:
  nginx-common nginx-full
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/518 kB of archives.
After this operation, 1311 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
(Reading database ... 122283 files and directories currently installed.)
Preparing to unpack .../nginx-common_1.6.2-5+deb8u4_all.deb ...
Unpacking nginx-common (1.6.2-5+deb8u4) ...
dpkg: error processing archive /var/cache/apt/archives/nginx-common_1.6.2-5+deb8                                                                                                                                                             u4_all.deb (--unpack):
 trying to overwrite '/etc/nginx/scgi_params', which is also in package sw-nginx                                                                                                                                                              1.11.10-debian8.0.17040416
Preparing to unpack .../nginx-full_1.6.2-5+deb8u4_amd64.deb ...
Unpacking nginx-full (1.6.2-5+deb8u4) ...
dpkg: error processing archive /var/cache/apt/archives/nginx-full_1.6.2-5+deb8u4                                                                                                                                                             _amd64.deb (--unpack):
 trying to overwrite '/usr/sbin/nginx', which is also in package sw-nginx 1.11.1                                                                                                                                                             0-debian8.0.17040416
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/nginx-common_1.6.2-5+deb8u4_all.deb
 /var/cache/apt/archives/nginx-full_1.6.2-5+deb8u4_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@vps:~# apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 nginx : Depends: nginx-full (>= 1.6.2-5+deb8u4) but it is not installed or
                  nginx-light (>= 1.6.2-5+deb8u4) but it is not installed or
                  nginx-extras (>= 1.6.2-5+deb8u4) but it is not installed
         Depends: nginx-full (< 1.6.2-5+deb8u4.1~) but it is not installed or
                  nginx-light (< 1.6.2-5+deb8u4.1~) but it is not installed or
                  nginx-extras (< 1.6.2-5+deb8u4.1~) but it is not installed
E: Unmet dependencies. Try using -f.

Answer

Try and run the following commands

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

purge delete configuration files for an application, but if it isin’t removed first this gives issues.

&& only executes if previous command executed, exited with exit code 0 (successfull) echo $? will show you the exit code of an application.

If all of this fails try and run dpkg -l|grep nginx and look for the first two letters in the output to see the status of the nginx package installation.

Example

ii openssh-server

A link that describes the dpkg flags
https://askubuntu.com/questions/18804/what-do-the-various-dpkg-flags-like-ii-rc-mean

Attribution
Source : Link , Question Author : Alexandru , Answer Author : Cristian Matthias Ambæk

Leave a Comment