Install Apache web server on ubuntu

 How to Install Apache web server on ubuntu 20.04 LTS

The Apache Web Server, called Apache is a open-source cross-platform web server software package that turns a computer into an HTTP server. Apache open-source software, its means it can be used and modified freely. Apache is developed and maintained by an open community of developers Apache Software Foundation.

Install Update on Ubuntu

Before installing new software, it’s a good to update ubuntu operating system database to make sure you are accessing the latest versions. use below mention command for update ubuntu server.

$ sudo apt-get update

Install Apache on Ubuntu

Installation of the Apache package on Ubuntu, use the command:

$ sudo apt-get install apache2

When you get message "do you want to continue" type y and press enter.

Open browser and type http://localhost for Verify Apache Installation

Replace Localhost with the IP address of your server. If you are don't know what's the IP address, run the following terminal command:

$ hostname -I | awk '{print $1}'

Configure Ubuntu local Firewall for apache 

By default apache working on 80 port. so if local firewall active on your ubuntu server need to configure UFW firewall to allow traffic on port 80.

1. First check status of UFW firewall on ubuntu server using below mention command.

$ sudo ufw status

2. Use below mention command to know app list. After run the command The terminal respond by listing all available application.

$ sudo ufw app list

3. Use the following command to allow Apache in UFW firewall.

$ sudo ufw allow 'Apache'

4. Now check UFW status using following command.

$ sudo ufw status

After allow the apache application in ufw firewall open browser and type (Your server ip address) and press enter.

How to Start, restart, stop, reload and check status of Apache Service.

If you do any changes in Apache in that case you need to start, restart, stop, reload and check status of Apache. if you need use the following command for start, restart, stop, reload and check status.

1. For check the status of apache.

$ sudo systemctl status apache2.service

2. For Stop the service of apache.

$ sudo systemctl stop apache2.service

3. For start the service of apache.

$ sudo systemctl start apache2.service

4. For restart the service of apache.

$ sudo systemctl restart apache2.service

5. For reload the service of apache. 

$ sudo systemctl reload apache2.service

Apache Configuration Files and Directories


Apache by default creates a document root directory at /var/www/html.

Configuration Files

Website content is stored in the/var/www/html/directory.

Apache creates log files for any errors it generates in the file /var/log/apache2/error.log.

It also creates access logs for its interactions with clients in the file /var/log/apache2/access.log.

Its apache main configuration file /etc/apache2/apache2.conf.

Its apache port configuration file. You can customize the ports Apache port from here. by default its working on 80 /etc/apache2/ports.conf .

Apache virtual host Storage file /etc/apache2/sites-available.

This directory holds websites that are ready for client /etc/apache2/sites-enabled.

Post a Comment