How to Install Apache on Ubuntu

  • Post category:Ubuntu

Apache is one of the most popular open-source web servers in the world, and it’s easy to install and configure on Ubuntu. This guide will walk you through the process of installing Apache on Ubuntu, allowing you to host websites or applications with minimal effort.

Step 1: Update the Package Repository

Before installing any software, it’s important to update the package repository to ensure that you get the latest version of the software.

Step 1.1: Open Terminal

Press Ctrl + Alt + T to open the terminal.

Step 1.2: Update Package List

Run the following command to update the package list:

sudo apt update

Step 2: Install Apache

Now that your package list is updated, you can install Apache using Ubuntu’s default package manager.

Step 2.1: Install Apache2

To install the Apache web server, run the following command:

sudo apt install apache2

Step 2.2: Verify Installation

Once Apache is installed, you should verify that the service is running. Use the command below to check its status:

sudo systemctl status apache2

You should see output indicating that Apache is active (running). This means Apache is successfully installed and running.

Step 3: Adjust Firewall Settings

If you are using the Uncomplicated Firewall (UFW), you will need to allow Apache to communicate through the firewall.

Step 3.1: Allow Apache Through the Firewall

Run the following command to allow HTTP and HTTPS traffic:

sudo ufw allow 'Apache'

Step 3.2: Verify UFW Status

To confirm the firewall settings, use:

sudo ufw status

Ensure that HTTP and HTTPS services are listed as Allowed.

Step 4: Test Apache Installation

Let’s make sure everything is working by accessing the Apache default page.

Step 4.1: Access Apache in a Web Browser

Open your web browser and go to the following URL:

  • Local Machine: If you’re using the same machine where Apache is installed, type http://localhost.
  • Remote Server: If you’re installing Apache on a remote server, replace your_server_ip with your server’s IP address, like so: http://your_server_ip.

You should see the default Apache “It works!” welcome page. This confirms that Apache is properly installed.

Conclusion

By following these steps, you now have Apache installed and configured on your Ubuntu machine. You can start hosting websites, web applications, or dive deeper into Apache configurations like setting up virtual hosts and customizing security settings.

For more guides on web development, server management, and other coding tutorials, explore more on CodeAllow.