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