When we are thinking about web server the first name is coming Apache HTTP server, it is most popular in the world for hosting any type of web applications or websites. The most important thing about Apache web server is, it is free and open-source web server and providing a powerful feature for your web application, including support of cross-platform.
In this tutorial, we will explain the process of installing the Apache webserver on Ubuntu 20.04 Operating System.
To perform Apache web server installation on your Ubuntu 20.04 system, you should have user access to login on system and need sudo privileges to execute administrative commands to install applications.
The apache web server packages are inbuilt in Ubuntu repository packages which we can easily install using “apt” command. The only thing is to know the Apache HTTP server’s service is known as “apache2” in Ubuntu Operating System.
To install Apache2 package, first, need to update Ubuntu package index and install apache2 using the following command:
$ sudo apt update
$ sudo apt install apache2
Now, the apache web server is installed and automatically started on your Ubuntu machine. You can check the apache web server’s service status using the following command:
$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-06-24 02:17:57 PDT; 2min 41s ago
Main PID: 4243 (apache2)
Tasks: 55 (limit: 2321)
|-4243 /usr/sbin/apache2 -k start
|-4244 /usr/sbin/apache2 -k start
`-4245 /usr/sbin/apache2 -k start
Configure the Firewall for Apache wen server on Ubuntu 20.04
Nowadays, every system we protesting with Firewall to secure system and services. If Firewall also protests your Ubuntu system, you need to open HTTP (80) and HTTPS (443) port to access the webserver.
Assuming your system is secured using UFW firewall, as most of the Ubuntu machine using UFW firewall, you can open the Apache ports using the following command:
$ sudo ufw allow 'Apache Full'
You can verify the port is open or not on UFW firewall using below command:
$ sudo ufw status
To Action From
-- ------ ----
22/tcp ALLOW Anywhere
Apache Full ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
Apache Full (v6) ALLOW Anywhere (v6)
Verify Apache Installation
To verify apache web server installed adequately and everything working as per the instructions, open the web browser and open your web server by typing your configured domain or IP for this Ubuntu server like “http://<your_domain_or_IP>.
If everything is working and apache webserver running fine, you will get the default Ubuntu 20.04 Apache2 welcome page as shown below:
This page includes some of the necessary information about apache2 web server, configuration file, directory locations and helper scripts.
Apache Configuration File’s Structure
The Apache2 configuration file’s default location is “/etc/apache2/” directory.
The main Apache2 web server configuration file is “/etc/apache2/apache2.conf”.
The Apache listener ports configuration file located at “/etc/apache2/ports.conf”.
The virtual host files configured on Apache webserver stored in the “/etc/apace2/sites-available/” directory. But the configuration file found in this directory is not used by apache unless they linked to the “/etc/apache2/sites-enabled/” directory.
To activate the virtual host file and use it with apache configuration need to create a symlink file from “sites-available” to sites-enabled”. In apache, it is straightforward which can do by using the “a2ensite” command and similarly deactivate the virtual host file or remove symlink file use the command “a2dissite”.
To configure a virtual host file, it is good to follow the standard naming convention. For example, you are configuring virtual host for your domain “testsite.com” then you should keep the virtual host configuration name as “/etc/apache2/sites-available/testsite.com.conf”.
The apache web server’s module configuration files stored in the “/etc/apache2/mods-available/” directory. Similar to “sites-available”, “mods-available” files are usable only when it enabled by creating a symlink to the “/etc/apache2/mods-enabled/” directory using “a2enmod” command, and it disabled by using “a2dismod” command.
The global configuration files for apache web servers stored in the “/etc/apache2/conf-available/” directory. Similar to “sites-available” and “mods-available”, “conf-available” files are usable only when it enabled by creating a symlink to the “/etc/apache2/conf-enabled/” directory using “a2enconf” command, and it disabled by using “a2disconf” command.
To troubleshoot or debug the issue with the apache web server, use the log file for apache server and virtual host. The log file for apache located at “/var/log/apache2/access.log” and “/var/log/apache2/error.log”. To make it easy to troubleshoot an issue with different virtual host need to create different access and error log for each virtual host.
There is no location boundary to create document root directory, you can create at any location but as per suggestion, the most common location for webroot directory is:
You have learned to install Apache web server on your Ubuntu 20.04 server or system. Now your system is ready to deploy a web application using Apache virtual host or use Apache as a web proxy server for your application.
Do you have any doubt, questions or feedback? Feel free to leave a comment.
The CouchDB is an open-source database system, managed by the Apache Software Foundation. It is fault-tolerant, and schema-free NoSQL database management system. CouchDB store data in document or files with JSON data structure. Each document contains fields and...
The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...
Nginx is the most potent, open-source, and a high-performance Web server. It can work as a reverse proxy server also, nowadays, is used by most of the most significant websites on the internet. People pronounced “engine x” for Nginx; it is the hot choice for every...
VirtualBox is an Open Source tool, known as a cross-platform virtualization application or software. It used to run multiple operating systems or virtual machines simultaneously on a single hardware. In this VirtualBox installation tutorial, we will explain the...