Step by Step Guide to Installing Apache on CentOS 7

   

Apache HTTP Server, often referred to simply as Apache, is one of the most widely used web servers globally. It's renowned for its reliability, robust performance, and open-source nature. If you're looking to set up a web server on CentOS 7, Apache is an excellent choice. Here's a detailed guide on how to install Apache on CentOS 7:

Step 1: Update System Packages
Before installing Apache, it's crucial to ensure that your system's package repository is up-to-date. Open a terminal or SSH session and execute the following commands:


sudo yum update

This command will update your CentOS system's repository and ensure that you have the latest versions of packages installed.

Step 2: Install Apache

Once your system packages are updated, you can proceed with installing Apache. Execute the following command in your terminal:


sudo yum install httpd

This command will download and install the Apache HTTP Server along with its dependencies.

Step 3: Start Apache and Enable Auto-Start
After Apache is installed, start the service using the following command:


sudo systemctl start httpd

To ensure that Apache starts automatically upon system boot, enable it as a systemd service:


sudo systemctl enable httpd

Step 4: Adjust Firewall Settings

If your CentOS system is running a firewall, such as firewalld, you need to allow HTTP traffic through the firewall to enable web access. Execute the following command to add a rule allowing HTTP traffic:


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


After adding the rule, reload the firewall to apply the changes:


sudo firewall-cmd --reload


Step 5: Verify Apache Installation
To confirm that Apache has been installed and is running correctly, open a web browser and enter your server's IP address or domain name in the address bar. You should see the default Apache test page, indicating that Apache is successfully installed and accessible.

Step 6: Additional Configuration (Optional)
You may want to customize Apache's configuration to suit your specific requirements. The main configuration file for Apache on CentOS 7 is located at /etc/httpd/conf/httpd.conf. You can edit this file using a text editor like nano or vi to make changes such as configuring virtual hosts, setting up SSL/TLS, or adjusting access controls.

Conclusion
Installing Apache on CentOS 7 is a straightforward process that can be completed in just a few simple steps. By following this guide, you'll have a fully functional Apache web server up and running, ready to serve your web content to the world. Whether you're hosting a personal website, a blog, or a business application, Apache on CentOS 7 provides a stable and reliable platform for your web hosting needs.

The full tutorial including all the necessary commands can be found in the video below: