Setting up a reliable web server is essential for hosting websites, applications, or community forums. NGINX, known for its high performance and low resource consumption, is one of the most popular web servers. In this tutorial, we'll walk through the process of installing and configuring NGINX on Rocky Linux 9, a community-driven enterprise OS compatible with RHEL. Whether you're hosting a personal site or building a high-traffic community like hrace009.com, this guide provides a solid foundation to get started with NGINX quickly and securely.
Step 1: Update Your System
Open a terminal and update your system packages:
Bash:
sudo dnf update -y
Step 2: Install NGINX
Install NGINX using DNF, the default package manager:
Bash:
sudo dnf install nginx -y
Step 3: Enable and Start NGINX
Enable NGINX to start on boot, then start the service:
Bash:
sudo systemctl enable nginx
sudo systemctl start nginx
Step 4: Adjust Firewall Rules
Allow HTTP and HTTPS traffic through the firewall:
Bash:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Step 5: Test NGINX
Verify the installation by opening your browser and visiting your server's IP address. You should see the default NGINX welcome page:
NGINX:
http://your_server_ip/
Step 6: Configure Your Website
Replace the default NGINX config with your own. Example:
Bash:
sudo nano /etc/nginx/conf.d/hrace009.conf
NGINX:
server {
listen 80;
server_name yourdomain.com;
root /var/www/hrace009;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}
Bash:
sudo mkdir -p /var/www/hrace009
sudo nano /var/www/hrace009/index.html
HTML:
<h1>Welcome to hrace009.com!</h1>
Bash:
sudo chown -R nginx:nginx /var/www/hrace009
Step 7: Restart NGINX
After configuring your site, restart NGINX:
Bash:
sudo systemctl restart nginx