fbpx

Nginx / Server Setup

How to install nginx on RHEL 7 / CentOS 7 properly

by , , revisited on


We have by far the largest RPM repository with dynamic stable NGINX modules and VMODs for Varnish 4.1 and 6.0 LTS. If you want to install NGINX, Varnish and lots of useful modules for them, this is your one stop repository to get all performance related software.
You have to maintain an active subscription in order to be able to use the repository!

The Internet is full of wrong advice everywhere. Unfortunately, the first results in Google tend to lead you to the worst advice of compiling NGINX from source to avail of features like ALPN or integrating some modules. See my post on [where the compilation is wrong][https://www.getpagespeed.com/server-setup/where-compilation-went-wrong] to realize why compilation should be absolutely avoided.

Follow these instructions on how to install the latest stable NGINX web server in RHEL 7 / CentOS 7 server.

Step 1. Prepare your system

First things first. You have to upgrade your RHEL / CentOS 7 to the latest release:

sudo yum -y upgrade

Next, decide on the repository to fetch NGINX from:

Step 2. Setup RPM repository

Our CDN powered repository builds on exact same binaries released by official nginx.org website.

sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm

Step 3. Install NGINX

Option 1. Install latest stable NGINX

sudo yum install nginx

Option 2. Install latest mainline NGINX

The mainline NGINX is in fact, also stable for production. However, it receives more updates with new features, whereas the stable branch is updated less frequently.
To install the mainline NGINX, enable extra repository and proceed as usual:

sudo yum -y install yum-utils
sudo yum-config-manager --enable getpagespeed-extras-mainline 
sudo yum install nginx

Run NGINX

Now we are ready to run NGINX:

sudo systemctl enable --now nginx

Also published on Medium.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.