The cart is empty

Installing the Apache web server on CentOS 7 is one of the first steps in creating a secure and efficient web platform. Apache, also known as the Apache HTTP server, is open-source software used worldwide for hosting websites. In this article, we will show you how to install Apache on CentOS 7 step by step.

System Preparation

Before installing Apache, make sure your system is up to date. Open the terminal and run the following command:

sudo yum update

This command will update all packages on your system to the latest versions.

Installing Apache

After updating the system, you can proceed directly to installing Apache. Apache is available in the default CentOS 7 repositories, making its installation straightforward. Install Apache using the following command:

sudo yum install httpd

After entering this command, yum will download and install Apache along with all necessary dependencies.

Firewall Configuration

CentOS 7 uses firewalld as the default firewall manager. To allow access to the web server from external networks, you need to open port 80 (HTTP) and port 443 (HTTPS) in your firewall. You can do this by running the following commands:

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

Starting Apache

After configuring the firewall, you can start the Apache web server using the following command:

sudo systemctl start httpd

To verify that Apache is running, you can check its status by running:

sudo systemctl status httpd

Setting Apache to Start Automatically at Boot

It's good practice to set Apache to start automatically when the system boots. You can do this by running the following command:

sudo systemctl enable httpd

Testing Apache

After successfully installing and configuring Apache, you can test if your web server is working by opening a web browser and entering your server's address - typically, it's the IP address of your server. If everything is set up correctly, you should see the default Apache welcome page.

 

You have now successfully installed and configured Apache on CentOS 7. You have the foundation for hosting websites and applications on your server. The next steps could include configuring virtual hosts for hosting multiple websites or installing an SSL certificate to secure your server using HTTPS.