To connect to the aws instance via Putty or SSH, and type the command sudo yum install -y nginx
to install NGINX server on Amazon AWS EC2 Linux 2 server. Once it’s installed, you can configure it using the sudo nano /etc/nginx/conf.d/mywebsite.conf
command on an AWS SSH terminal window.
How to Install and Configure Nginx on Amazon AWS Ec2 Instance Linux 2
Here are the steps to install, configure, and verify NGINX on Amazon AWS ec2 instance with linux 2 server:
Step 1 – Connect to AWS Instance via SSH OR Putty
To connect Amazon AWS EC2 instance via putty SSH.
If you do not how to connect AWS EC2 instance via SSH, Read this => Connect AWS EC2 instance via ssh for Windows, Mac, and Linux users.
Step 2 – Update System Packages
To update system packages, type sudo yum update -y
command on aws ssh terminal and press enter:
sudo yum update -y
Step 3 – Install NGINX on Amazon AWS Linux 2
To install NGINX on amazon aws ec2 instance linux 2, Simply type sudo yum install -y nginx
command on aws ssh terminal and press enter:
sudo yum install -y nginx
Step 4 – Verify NGINX Installation
Once the installation of NGINX on amazon linux 2 system has been done; then run the following command on ssh terminal to verify NGINX installation:
sudo systemctl status NGINX
Step 5 – Configure NGINX Server
To configure nginx, you need to open conf.d
file, which is located inside /etc/nginx/
directory.
sudo nano /etc/nginx/conf.d/mywebsite.conf
Add the following configuration to the file:
server { listen 80; server_name mywebsite.com www.mywebsite.com; location / { root /var/www/html; index index.html; } }
To apply the configuration changes, type sudo systemctl reload nginx command on ssh terminal and press enter:
sudo systemctl reload nginx
Step 6 – Test Installation in Browser
Test nginx installation, open web browser and type your ip address:
http://YOUR_IP
Here are some commands for restarting, reloading, starting, stopping, enabling, and disabling nginx services.
Check NGINX Status
sudo systemctl status NGINX
Restart NGINX
sudo systemctl restart NGINX
Reload NGINX
sudo systemctl reload NGINX
Start NGINX
sudo systemctl start NGINX
Stop NGINX
sudo systemctl stop NGINX
Disable NGINX
sudo systemctl disable NGINX
Here is the video guide on installing and configuring NGINX server on amazon aws ec2 instance with linux 2 server:
Conclusion
Through this tutorial, you have learned the complete process of nginx installation on amazon aws linux 2 server.
After all, this is related to the tutorial, if you have any questions, you can comment in the comment box, or mail me at [email protected].