Installing Nginx from the Amazon Linux repo will provide you with an exceedingly old Nginx version. Therefore, I will show you how to install it through the EPEL repo which is my preferred choice when it comes to an RHEL Linux-based distro.
- AWS account
- EC2 instance with Amazon Linux 2 template
Enable and Install EPEL repo on AWS EC2 Amazon Linux 2 instance
Step 1. Firstly, check if the EPEL repository is enabled.
sudo amazon-linux-extras list | grep epel
If you get the following output:
24 epel available [ =7.11 =stable ]
Then, it means that you should enable it before installing Nginx.
Step 2. To enable the EPEL repo on Amazon Linux 2 instance run.
sudo amazon-linux-extras enable epel
Step 3. Now you should be able to install the EPEL repo.
sudo yum install epel-release
Install Nginx on AWS EC2 Amazon Linux 2 instance
Step 1. Once the EPEL repo is installed you can install the Nginx latest version as well.
sudo yum install nginx
Step 2. Verify the installation.
nginx version: nginx/1.20.1
This tutorial is aimed to provide you with a quick and safe path of installing Nginx on Amazon Linux 2 instance. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.