These instructions aim to provide proper and the only correct way to install nginx web server on CentOS 7.
Prepare your system
First things first. You have to upgrade your CentOS 7 to latest release because nginx natively supports CentOS 7 >= 7.4:
yum -y upgrade
Add stable nginx repository
Now that we have at least CentOS 7.4, let’s install nginx repository to our system. We import nginx package signing key and install release package which contains the nginx yum repository file.
rpm --import https://nginx.org/keys/nginx_signing.key
yum -y install http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
As of this writing, EPEL repository has nginx package
1.12.2-2.el7 whereas nginx latest package is
1.12.2-1.el7_4.ngx. The actual version number is the same, but release number (
-1 in package names) is different. So if we proceed with installation,
yum would install nginx from EPEL.
The nginx packages by EPEL have entirely different structure and we want stable nginx server which is packaged and maintained by its creators.
So let’s make sure that the native nginx repository has priority over the others.
Install priorities yum plugin and adjust nginx repository priority:
yum -y install yum-plugin-priorities
echo 'priority=1' >> /etc/yum.repos.d/nginx.repo
yum will prefer to install nginx from stable nginx repository. Finalise your nginx setup with:
yum -y install nginx
Originally published at GetPageSpeed.