Basic Guide to Install and Use Nginx & Apache
Introduction
This guide will help you get started with installing and using Nginx and Apache on your Linux system. Both are popular web servers used to serve websites and web applications.
Installing Nginx
1. Update the system
sudo apt update && sudo apt upgrade -y
2. Install Nginx
sudo apt install nginx -y
3. Start and enable Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
4. Check Nginx status
sudo systemctl status nginx
5. Access the default Nginx page
- Open your web browser and go to
http://<your_server_ip>
- You should see the default Nginx welcome page.
Using Nginx
1. Configuration file location
- Main config file:
/etc/nginx/nginx.conf
- Site-specific configs:
/etc/nginx/sites-available/
- To enable a site, create a symlink in
/etc/nginx/sites-enabled/
2. Reload Nginx after making changes
sudo systemctl reload nginx
Installing Apache
1. Update the system
sudo apt update && sudo apt upgrade -y
2. Install Apache
sudo apt install apache2 -y
3. Start and enable Apache
sudo systemctl start apache2
sudo systemctl enable apache2
4. Check Apache status
sudo systemctl status apache2
5. Access the default Apache page
- Open your web browser and go to
http://<your_server_ip>
- You should see the default Apache welcome page.
Using Apache
1. Configuration file location
- Main config file:
/etc/apache2/apache2.conf
- Site-specific configs:
/etc/apache2/sites-available/
- To enable a site, use
a2ensite <site-name>.conf
2. Reload Apache after making changes
sudo systemctl reload apache2
Switching Between Nginx and Apache
If you have both servers installed, you need to stop one before starting the other to avoid port conflicts.
- Stop Nginx:
sudo systemctl stop nginx
- Start Apache:
sudo systemctl start apache2
And vice versa.