Knowledge Base
Tutorials
Tutorials
  • How to install Joomla 4.2.2 on Ubuntu 20.04?
  • How to set and execute environment and shell variables in Linux?
  • How to employ Docker containers?
  • How to access PostgreSQL Image?
  • How to add and delete users on Ubuntu 20.04?
  • How to add swap space on Ubuntu 20.04?
  • How to back up, restore, and migrate a MongoDB database on Ubuntu 20.04?
  • How to configure additional SSH keys to your public cloud instance?
  • How to configure static IP on Ubuntu?
  • How to create a CLI with Python Fire on Ubuntu 22.04?
  • How to create a new user and manage permissions in MySQL?
  • How to create an instance with Terraform?
  • How to import and export a MongoDB database on Ubuntu 20.04?
  • How to install 7zip on Ubuntu 20.04?
  • How to install AIDE on Ubuntu 22.04?
  • How to install Anaconda on Ubuntu 20.04?
  • How to install and use Docker on Ubuntu 20.04?
  • How to install and use Elinks on Ubuntu 20.04?
  • How to install and use PostgreSQL on Ubuntu 20.04?
  • How to install Android Studio on Ubuntu 22.04?
  • How to install Angular on Ubuntu 20.04?
  • How to install Ansible on Ubuntu 20.04?
  • How to install Apache Kafka on Ubuntu 20.04?
  • How to install Apache Maven on Ubuntu 20.04?
  • How to install Asterisk on Ubuntu 20.04?
  • How to install Atom Text Editor on Ubuntu 20.04?
  • How to install Blender on Ubuntu?
  • How to install CFEngine3 on Ubuntu 20.04?
  • How to install Code::Blocks on Ubuntu 20.04?
  • How to install Composer on Ubuntu 22.04?
  • How to install Curl on Ubuntu 20.04?
  • How to install Desktop GUI on Ubuntu 20.04?
  • How to install Discord on Ubuntu 22.04?
  • How to install Django on Ubuntu 20.04?
  • How to install Docker Compose on Ubuntu 20.04?
  • How to install ELK on Debian 10 or Debian 11?
  • How to install Fail2ban on Debian 10?
  • How to install FFmpeg on Ubuntu 20.04?
  • How to install Flask on Ubuntu 20.04?
  • How to install Fish Shell in Ubuntu 20.04?
  • How to install Gedit on Ubuntu 20.04?
  • How to install Git on Ubuntu 20.04?
  • How to install Gitea on Ubuntu 20.04?
  • How to install Gitlab on Ubuntu 20.04?
  • How to install Go on Ubuntu 20.04?
  • How to install Google Chrome on Ubuntu 20.04?
  • How to install Gradle on Debian 10?
  • How to install Gradle on Ubuntu 20.04?
  • How to install Grafana on Ubuntu 20.04?
  • How to install Hadoop on Ubuntu 20.04?
  • How to install Homebrew on Linux?
  • How to install JAVA with APT on Ubuntu 20.04?
  • How to install Julia on Ubuntu 20.04?
  • How to install Jupyter on an Ubuntu Linux VM?
  • How to install Kdenlive on Ubuntu 20.04?
  • How to install Logwatch on Ubuntu 20.04?
  • How to install MariaDB on Ubuntu 22.04?
  • How to install Memcached on Debian 10?
  • How to install Microsoft Edge Browser on Ubuntu 22.04?
  • How to install MongoDB on CentOS 7?
  • How to install MongoDB on Linux?
  • How to install Mono on Debian 10?
  • How to Install Mono on Ubuntu 20.04?
  • How to install Mozilla Firefox on Ubuntu 20.04?
  • How to install MySQL on Ubuntu 22.04?
  • How to install Nagios on Ubuntu 20.04?
  • How to install Nginx on CentOS 8?
  • How to install Nginx on Ubuntu 22.04?
  • How to install Node.js on Ubuntu 22.04?
  • How to install NVIDIA CUDA on Ubuntu 20.04?
  • How to install Nvidia Optimus Driver on Ubuntu 22.04?
  • How to install OpenCV on Ubuntu 20.04?
  • How to install Perl on Ubuntu on 22.04?
  • How to install Pacman on Ubuntu 20.04?
  • How to install phpMyAdmin on Ubuntu 20.04?
  • How to install PIP on CentOS 8?
  • How to install Plex media server on Ubuntu 20.04?
  • How to install Podman on Ubuntu 20.04?
  • How to install Poetry on Ubuntu 22.04?
  • How to install Postman on Ubuntu 20.04?
  • How to install ProcessWire on Ubuntu 20.04?
  • How to install PyQuery package on Ubuntu 20.04?
  • How to install Python 3 on Ubuntu 22.04 and set up a programming environment?
  • How to install Python on Windows 10 using UI and Windows command prompt?
  • How to install R on Ubuntu 20.04?
  • How to install Ruby on Rails on Ubuntu 20.04?
  • How to install Ruby on Ubuntu 20.04 and setup programming environment?
  • How to install Rust on Ubuntu 22.04?
  • How to install Samba on Ubuntu 20.04?
  • How to install Skype on Ubuntu 20.04?
  • How to install Rancher on Ubuntu 20.04?
  • How to install Slack on Ubuntu 20.04?
  • How to install Springboot on Ubuntu 20.04?
  • How to install Spyder IDE in Ubuntu?
  • How to install Steam on Ubuntu 20.04?
  • How to install Strapi for Production on Ubuntu 20.04?
  • How to install TeamViewer on Ubuntu 20.04?
  • How to install TensorFlow on Ubuntu 20.04?
  • How to install Apache Web Server on Ubuntu 20.04?
  • How to install the Deno JavaScript Runtime on Ubuntu 20.04?
  • How to install Open LiteSpeed Web Server on Ubuntu 22.04?
  • How to install Sublime Text Editor on Ubuntu 20.04?
  • How to install tix package on Ubuntu 20.04?
  • How to install Vagrant on Ubuntu 20.04?
  • How to install Vim on Ubuntu 20.04?
  • How to install VirtualBox on Ubuntu 20.04?
  • How to install VLC Media Player on Ubuntu 20.04?
  • How to install VMware Workstation Player on Ubuntu 20.04?
  • How to install vscode on Ubuntu 20.04?
  • How to install Webmin on Ubuntu 20.04?
  • How to install Wine on Ubuntu 20.04?
  • How to install WordPress on Ubuntu 20.04?
  • How to install Xibo on Ubuntu 20.04?
  • How to install Zoom on Ubuntu 20.04?
  • How to install Yarn on Ubuntu 20.04?
  • How to keep Ubuntu 22.04 servers updated?
  • How to monitor system authentication logs on Ubuntu 20.04?
  • How to perform basic administration tasks for Storage Devices in Linux?
  • How to set up Jenkins on Ubuntu 20.04?
  • How to setup OpenVPN on Ubuntu 20.04?
  • How to setup time synchronization on Ubuntu 20.04?
  • How to setup a UFW on an Ubuntu or Debian Cloud Server?
  • How to setup SSH keys in Ubuntu 20.04?
  • How to SSH terminal through MobaXterm and PuTTY in Windows?
  • How to Use Ansible to Install and Set Up Docker on Ubuntu 20.04?
  • How to view system users on Ubuntu 20.04?
  • How to make OpenStack accessible through CLI?
  • How to make Block Storage available for Linux?
  • Script for automated incremental backups
  • How to configure a Git repository using Linux CLI?
  • How to enable remote access on MySQL?
  • How to Mount a S3 Bucket on Linux Instance?
  • How to access MySQL database credentials?
  • How to create an incremental backup using CLI?
  • How to set up web-based SQL server on OpenStack instance using SQL image?
