In this article, we will have explained the necessary steps to install and configure Apache on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
Apache HTTP Server, also known as “Apache.” It is a web server famous for promoting the growth of the World Wide Web. Apache is the opensource, cross-platform, powerful, stable, reliable and free web server providing features which can be extended by the wide variety of modules. It is also used as a reverse proxy server in different scenarios.
Install Apache on CentOS
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo yum update
Step 2. Install Apache on CentOS 8.
Apache is available in the default CentOS repositories, run following command to install Apache:
sudo yum install httpd
Run and enable the Apache webserver to start after reboot:
sudo systemctl enable httpd sudo systemctl start httpd
You can also check the version of your web server in order to make sure that it was installed correctly:
Following are the Apache important files and directories:
- All Apache configuration files are located in the
- The main Apache configuration file is
- Configuration files ending with
.conflocated in the
/etc/httpd/conf.ddirectory are included in main Apache configuration file.
- Configuration files that are responsible for loading various Apache modules are located in the
- Apache vhost files must end with
.confand be stored in
/etc/httpd/conf.ddirectory. You can have as many vhosts as you need. Creating a separate configuration file (vhost) for each domain makes the server easier to maintain.
- – It is a good practice to follow a standard naming convention. For example, if the domain name is
mydomain.comthen the configuration file should be named
- Apache log files (
error_log) are located in the
/var/log/httpd/directory. It is recommended to have a different
errorlog files for each vhost.
Step 3. Adjust the Firewall for Apache Web Server.
During the installation, Apache creates firewalld service files with predefined rules for allowing access to HTTP (80) and HTTPS (443) ports:
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
That’s all you need to do to Install Apache Web Server on CentOS 8. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.