Setting Up a Web Server with NGINX
Introduction
NGINX is a powerful web server known for its performance and flexibility. In this guide, we'll walk you through the steps to install and configure NGINX on a Linux server.
Step 1: Install NGINX
First, update your package list and install NGINX using the following commands:
sudo apt update
sudo apt install nginx -y
Step 2: Start and Enable NGINX
To start NGINX and enable it to run on startup, use:
sudo systemctl start nginx
sudo systemctl enable nginx
Step 3: Configure the Firewall
If you're using UFW, allow NGINX traffic by running:
sudo ufw allow 'Nginx Full'
Step 4: Verify NGINX Installation
Visit your server's IP address in a web browser. You should see the NGINX welcome page:
http://your_server_ip
Step 5: Host a Website
To host a website, place your HTML files in the /var/www/html/
directory, and modify the server block configuration if necessary.
echo "<h1>Welcome to My Website</h1>" | sudo tee /var/www/html/index.html
Conclusion
You've successfully set up an NGINX web server. From here, you can explore more advanced configurations to tailor the server to your needs.