In Ubuntu 18.04 How To Install Apache Using CLI

In Ubuntu 18.04 How To Install Apache Using CLI

How To Install Apache on Ubuntu 18.04 Using CLI. In this tutorial , We will study about How to install Apache on Ubuntu 18.04 & We will also look at with install apache, how to manage the Apache services like Start Apache, Stop Apache, Restart Apache, Reload Apache, Enable Apache, Disable Apache. Adjust the firewall configuration to allow http and https traffic.

The Apache HTTP Server, colloquially called Apache, is free and open-source cross-platform web server software, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation .

Install Apache On Ubuntu

Before Install the Apache web server on Ubuntu. First update the apt package :

sudo apt-get update

Install The Apache On Ubuntu with the below command :

sudo apt-get install apache2

Check Apache Status

After the Apache installation process, the web server service should be started automatically, You can check the Apache service status :

sudo systemctl status apache2

apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
   Active: active (running) since Sun 2018-12-31 05:18:45 PDT; 2min 30s ago
 Main PID: 3143 (apache2)
    Tasks: 55 (limit: 2321)
   CGroup: /system.slice/apache2.service
           |-3143 /usr/sbin/apache2 -k start
           |-3144 /usr/sbin/apache2 -k start
           `-3145 /usr/sbin/apache2 -k start

Firewall setup

If a firewall is enabled on our system (like it should), to make the content accessible from outside our machine, you need to open HTTP (80) and HTTPS (443) ports.

You can open the necessary ports with the below command :

sudo ufw allow 'Apache Full'

Verify the change with :

sudo ufw status

Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere
Apache Full                ALLOW       Anywhere
22/tcp (v6)                ALLOW       Anywhere (v6)
Apache Full (v6)           ALLOW       Anywhere (v6)

Test Install Apache Web Server on Ubuntu


The page includes some basic information about Apache configuration files. 

Manage the Apache services

Manage the Apache services using these below commands.  

Stop Apache service :

sudo systemctl stop apache2

Start Apache service :

sudo systemctl start apache2

Stop and then start the service again :

sudo systemctl restart apache2

Reload the Apache service after you made some configuration changes :

sudo systemctl reload apache2

You want to disable the Apache service :

sudo systemctl disable apache2

To re-enable the service to start up at boot :

sudo systemctl enable apache2

Check Apache Status :

sudo systemctl status apache2

Apache configuration file

On most systems if you install Apache on Ubuntu with a package manager, or it came preinstalled, the Apache configuration file is located in one of these locations:

  • /etc/apache2/httpd.conf
  • /etc/apache2/apache2.conf
  • /etc/httpd/httpd.conf
  • /etc/httpd/conf/httpd.conf

If you installed Apache from source it is likely located in /usr/local or /opt, though the config files may have been moved to /etc as usual. Check your build script for more details


You have successfully installed Apache on your Ubuntu 18.04 server. You are now ready to start deploying your applications and use Apache as a web server.

If you have any questions or thoughts to share, use the comment form below to reach us.


My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Vue JS, Angular JS, React Js, WordPress, and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *