Apache HTTP Server (httpd) is one of the most widely deployed web servers in the world and is fully supported on RHEL 8 through the AppStream repository. After installing the httpd package, you will configure the firewall, review the main configuration file, and serve content from a custom document root. This tutorial covers everything you need to get Apache running on RHEL 8.
Prerequisites
- A RHEL 8 server with root or sudo access
- A registered RHEL 8 subscription with access to the AppStream and BaseOS repositories
- Basic familiarity with the Linux command line
- Ports 80 and 443 not blocked by an external firewall
Step 1 — Install Apache HTTP Server
Install the httpd package using dnf:
sudo dnf install -y httpd
Confirm the installed version:
httpd -v
Step 2 — Enable and Start the httpd Service
Enable Apache to start at boot and bring it up immediately:
sudo systemctl enable --now httpd.service
Check that the service is running:
sudo systemctl status httpd.service
The output should show Active: active (running).
Step 3 — Open the Firewall for HTTP and HTTPS
Allow incoming HTTP and HTTPS connections through firewalld:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
List active services to verify:
sudo firewall-cmd --list-services
Step 4 — Review the Main Configuration File
Apache’s primary configuration file is /etc/httpd/conf/httpd.conf. Open it to examine its layout:
sudo cat /etc/httpd/conf/httpd.conf
Important directives to understand:
- ServerName — set this to your server’s hostname or IP (e.g.,
ServerName www.example.com) to suppress the fully qualified domain name warning - DocumentRoot — defaults to
/var/www/html; this is where Apache serves files from - IncludeOptional conf.d/*.conf — loads virtual host and module configuration files from
/etc/httpd/conf.d/
Set your ServerName directive now if you have not already:
echo "ServerName 127.0.0.1" | sudo tee /etc/httpd/conf.d/servername.conf
Step 5 — Test the Default Page and Check Logs
Create a simple test page in the default document root and test it:
echo "Apache is working
" | sudo tee /var/www/html/index.html
curl http://localhost
Apache log files are stored in /var/log/httpd/:
/var/log/httpd/access_log— records all incoming requests/var/log/httpd/error_log— records errors and warnings
Tail the error log to watch for issues in real time:
sudo tail -f /var/log/httpd/error_log
Step 6 — List Loaded Modules
Apache’s functionality is extended through modules. To list all currently loaded modules:
sudo httpd -M
Modules in the output marked (shared) are dynamically loaded. You can enable or disable modules by adding or removing their configuration files from /etc/httpd/conf.modules.d/. After any configuration change, reload Apache to apply it:
sudo systemctl reload httpd.service
Conclusion
You have installed Apache HTTP Server on RHEL 8, opened the necessary firewall ports, reviewed the main configuration file, and verified the server is serving content correctly. Apache is now ready to host websites and web applications on your RHEL 8 system.
Next steps: How to Configure Apache Virtual Hosts on RHEL 8, How to Secure Apache with Let’s Encrypt on RHEL 8, and How to Configure Apache as a Reverse Proxy on RHEL 8.