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>

- 74,764
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.

- 74,764
-
Your blog article was enlightening and helped me better deal with my quest to update nginx on Ubuntu properly. Sadly, it seems to be down right now, but is available via archive: https://web.archive.org/web/20170311094713/http://dark-net.net/?p=80 – spex Aug 21 '19 at 04:08
-
Also, your response here was very helpful: https://askubuntu.com/questions/553937/what-is-the-difference-between-the-core-full-extras-and-light-packages-for-ngi/556382#556382 – spex Aug 21 '19 at 04:09
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,024
-
This doesn't take into account the user is mixing-and-matching upstream repository packages and Ubuntu repository packages - this mixing is a critical failure point and will lead to evil on their system when mixing-and-matching, and breaks upgrading perpetually. – Thomas Ward Aug 30 '17 at 19:36
-
I will update the answer explaining this, and suggesting to backup conf files, remove nginx first and installing it again. If possible, please upvote after the update. Thanks! – Paulo Coghi Aug 30 '17 at 19:53
-
I also ran
sudo apt purge libnginx-mod*
to get rid of the Debian lib modules related with nginx. – Caumons Jul 29 '23 at 22:15