In this tutorial, we will show you how to install Apache in the sequence of CentOS 9. For those of you who didn’t know, Apache aka Apache HTTP Server is a free, open source, cross-platform HTTP server that includes powerful features and can be extended with a wide variety of modules. It is part of the LAMP (Linux, ApacheMySQL, PHP) stack that powers much of the Internet.
This article assumes that you have at least a basic understanding of Linux, know how to use the shell, and most importantly, host your site on your own VPS. Installation is pretty simple and assumes you are running under the root account, if not you may need to add ‘ sudo
‘ to the commands to gain root privileges. I will show you the step by step installation of the Apache web server on CentOS 9 Stream.
Install on pc Apache on streaming CentOS 9
Step 1. First, let’s start by making sure your system is up to date.
sudo dnf update
Step 2. Installing Apache on the CentOS 9 stream.
By default, Apache is available in the CentOS 9 Stream base repository. Now we run the following command to install Apache HTTP Server to your system:
sudo dnf install httpd httpd-tools sudo dnf install mod_ssl
Once the installation is complete, now enable Apache (to start automatically at system boot), start the web server and check the status with the following commands:
sudo systemctl start httpd sudo systemctl enable httpd sudo systemctl status httpd
To check the Apache version, use the following command to confirm:
httpd -v
Step 3. Configure the firewall.
If your server is protected by the firewall and you have not opened the HTTP and HTTPS ports. Enable them with the following command below:
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 https://your-IP-address
and you will see the default Apache HTTP Server Welcome Page as shown in the following image:
Step 5. Apache Configuration File Structure.
You need to know the location of the configuration files and the Apache root directory in case you need to modify the configuration:
- All Apache configuration files are located in the
/etc/httpd
directory. - The main Apache configuration file is
/etc/httpd/conf/httpd.conf
. - Configuration files ending in
.conf
Located in the/etc/httpd/conf.d
the directory is included in 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 must end with
.conf
and be stored in/etc/httpd/conf.d
directory. You can have as many vhosts as you need. Creating a separate configuration file (vhost) for each domain makes server maintenance easier.
Ref: https://codepre.com/en/como-instalar-apache-en-la-transmision-de-centos-9.html