Install Apache2 in Ubuntu 18.04/20.04/22.04


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 18.04/20.04/22.04; In this tutorial, you will learn to install Apache2 on Ubuntu 22.04 and 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.

Install Apache2 in Ubuntu 18.04/20.04/22.04

Steps to install, start Apache, Stop Apache, Restart Apache, Reload Apache, Enable Apache, Disable Apache. Adjust the firewall configuration to allow http and https traffic in ubuntu 18.04/20.04/22.04

  • Step 1 – Install Apache2 On Ubuntu

  • Step 2 – Check Apache2 Status
  • Step 3 – Firewall setup
  • Step 4 – Test Install Apache2 Web Server on Ubuntu
  • Step 5 – Manage the Apache2 services
  • Step 5 – Apache2 configuration file

Step 1 – Install Apache2 On Ubuntu

First of all, open your command prompt or cmd and execute the following command into it to update the apt package :

sudo apt-get update

Next, execute the following command into it to install Apache2 On Ubuntu 18.04/20.04/22.04:

sudo apt-get install apache2

Step 2 – Check Apache2 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
                                      Output

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
           `-apache2-systemd.conf
   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

Step 3 – 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
                                  Output

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)

Step 4 – Test Install Apache2 Web Server on Ubuntu

http://your_server_ip

The page includes some basic information about Apache configuration files. 

Step 5 – Manage the Apache2 services

Using the following commands, you can manage the Apache2 services like start, stop, restart, status, reload, enable and disable apache2 services:

Stop Apache2 service:

sudo systemctl stop apache2

Start Apache2 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

Disable the Apache2 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

Step 6 – Apache2 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

Conclusion

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

Recommended Tutorials

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

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?