How to Install Apache Web Server on Ubuntu

   

Apache HTTP Server, commonly known as Apache, is a powerful and widely used open-source web server software. It's renowned for its reliability, flexibility, and scalability, making it a top choice for hosting websites and applications on the internet. In this guide, we'll walk you through the steps to install Apache on an Ubuntu Linux system.

Prerequisites:

Before you begin, ensure you have the following:

- Access to a terminal on your Ubuntu server.

- Sudo privileges or access to the root account.

- An updated package index. You can update it using the following command:

sudo apt update

Step 1: Install Apache

Installing Apache on Ubuntu is straightforward, thanks to the package manager. Open a terminal and run the following command to install Apache:

sudo apt install apache2

You will be prompted to confirm the installation. Type 'Y' and press Enter to continue. The package manager will download and install Apache along with its dependencies.

Step 2: Verify Apache Installation

Once the installation is complete, Apache should start automatically. You can verify this by running the following command:

sudo systemctl status apache2

If Apache is running, you will see output indicating that the service is active and running. You can also check if Apache is functioning correctly by accessing your server's public IP address or domain name in a web browser. You should see the Apache default page, confirming that Apache has been successfully installed.

To exit from the output of the sudo systemctl status apache2 command in your terminal, you can simply press the "q" key on your keyboard. This key is commonly used to quit or exit from various terminal-based utilities and commands.

So, after running sudo systemctl status apache2 and reviewing the status information, if you wish to exit back to the command prompt, just press the "q" key, and you'll return to the terminal prompt where you can continue entering commands.

Step 3: Adjust Firewall Settings

By default, Apache uses port 80 to listen for incoming HTTP requests. If you have a firewall enabled on your Ubuntu server, you may need to open this port to allow web traffic. You can do this using the ufw firewall tool, which is included with Ubuntu.

If ufw is not installed, you can install it by running:

sudo apt install ufw

To enable UFW (Uncomplicated Firewall) on your Ubuntu system, you can follow these steps:

sudo ufw enable

- You will be prompted with a message asking if you want to proceed with the operation because enabling UFW will disrupt existing SSH connections. Type 'y' and press Enter to continue.

- Once enabled, UFW will start automatically at boot and apply the firewall rules you have configured.

Once ufw is installed, you can enable the Apache Full profile, which opens both port 80 (HTTP) and port 443 (HTTPS), by typing:

sudo ufw allow 'Apache Full'

You can verify the changes by running:

sudo ufw status

Step 4: Managing Apache Service

You can use systemctl to manage the Apache service on your Ubuntu server. Here are some common commands:

- To stop Apache:

sudo systemctl stop apache2

- To start Apache:

sudo systemctl start apache2

- To restart Apache:

sudo systemctl restart apache2

-To disable Apache from starting automatically at boot:

sudo systemctl disable apache2

To re-enable Apache to start automatically at boot:

sudo systemctl enable apache2

Conclusion

In this tutorial, you've learned how to install Apache on Ubuntu, open the necessary ports in the firewall, and manage the Apache service. Apache is now ready to serve your web content, whether it be a static website, dynamic web application, or RESTful API. You can further configure Apache to meet the specific requirements of your project and enhance its performance and security.

For the full video tutorial, please watch the video below