Pre-requisites:
A system with CentOS Stream 9 installed and running
Access to a terminal or command line
Root or sudo privileges
First, update your systems package index
dnf update -y
Install Apache
dnf install httpd -y
Once the installation is complete, enable and start the Apache service
systemctl enable httpd
systemctl start httpd
Configure the Firewall to allow http and https traffic
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
Verify Apache Installation
systemctl status httpd
Configure Apache (Optional)
Apache’s configuration files are located in the following directory
/etc/httpd
Run the following command to see the location of the main configuration file
find ‘/etc/httpd’ -name “httpd.conf”
The main configuration file is httpd.conf and should be located in /etc/httpd/conf
Apache error logs
If you encounter any issues, check your Apache error logs located in /var/log/httpd/error_log
When it comes to restarting the Apache server, there are several reasons why you might need to do so. Some of the most common reasons are performance issues, configuration changes, and security updates.
systemctl restart httpd
To stop your web server, type:
systemctl stop httpd
Show Apache version number
httpd -v
List available Apache command line options
httpd -h
Learn about the popular Apache HTTP Web Server on the official site
For information on Apache version 2.4 command line options