How To Install Apache (HTTPD) On Centos 8
Enjoying this content? Subscribe to the Channel!
Mastering CentOS 8: A Step-by-Step Guide to Installing the Apache Web Server (HTTPD)
Welcome to Darren’s Tech Tutorials! Get Your Web Server Running in Minutes
Hey everyone, Darren here! If you’re looking to host your own websites, develop applications, or just learn the fundamentals of Linux server administration, you’ve come to the right place. Today, we’re tackling one of the most fundamental steps in building a web presence: installing the Apache HTTP Server on CentOS 8.
Apache is the world’s most popular open-source web server—it’s free, stable, and incredibly versatile. In this guide, we’ll walk through the process, ensuring your server is installed, running, and configured to start automatically, all using just a few simple terminal commands.
Ready to get started? Let’s turn that fresh CentOS 8 installation into a powerful web host!
Prerequisites
Before we begin the installation process, ensure you have the following:
- A fresh installation of CentOS 8 (or RHEL 8).
- Root or Sudo privileges on your system.
- A stable internet connection.
If you’re running a clean CentOS install, it’s always a good practice to run a quick system update first, though it’s not mandatory for this tutorial:
sudo yum update -y
Step 1: Installing the Apache (HTTPD) Package
In CentOS and RHEL distributions, the Apache web server package is known as httpd. We will use the yum package manager (which utilizes dnf on CentOS 8 systems) to quickly download and install the software and all its necessary dependencies.
To install the Apache package, execute the following command:
sudo yum install httpd
You will be prompted to confirm the download size and dependencies. Type y and hit Enter. Once finished, Apache is successfully installed on your system!
Step 2: Starting and Checking the Apache Service
The installation process only places the files onto your system; it doesn’t automatically start the server. We need to use the systemctl command (the standard service management tool in modern Linux distributions) to activate the web server.
2a. Start the Service
Start the Apache service with the following command:
sudo systemctl start httpd
2b. Check the Status
To verify that the service is running correctly, use the status command. You should look for the output indicating that the service is active (running).
sudo systemctl status httpd
If everything is successful, you will see output confirming that the Apache server is listening for connections.
Step 3: Enabling Apache to Start Automatically on Boot
Currently, if you reboot your CentOS server, Apache will not restart automatically. This is a crucial step for production environments! We need to permanently enable the service so it starts up every time the server boots.
While older systems might use sudo chkconfig httpd on (as seen in some legacy documentation), the correct and modern approach for CentOS 8 is to use the systemctl enable command:
sudo systemctl enable httpd
This command creates the necessary symbolic links so the system knows to start the HTTPD service during the boot sequence.
Step 4: Configuring the Firewall (Allowing Web Traffic)
Even if Apache is running, your server’s built-in firewall will block external connections, preventing users from accessing your website. We need to explicitly open the HTTP port (Port 80) and HTTPS port (Port 443) on the firewall.
We use the firewall-cmd utility for this step:
4a. Allow HTTP Traffic (Port 80)
Add the standard HTTP service permanently:
sudo firewall-cmd --permanent --add-service=http
4b. Reload the Firewall
The --permanent flag ensures the rule persists after a reboot, but we must reload the firewall instantly for the new rules to take effect:
sudo firewall-cmd --reload
Confirmation: Testing Your New Web Server
Congratulations! Your Apache web server is now installed, running, enabled for auto-start, and accessible via the network.
To confirm that the default Apache welcome page is visible, open a web browser on another machine and navigate to the IP address of your CentOS 8 server.
- Example:
http://192.168.1.100
You should see the default CentOS 8 Apache Testing Page. This means your server is live and ready for you to place your website files in the document root directory (usually /var/www/html/).
Summary and Next Steps
You just mastered the foundational step of web hosting on Linux! By following these simple steps, you have transformed a vanilla CentOS 8 installation into a powerful platform ready to serve content to the world.
If you are diving deeper into Linux administration, remember that having quick access to essential commands is key. You can grab my comprehensive Free Linux Cheat Sheet right here: http://eepurl.com/dkRNM9
Did this tutorial help you get your server running? If so, hit that Like button, Subscribe for more clear and accessible tech guides, and let me know what you are planning to build in the comments below! Happy hosting!