I'm trying to upgrade nginx 1.2.1 to version 1.2.6 on ubuntu 12.10, but with no luck. I've previously installed nginx using apt-get install nginx-full because I needed the modules instead of building from sources. But now I can't 'overwrite' the old package with the apt-get from below

$ apt-get install nginx
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 415 kB of archives.
After this operation, 930 kB of additional disk space will be used.
Get:1 http://nginx.org/packages/ubuntu/ quantal/nginx nginx amd64 1.2.6-1~quantal [415 kB]
Fetched 415 kB in 2s (186 kB/s)
Selecting previously unselected package nginx.
(Reading database ... 77029 files and directories currently installed.)
Unpacking nginx (from .../nginx_1.2.6-1~quantal_amd64.deb) ...

Thanks for using NGINX!

Check out our community web site:
* http://nginx.org/en/support.html

If you have questions about commercial support for NGINX please visit:
* http://www.nginx.com/support.html

dpkg: error processing /var/cache/apt/archives/nginx_1.2.6-1~quantal_amd64.deb (--unpack):
trying to overwrite '/usr/sbin/nginx', which is also in package nginx-full 1.2.1-2.2
No apport report written because MaxReports is reached already
                                                          dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I don't want to mess with all the configured websites I have in nginx, is there a safe upgrade method in this case? I need realip_module, upstream_module, rewrite_module, memcached_module, headers_module, fastcgi_module but I don't know the the package 'nginx' from the PPA has all the modules within the package.


Found the answer from http://www.webupd8.org/2011/02/fix-dpkg-error-trying-to-overwrite-x.html

Fixing this (in most cases but probably not all) is quite simple: look for path of the file that caused the error - in my first example that would be "/var/cache/apt/archives/smplayer_0.6.9+svn3595-1ppa1~maverick1_i386.deb", an run the following command:

sudo dpkg -i --force-overwrite /var/cache/apt/archives/smplayer_0.6.9+svn3595-1ppa1~maverick1_i386.deb

If "--force-overwrite" doesn't work, you can try "--force-all" instead.

In the above command, replace "/var..." with the exact path to the .deb that caused the error on your computer. If you've installed it from a repository, the .deb is located in /var/cache/apt/archives but if not, it's wherever you've downloaded it (either way, the error should display its exact path so you don't have to look for it manually).

What the above command does is force the overwrite of the file that exists in 2 packages and caused the error. Then, to make sure all the packages have installed successfully, also run the following command:

sudo apt-get install -f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.