Introduction
Nginx is a powerful and popular web server known for its speed, stability, and flexibility. In this article, we will explore how to install Nginx on three commonly used Linux distributions: Ubuntu, CentOS, and Debian.
Installing Nginx on Ubuntu
Prerequisites
- A server with Ubuntu operating system installed
- Access to a user account with
sudo
privileges
Installation Steps
- Update Package Lists
sudo apt update
- Install Nginx
sudo apt install nginx
- Enable and Start Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
- Configure the Firewall If you are using
ufw
(Uncomplicated Firewall), allow web server traffic.sudo ufw allow 'Nginx Full'
- Verify Installation By visiting your server’s IP address in a web browser, you can see the default Nginx landing page.
Installing Nginx on CentOS
Prerequisites
- A server with CentOS operating system installed
- Access to a user account with
sudo
privileges
Installation Steps
- Add Nginx Repository
sudo yum install epel-release
- Install Nginx
sudo yum install nginx
- Enable and Start Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
- Configure the Firewall To allow web server access through the firewall, execute the following commands.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
- Verify Installation By visiting your server’s IP address in a web browser, you can see the default Nginx landing page.
Installing Nginx on Debian
Prerequisites
- A server with Debian operating system installed
- Access to a user account with
sudo
privileges
Installation Steps
- Update Package Lists
sudo apt update
- Install Nginx
sudo apt install nginx
- Enable and Start Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
- Configure the Firewall If you are using
ufw
(Uncomplicated Firewall), allow web server traffic.sudo ufw allow 'Nginx Full'
- Verify Installation By visiting your server’s IP address in a web browser, you can see the default Nginx landing page.
Conclusion
By following the instructions above, you can easily install Nginx on three popular Linux distributions. After installation, you can proceed to further configure Nginx for your web services.