Update nginx to version 1.9.5

  • Posted October 8, 2015
  • Nginx


i added the nginx repo to my source.list deb trusty nginx deb-src trusty nginx

After this i did a sudo apt-get update and a sudo apt-get clean && sudo apt-get install nginx

but i get the following error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.13.0-61 linux-headers-3.13.0-61-generic
  linux-headers-3.13.0-62 linux-headers-3.13.0-62-generic
  linux-headers-3.13.0-63 linux-headers-3.13.0-63-generic
  linux-image-3.13.0-61-generic linux-image-3.13.0-62-generic
  linux-image-3.13.0-63-generic linux-image-extra-3.13.0-61-generic
  linux-image-extra-3.13.0-62-generic linux-image-extra-3.13.0-63-generic
  nginx-common nginx-full
Use 'apt-get autoremove' to remove them.
The following packages will be upgraded:
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/426 kB of archives.
After this operation, 1093 kB of additional disk space will be used.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "de_DE.UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 191862 files and directories currently installed.)
Preparing to unpack .../nginx_1.9.5-1~trusty_amd64.deb ...
Unpacking nginx (1.9.5-1~trusty) over (1.8.0-1+trusty1) ...
dpkg: error processing archive /var/cache/apt/archives/nginx_1.9.5-1~trusty_amd64.deb (--unpack):
 trying to overwrite '/usr/share/nginx/html/index.html', which is also in package nginx-common 1.8.0-1+trusty1
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)
forge@hostianer:~$ sudo nano /etc/apt/sources.list

My current nginx version is nginx/1.8.0

How can i solve this problem and update to the latest http2 nginx version?


I would recommend backing up your nginx configuration and web files and removing the current nginx packages on your system:

apt-get purge nginx nginx-common

Then try installing from the new repo again. From these errors it looks like the deb packages in the nginx repository are not packaged in the same way as those in the ubuntu official repos so there is a conflict between the new nginx package and the existing nginx-common package.

Thanks Ryanpg - this is the command needed if you previously had nginx installed. I had 1.8 running previously and it kept tripping.

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

The issue is with the apt-get clean command being issued after apt-get update and before apt-get install nginx. What is happening is you are updating your package cache then clearing it out again before you install NGINX.

This should work below.

sudo apt-get update && sudo apt-get install -y nginx 

first get your language settings right, this should work:

sudo nano /etc/default/locale

add this line at the bottom:


(or use “de_DE” if you prefer this) then reboot and repeat your installation procedure

You can build nginx from source