root@vpsirham:~# apt-get --reinstall install nginx-common
Reading package lists... Done Building dependency tree Reading state
information... Done Suggested packages: fcgiwrap nginx-doc The
following NEW packages will be installed: nginx-common 0 upgraded,
1 newly installed, 0 to remove and 0 not upgraded. Need to get 0
B/18.3 kB of archives. After this operation, 220 kB of additional
disk space will be used. (Reading database ... 45660 files and
directories currently installed.) Preparing to unpack
.../nginx-common_1.4.6-1ubuntu3.4_all.deb ... Unpacking nginx-common
(1.4.6-1ubuntu3.4) ... dpkg: error processing archive
/var/cache/apt/archives/nginx-common_1.4.6-1ubuntu3.4_all.deb
(--unpack): trying to overwrite '/etc/logrotate.d/nginx', which is
also in package nginx 1.8.1-1~trusty Errors were encountered while
processing:
/var/cache/apt/archives/nginx-common_1.4.6-1ubuntu3.4_all.deb E:
Sub-process /usr/bin/dpkg returned an error code (1)</blink>
- 78,878
2 Answers
Firstly, you've got the NGINX upstream repositories enabled; these do not work with the Ubuntu nginx-common packages, and are never designed to. I explain a lot more on this in-depth on my blog post about this, but in all practical use cases, use only one or the other between the Ubuntu packages for NGINX and the upstream nginx.org repository - do NOT use both simultaneously, they don't work together properly and never will as they clobber each other. (upstream makes a single package, Debian/Ubuntu splits things into additional packages for sanity sake and ease of replacing configs with defaults and what not)
If you want to have the latest NGINX version and still have it be somewhat more compatible with Ubuntu, you can use the NGINX Mainline PPA (maintained by me, but I also maintain this in Ubuntu as well), which will have a more Ubuntu-compatible package set that is more similar to the packages you're expecting to use rather than the ones you are using.
If you want to go this way, I give details on my blog as well for that.
- 78,878
This is happening because you have previously installed Nginx from Ubuntu repositories and, after, added a new PPA and tried to upgrade.
The correct way to solve this is to remove completely Nginx (backup your conf files if needed) and install it again.
So, here are the instructions:
1 - Remove Nginx (after backup conf files)
sudo apt-get purge nginx*
2 - Install it again, this time the latest version from your new PPA:
sudo apt install nginx
That's it.
- 2,102