YouTube Icon

Code Playground.

How to Install Apache on Ubuntu 18.04


How to Install Apache on Ubuntu 18.04

Apache HTTP worker is the most mainstream web worker on the planet. It is a free, open-source and cross-stage HTTP worker giving incredible highlights which can be reached out by a wide assortment of modules. 

This instructional exercise discloses how to introduce and deal with the Apache web worker on Ubuntu 18.04. 


Prior to beginning with the instructional exercise, ensure you are signed in as a client with sudo advantages . 

Install Apache

Apache is accessible in the default Ubuntu vaults so we can undoubtedly introduce it utilizing the adept bundle the board instrument. On Ubuntu and Debian frameworks the Apache bundle and the administration is called apache2. 

In the first place, update the bundle list and a short time later introduce the apache2 bundle with the accompanying orders: 

sudo apt update
sudo apt install apache2

That is it, Apache is introduced and naturally began. You can check the Apache administration status by giving: 

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-06-24 02:17:57 PDT; 2min 41s 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

Adjust the Firewall

In the event that your Ubuntu worker is secured by a firewall you'll have to open HTTP (80) and HTTPS (443) ports. 

Expecting you are utilizing UFW to deal with your firewall, you can open the essential ports with the accompanying order: 

sudo ufw allow 'Apache Full'

You can check 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)

Verifying the Apache Installation

To check that everything works effectively, open your program, type your worker IP address http://YOUR_IP_OR_DOMAIN/and you will see the default Ubuntu 18.04 Apache invite page as demonstrated as follows: 

The page incorporates some essential data about Apache arrangement records, aide contents, and index areas. 

Apache Configuration File’s Structure and Best Practices

All Apache arrangement documents are situated in the/and so forth/apache2 catalog. 

  • The primary Apache arrangement record is/and so on/apache2/apache2.conf. 
  • The ports that Apache will tune in to are determined in the/and so on/apache2/ports.conf. 
  • Apache Virtual Hosts documents are put away in/and so on/apache2/locales accessible catalog. The arrangement documents found in this registry are not utilized by Apache except if they are connected to the/and so on/apache2/destinations empowered catalog. 
  • To actuate a virtual host you need to make a symlink by utilizing the a2ensite order from the design documents found in the locales accessible registry to the destinations empowered index. To deactivate a virtual host utilize the a2dissite order. 
  • It is a smart thought to adhere to a standard naming show. For instance, on the off chance that your area name is, at that point the virtual host arrangement record should be named/and so on/apache2/destinations accessible/ 
  • Arrangement records which are liable for stacking different Apache modules are situated in the/and so on/apache2/mods-accessible/catalog. Designs in the mods-accessible registry can be empowered by making a symlink to the/and so forth/apache2/mods-empower/index with the a2enconf order and handicapped with the a2disconf order. 
  • Documents containing worldwide setup parts are put away in the/and so on/apache2/conf-accessible/catalog. Documents in the conf-accessible registry can be empowered by making a symlink to the/and so forth/apache2/conf-empowered/with the a2enconf order and crippled with the a2disconf order. 
  • Apache log documents (access.log and error.log) are situated in the/var/log/apache/registry. It is prescribed to have diverse access and blunder log records for each vhost. 
  • You can set your space record root index to any area you need. The most widely recognized areas for webroot include: 
    • /home/<user_name>/<site_name> 
    • /var/www/<site_name> 
    • /var/www/html/<site_name> 
    • /select/<site_name> 


You have effectively introduced Apache on your Ubuntu 18.04 worker. You're currently prepared to begin conveying your applications and use Apache as a web or intermediary worker. 

On the off chance that you have any inquiries or input, don't hesitate to leave a remark.