How to Install the Apache Web Server on CentOS Stream 9

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 http traffic

firewall-cmd --permanent --add-service=http

firewall-cmd --permanent --add-service=http

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

http://httpd.apache.org

For information on Apache version 2.4 command line options

http://httpd.apache.org/docs/current/programs/httpd.html

Learn

Related articles

Getting Started with React

In this guide, we will cover the basics of setting up a local development environment, starting a simple React project, and the basics of how it works.

How to Create Bash Aliases

This tutorial demonstrates how to use the alias command to create personalized shortcuts, which can help you save time and feel less frustrated.

Using Git for PHP Development

This guide walks through the fundamentals of Git. In this tutorial, we will show you Git commands. For Linux you can use the built-in terminal.

How to Connect to MySQL with Laravel

In this guide, you will learn how to connect your Laravel application to your MySQL database.

How do you change the default SSH Port on CentOS Stream 9?

Changing the default SSH port adds an extra layer of security by reducing the risk of your password being cracked from a brute force attack.

What is Inheritance in PHP?

In this tutorial we will explain inheritance in PHP, a mechanism that allows a child class to inherit properties and behaviors from a parent class.