How to Install Apache on CentOS 9 Stream
Apache, commonly referred to as HTTPD for RHEL-based platforms like CentOS, is among the most used web server programs. With its robust capabilities and flexible configuration options, and compatibility with a variety of operating platforms, Apache is the go-to option for many web developers, business owners, administrators, and developers. It’s crucial to remember that Apache can be configured to become a very flexible web server that allows it to accommodate the requirements of large and smaller websites. In this article, we’re going to discuss how to install Apache on CentOS 9 and where to buy CentOS VPS hosting.
Why Use Apache for CentOS Stream?
CentOS Stream is a community-driven distribution of the Red Hat Enterprise Linux (RHEL) operating system, designed to offer a simple and easy development. When you use Apache with CentOS Stream, you’ll be in a position to benefit from new features as well as improvements to bugs while also getting the security and stability offered by the RHEL community. But how to install Apache (HTTPD) on CentOS 9?
Features of Apache (HTTPD) in CentOS Stream
Modular design: Apache has a modular design that makes it easy to expand or eliminate features according to the requirements of your business. You are able to choose to just load the modules you’ll need, which can enhance performance as well as reduce the amount of memory used.
Virtual hosting: Apache permits you to host several websites on a single server with a single IP address. It is also known as virtual hosting. This allows users to conserve the resources of their server and cut costs hosting multiple websites with the same server.
Compatible: Apache can be used with several operating systems, including Linux, Windows, and macOS. It’s easy to set up Apache in your existing environment regardless of your current infrastructure.
Efficiency: Apache is designed to perform efficiently and quickly. It is able to manage high-traffic loads. Due to its capability of handling many concurrent requests, Apache can provide high efficiency even when there are heavy loads.
Safety: Apache offers built-in security tools, like password security, SSL encryption, and setting firewall rules. These functions help protect your data and website safe and minimize the threat of security breaches and attacks.
Flexible Configuration: Apache offers an adaptable configuration that permits you to customize Apache to suit your needs. If you require to set up redirects, virtual hosting, or any other feature, Apache provides a wide selection of options to suit your requirements.
Flexibility: Apache can be extended using a third-party module, providing new features and functions for your servers. Apache may be extended in its functions in case you require support for a particular programming language, for example, PHP, or include additional security options.
In this guide, we’ll walk you through how to install the Apache HTTP server on CentOS 9 stream. So without further ado, let’s begin.
Step 1: Update CentOS Stream
Before the installation of the Apache webserver on the CentOS 9 stream, it is crucial to check the system you are using is kept up with the latest version. This is an essential part of the process since it can prevent issues with compatibility, enhance efficiency, and increase your system’s stability as well as security. To update your system, you must run the following command on your terminal:
sudo dnf upgrade –refresh
When you execute this command, you’ll begin the process of updating by installing and downloading the latest updates to your software as well as security patches. It is recommended to wait until the upgrade process is completed before moving forward in the installation process of Apache. It will make sure that your system is tuned and ready to use Apache without delays or issues with compatibility.
Step 2: Install Apache HTTP Server on CentOS 9 Stream
The installation of Apache (HTTPD) to CentOS Stream is an effortless job to be completed by using the DNF package manager. The DNF package manager can be described as a powerful application that makes it simple to update, install and manage software programs. In order to install Apache (HTTPD), start by running the following command on your terminal:
sudo dnf install httpd
The command starts the installation process. It will download and install the components necessary for running Apache (HTTPD) on your computer. This process will take just less than a couple of minutes, and when it’s completed, Apache (HTTPD) will be completely installed and available for use.
After you’ve successfully installed Apache (HTTPD) to the CentOS Stream system, it’s crucial to kick off the service by enabling it to run automatically on the system’s boot. This will ensure the service Apache (HTTPD) will always be functioning and ready to process web-based requests at any time you turn on your system. If your service isn’t active or disabled as default, you may make use of the following commands in your terminal program to activate the service and then enable it during system boot:
sudo systemctl start httpd
sudo systemctl enable httpd
The initial command, sudo systemctl launch httpd, launches the Apache (HTTPD) service, and the other command sudo systemctl enable httpd, enables the program to start automatically upon system start. If you run the two commands above, be sure you have Apache (HTTPD) remains operational and ready to process Web requests any time the computer is on.
Another alternative to the earlier procedures is to run only one command to initiate Apache (HTTPD) service and allow it to be enabled on system start. The command is executed in the following manner:
sudo systemctl enable httpd –now
The option –now when you run sudo systemctl enable httpd will start the Apache (HTTPD) service instantly and allows it to be run at regular intervals during the system’s boot. This command blends the two distinct commands in the previous steps into a single one, which makes the procedure faster and easier.
Check the operation for Apache (HTTPD) with the following systemctl commands.
systemctl status httpd
This command will provide you with the status that is associated with Apache (HTTPD) service as well as any errors or messages in the system. If you check the status of this service, you will be able to confirm that Apache (HTTPD) has been functioning properly within the CentOS Stream system and also that it’s ready to handle web-based queries.
When you run the command output, you can see details about the server, like its current state, whether it is active or not, and all relevant messages or error messages. This data can be helpful in diagnosing any problems that might occur during the installation or when using Apache (HTTPD) on your computer.
It is essential to regularly check the state of Apache (HTTPD) to make sure it is running efficiently and is able to handle web requests in the way you expect. If you do this, it is possible to quickly spot and fix any problems which may occur and keep your websites functioning smoothly and effectively.
Step 3: Setup the Firewall
In the event that your server has been secured by a firewall, it hasn’t been opened to the HTTP or HTTPS ports. Make sure they are enabled using the commands:
sudo firewall-cmd –permanent –zone=public –add-service=http
sudo firewall-cmd –permanent –zone=public –add-service=https
sudo firewall-cmd –reload
Step 4: Verify Apache Installation
Once successfully installed, open your favorite web browser and enter the URL http://your-IP-addressand you will see the default Apache HTTP server welcome page.
Step 5: Apache Configuration Structure
You must know where to find the directory of configuration files as well as their location in the Apache root directory should you have to alter the configuration.
The entire set of Apache configuration files is stored in the directory /etc/httpd.
The main Apache configuration file is /etc/httpd/conf/httpd.conf.
Files for configuration that end with .conf found in /etc/httpd/conf.d directory are included within the main Apache Configuration file.
Configuration files that are responsible for loading various Apache modules are located in the /etc/httpd/conf.modules.d directory.
Apache Vhost files should end with .conf and must be located in /etc/httpd/conf.d directory. It is possible to have any number of vhosts that you want. The creation of a different setting document (vhost) for each domain makes it more manageable.
Congratulations! You’ve installed Apache successfully. Thank you for following this guide on how to install Apache on CentOS 9. If you need additional assistance or info, we suggest you go to the official Apache site.
Read More: How to Install Apache Web Server on Ubuntu 22.04
Conclusion
Installation of Apache (HTTPD) to CentOS Stream is a simple and easy process that is done in only a few steps. If you’re just starting out or a seasoned user, this tutorial will assist you in getting set up using Apache (HTTPD) in CentOS Stream quickly, or you can simply buy a CentOS VPS server that comes with everything Apache-related. Be sure to configure Apache (HTTPD) in order to satisfy the requirements of your site and to ensure that your system is secured to safeguard your data and website.