Powered by GitBook
On this page
  • Overview
  • Prerequisites
  • Get Started
  • Conclusion

Was this helpful?

How to install Apache Web Server on Ubuntu 20.04?

Overview

The Apache web server is one of the most widely used web servers in the world. It offers a host of powerful capabilities, including modules that can be loaded dynamically, powerful media support as well as full integration with various well-liked programs.

This tutorial will show you how to set up the Apache server on a host running Ubuntu version 20.04.

Prerequisites

There are certain prerequisites that need to be met before you begin.

  • Ubuntu 22.04-equipped system

  • A regular user (non-root) having Sudo privileges

  • Internet connection

  • Knowledge of Command Line Interface (CLI)

Get Started

Step 1: Setting up Apache

Apache can be installed using customary tools (package management) since it is part of Ubuntu's usual software repositories.

Let's start by incorporating the most recent upstream updates by using the following command:

sudo apt update

Now install apache2 package by using the following command:

sudo apt install apache2

After you've confirmed the installation process, apt will now install Apache along with all required components.

Step 2: Checking the Web Server

The latest Ubuntu version 20.04 launches Apache after the installation procedure is complete and the web server will be operational by now.

Ensure that the service runs by verifying it by using the following command:

sudo systemctl status apache2

This result shows that the service launched properly. However, requesting a webpage from Apache is the most effective approach to testing this.

