How to Install Apache (HTTPD) on CentOS 9 / Redhat 9 / Fedora

Published: December 1, 2025 (Updated: Dec 1, 2025)

Enjoying this content? Subscribe to the Channel!

Lightning Fast Setup: Install & Configure Apache (HTTPD) on CentOS 9!

Hello and welcome to Darren’s Tech Tutorials! I’m Darren O’Neill, and in this comprehensive guide, we’re diving straight into the command line to show you exactly how to install and configure the essential Apache Web Server (known as HTTPD) on CentOS 9.

Whether you’re setting up a new development server or hosting a small website, Apache is the reliable backbone of the web. While this tutorial focuses specifically on CentOS 9, the steps and commands are highly applicable across most Red Hat Enterprise Linux (RHEL) based distributions, including Fedora and other RHEL derivatives.

By the end of this guide, you will have a running, enabled Apache server hosting your very own custom webpage!


Prerequisites

Before we begin, ensure you are logged into your CentOS 9 machine with a user account that has sudo privileges.

Step 1: Installing the Apache HTTPD Package

The first and most crucial step is installing the Apache package, which is named httpd on Red Hat-based systems. We’ll use the dnf package manager for this.

Open your terminal and execute the following command:

sudo dnf install httpd -y
  • sudo: Executes the command with root permissions.
  • dnf install httpd: Tells the package manager to find and install the Apache server.
  • -y: Automatically confirms all prompts, allowing the installation to proceed without interruption.

Once the process finishes, Apache is installed on your system!

Step 2: Starting the Apache Service

Installation is one thing, but running the service is another. We need to tell the system to start the Apache daemon using systemctl.

Use the following command to initiate the web server:

sudo systemctl start httpd

Step 3: Verifying the Installation and Status

After starting the service, let’s make sure everything is running smoothly.

Check Service Status

To confirm that Apache is active and running, check its status:

sudo systemctl status httpd

You should see output indicating the service is active (running).

Browser Test

Now for the fun part! Let’s verify that the web server is accessible.

  1. Open a web browser on your CentOS machine (or a machine with network access to your server).
  2. In the address bar, type: localhost
  3. If successful, you should see a default test page provided by CentOS, confirming that the service is running and ready to serve content!

Step 4: Enabling Apache for System Boot

By default, the service we just started will stop if you reboot your CentOS machine. To ensure that Apache automatically launches every time your system starts up, we need to enable the service.

Execute this simple command:

sudo systemctl enable httpd

You will receive output confirming that the necessary symlinks have been created, guaranteeing that your Apache web server will be ready to go after any future reboot.

Step 5: Creating Your First Custom Web Page

Now that the server is running, let’s replace the default test page with our own custom content.

On CentOS/RHEL systems, the default directory for placing website files is /var/www/html/.

  1. Navigate to the web root directory: (Optional, but helpful)

    cd /var/www/html/
    
  2. Create an Index File: We will use the vi text editor to create our primary welcome file, index.html.

    sudo vi index.html
    
  3. Add Content:

    • Press i to enter INSERT mode.
    • Type your simple HTML content:
      <h1>This is our new test page running on CentOS 9!</h1>
      <p>Darren's Tech Tutorials Apache setup was a success!</p>
      
    • Press Esc to exit INSERT mode.
    • Type :wq (write and quit) and press Enter.
  4. Set Permissions (Crucial Step): Since we created the file using sudo, it often has permissions belonging to the root user. For Apache (which runs as the apache user) to read and serve this file, we must change the ownership.

    sudo chown apache:apache index.html
    

Step 6: Testing the Custom Page

Go back to your web browser and reload the localhost page.

If all steps were followed correctly, you will now see your custom message: “This is our new test page running on CentOS 9!”

You have successfully installed, configured, enabled, and customized the Apache HTTPD web server on your CentOS 9 machine!


Summary and Next Steps

That’s all there is to it! In just a few quick steps, you have a functional, persistent Apache server ready to host your web projects. This foundation allows you to start configuring virtual hosts, installing application stacks (like PHP or Python), and building out your infrastructure.

If you found this guide useful, please subscribe to Darren’s Tech Tutorials for more clear, accessible technology guides. Don’t forget to leave any questions in the comments below—I always do my best to get back to everyone!

Happy coding!