To install the Apache web server on Ubuntu, follow these steps:

1. Update the package repositories

First, make sure that the repository list is up to date:

sudo apt update
sudo apt upgrade

2. Install Apache

Run the following command to install Apache:

sudo apt install apache2

3. Enabling and starting the Apache service

Enable the service to run automatically at boot time:

sudo systemctl enable apache2

Click now to buy quality and economical virtual servers (from 20 different countries)

Start or check the status of the service:

sudo systemctl start apache2
sudo systemctl status apache2

4. Firewall Settings (Optional)

If UFW firewall is enabled on your system, you need to open access to the ports required by Apache:

  • Open full access to Apache:
sudo ufw allow 'Apache Full'

Or just the HTTP port (80):

sudo ufw allow 'Apache'

Enable UFW:

sudo ufw enable

5. Checking Apache Installation

Open your browser and enter the following address:

http://localhost

Or if you are using IP:

http://your-server-ip

You should see the Apache2 Ubuntu Default Page.

6. Managing Files and Directories

Apache's default folder for hosting files:

/var/www/html/

You can place your website files in this folder.

Other useful commands:

Stopping the service:

 

sudo systemctl stop apache2

Restarting the service:

sudo systemctl restart apache2

Reloading the configuration without stopping:

sudo systemctl reload apache2

The end!

Thank you for following along with Radib until the end of this tutorial. Apache is now installed on your system and ready to use.

Was this answer helpful? 209 Users Found This Useful (209 Votes)