
Apache is an open-source and most popular and used HTTP web server in the world. It powers a large number of websites among the world. Apache HTTP server is cross-platform, powerful, stable, reliable and free web server providing features which can be extended by the wide variety of modules. In this guide, you will learn how to install Apache on Ubuntu 18.04.
Prerequisites
You need Ubuntu 18.04 server with a non-root user account with sudo privileges.
Install Apache on Ubuntu 18.04
Apache is available in the default Ubuntu software repositories so Apache installation is very easy and straightforward to install using apt
package management tool.
First, update the package index and with the below commands:
sudo apt update
On Debian and Ubuntu systems the Apache service and package is called apache2. To install apache2
execute below command :
sudo apt install apache2
Once process is completed, Apache is installed in your Ubuntu server. Apache service will start automatically after installation. You can check Apache service status by typing:
sudo systemctl status apache2
It will show output like below:
Output
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2019-03-23 16:30:47 UTC; 13min ago
Main PID: 491 (apache2)
CGroup: /system.slice/apache2.service
├─ 491 /usr/sbin/apache2 -k start
├─1723 /usr/sbin/apache2 -k start
└─1724 /usr/sbin/apache2 -k start
Adjust the Firewall
If your Ubuntu server is protected by firewall then make sure that your firewall allows HTTP and HTTPS traffic. You can check “Apache Full” profile enables traffic or not :
sudo ufw app info "WWW Full"
Output
Profile: WWW Full
Title: Web Server (HTTP,HTTPS)
Description: Web Server (HTTP,HTTPS)
Ports:
80,443/tcp
It should show that it enables traffic to ports 80
and 443
or you can Allow incoming HTTP and HTTPS traffic for this profile:
sudo ufw allow in "Apache Full"
Verify Apache Installation
To check that everything goes correctly, open your browser and visit your server IP address http://YOUR_SERVER_IP/
It should display a default Ubuntu 18.04 Apache web page as following screenshot :

If you will see this page then your Apache installation is correct.
Manage Apache Processes
Now Apache web server is installed on your machine and up to run so we will see few basic management commands.
You can stop Apache service by type:
sudo systemctl stop apache2
To start again Apache service type:
sudo systemctl start apache2
You can Restart (stop and start) the Apache service by:
sudo systemctl restart apache2
If you have need to make configuration changes, Apache can reload without dropping connections. For this, use this command:
sudo systemctl reload apache2
Also, you can disable the Apache service by typing:
sudo systemctl disable apache2
Again, re-enable the service to start up at boot, type:
sudo systemctl enable apache2
Finally, you have successfully installed Apache on your Ubuntu 18.04 server.
Conclusion
By this guide, You successfully installed Apache on your Ubuntu 18.04 server. You can now start deploying your applications and use Apache as a web server.
Leave a Reply