Through your IP address, you can browse the default home page of Apache to make sure the program is functioning properly. There are several ways to obtain your server's IP address from the command prompt interface if you are unsure of it.

Enter the following at the command prompt on your server:

hostname -I

A list of addresses with spaces between them will be returned. To find out if they function, you can test each one on your system.

Utilizing the Icanhazip program is a different choice that should provide you with your IP address:

curl -4 icanhazip.com

Once you know your server's IP address, type it into the address bar of your browser as http://server_ip.

The default Apache web page for Ubuntu version 20.04 should appear:

This page ensures Apache is now operating properly. Additionally, it contains certain fundamental details regarding the locations of key Apache files as well as the directories.

Step 3: Handling the Apache Services

Now that the web server is operational, let's review some fundamental systemctl administration commands.

Type the following to terminate the web server:

sudo systemctl stop apache2

When a web server is halted, enter the following command to restart it:

sudo systemctl start apache2

Restart the service once again after stopping it by typing:

sudo systemctl restart apache2

Most of the time, Apache can reload without losing connections if you are only making configuration-based changes. Use the following command to accomplish this:

sudo systemctl reload apache2

When a server boots up, Apache is set up by default to launch immediately. Disable this behavior if that is not your requirement by using:

sudo systemctl disable apache2

Type the following command to make the service start up again at boot:

sudo systemctl enable apache2

When the server restarts, Apache will now launch automatically.

Step 4: Setting up of Virtual Hosts (Optional)

Using virtual hosts, you can host several domains on a single Apache web server by encapsulating configuration information.

For your domain, make the following directory:

sudo mkdir /var/www/my_domain

Next, use the $USER variable to specify who owns the directory:

sudo chown -R $USER:$USER /var/www/my_domain

Your web roots' permissions should be correct if you haven't modified the umask value, which controls the default file permissions. The following command can be used to check your permissions to determine if they are configured appropriately such that the owner has written, read, and execute permissions while only groups and other users have read and executed permissions:

sudo chmod -R 755 /var/www/my_domain

Next, utilizing nano or your preferred editor, make a test index.html file as follows:

sudo nano /var/www/my_domain/index.html

Add the given template HTML inside:

<html>
    <head>
        <title>Welcome to my_domain!</title>
    </head>
    <body>
        <h1>Success!  The mydomain virtual host is working!</h1>
    </body>
</html>

When you're done, save and shut the file.

It is important to construct virtual configuration files with the appropriate directives to enable Apache to deliver this content. Let's create a new configuration file by using the following command:

sudo nano /etc/apache2/sites-available/my_domain.conf

Paste the configuration block that follows:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName my_domain
    ServerAlias www.my_domain
    DocumentRoot /var/www/my_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

When you're done, save and shut the file.

Let's now enable the file using:

sudo a2ensite my_domain.conf

Let's check for configuration issues next:

sudo apache2ctl configtest

To put your modifications to work, restart Apache:

sudo systemctl restart apache2

Your domain name should now be served by Apache. You may verify this by typing http://my_domain on your browser.

Conclusion

Now that your web server is set up, you have a variety of options for the content types you can offer and the technology you can utilize to give users a richer experience.

PreviousHow to install TensorFlow on Ubuntu 20.04?NextHow to install the Deno JavaScript Runtime on Ubuntu 20.04?

Last updated 1 year ago

Was this helpful?