Increasingly, customers MyHosti faced with the desire to have the latest version of the software on the server. In this article we will look at how to perform Nginx upgrade to the latest version to date.
Adding Nginx repository.
1. Go to the directory of the source package:
Debian/Ubuntu
touch nginx.list
CentOS/CloudLinux
touch nginx.list
2. Create files to specify package source Nginx
Debian/Ubuntu
touch nginx.list
CentOS/CloudLinux
touch nginx.list
3. Specify the Nginx repository
Debian 7
echo "deb http://nginx.org/packages/debian/ wheezy nginx" | tee -a /etc/apt/sources.list.d/nginx.list
echo "deb-src http://nginx.org/packages/debian/ wheezy nginx" | tee -a /etc/apt/sources.list.d/nginx.list
Debian 8
echo "deb http://nginx.org/packages/debian/ jessie nginx" | tee -a /etc/apt/sources.list.d/nginx.list
echo "deb-src http://nginx.org/packages/debian/ jessie nginx" | tee -a /etc/apt/sources.list.d/nginx.list
Ubuntu 12
echo "deb http://nginx.org/packages/ubuntu/ precise nginx" | tee -a /etc/apt/sources.list.d/nginx.list
echo "deb-src http://nginx.org/packages/ubuntu/ precise nginx" | tee -a /etc/apt/sources.list.d/nginx.list
Ubuntu 14
echo "deb http://nginx.org/packages/ubuntu/ trusty nginx" | tee -a /etc/apt/sources.list.d/nginx.list
echo "deb-src http://nginx.org/packages/ubuntu/ trusty nginx" | tee -a /etc/apt/sources.list.d/nginx.list
Ubuntu 15
echo "deb http://nginx.org/packages/ubuntu/ wily nginx" | tee -a /etc/apt/sources.list.d/nginx.list
echo "deb-src http://nginx.org/packages/ubuntu/ wily nginx" | tee -a /etc/apt/sources.list.d/nginx.list
Ubuntu 16
echo "deb http://nginx.org/packages/ubuntu/ xenial nginx" | tee -a /etc/apt/sources.list.d/nginx.list
echo "deb-src http://nginx.org/packages/ubuntu/ xenial nginx" | tee -a /etc/apt/sources.list.d/nginx.list
CentOS 5 / CloudLinux 5
echo "[nginx]" | tee -a /etc/yum.repos.d/nginx.repo
echo "name=nginx repo" | tee -a /etc/yum.repos.d/nginx.repo
echo "baseurl=http://nginx.org/packages/mainline/centos/5/"'$basearch/' | tee -a /etc/yum.repos.d/nginx.repo
echo "gpgcheck=0" | tee -a /etc/yum.repos.d/nginx.repo
echo "enabled=1" | tee -a /etc/yum.repos.d/nginx.repo
CentOS 6 / CloudLinux 6
echo "[nginx]" | tee -a /etc/yum.repos.d/nginx.repo
echo "name=nginx repo" | tee -a /etc/yum.repos.d/nginx.repo
echo "baseurl=http://nginx.org/packages/mainline/centos/6/"'$basearch/' | tee -a /etc/yum.repos.d/nginx.repo
echo "gpgcheck=0" | tee -a /etc/yum.repos.d/nginx.repo
echo "enabled=1" | tee -a /etc/yum.repos.d/nginx.repo
CentOS 7 / CloudLinux 7
echo "[nginx]" | tee -a /etc/yum.repos.d/nginx.repo
echo "name=nginx repo" | tee -a /etc/yum.repos.d/nginx.repo
echo "baseurl=http://nginx.org/packages/mainline/centos/7/"'$basearch/' | tee -a /etc/yum.repos.d/nginx.repo
echo "gpgcheck=0" | tee -a /etc/yum.repos.d/nginx.repo
echo "enabled=1" | tee -a /etc/yum.repos.d/nginx.repo
4. Add the Nginx key
cd
wget http://nginx.org/keys/nginx_signing.key
Debian/Ubuntu
apt-key add nginx_signing.key
CentOS/CloudLinux
rpm --import nginx_signing.key
5. Perform updating indexes and packages
Debian/Ubuntu
apt-get update && apt-get -y upgrade nginx
CentOS/CloudLinux
yum update
You can simplify the process and perform the upgrade using our script.