

🚀 How to Install and Configure NGINX on CentOS#
NGINX is one of the most popular web servers in the world. It’s fast, lightweight, and easy to configure — perfect for hosting websites, APIs, or static content.
In this guide, you’ll learn how to install NGINX on CentOS, start the service, configure a basic website, and verify the installation.
Step 1: Update Your System#
sudo yum update -ybashStep 2: Install NGINX#
sudo yum install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl status nginxbashStep 3: Allow NGINX in the Firewall#
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reloadbashStep 4: Verify NGINX is Running#
Visit:
http://<your-server-ip>plaintextYou should see the NGINX welcome page.
Step 5: Hosting Your First Web Page#
Default NGINX web root:
/usr/share/nginx/htmlplaintextEdit:
sudo nano /usr/share/nginx/html/index.htmlbashExample:
<h1>Hello from NGINX on CentOS!</h1>htmlStep 6: Basic Custom NGINX Configuration#
Create:
sudo nano /etc/nginx/conf.d/mywebsite.confbashAdd:
server {
listen 80;
server_name example.com;
root /var/www/mywebsite;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}nginxReload:
sudo nginx -t
sudo systemctl reload nginxbash🎉 Done!
You’ve successfully installed and configured NGINX on CentOS.