How To Setup the HTTP Web Server on CentOS 7
The HTTP Apache server stands out as the most prevalent web server globally, renowned for its versatility and robustness. Offering a plethora of powerful functionalities, it includes dynamically loadable modules, comprehensive media support, and seamless integration with a wide array of other popular software solutions.
Below are the steps for installing HTTPD (Apache) on CentOS7:
Step 1: Installing HTTPD
Apache is available in CentOS’s default software repositories, making installation a breeze with the yum package manager.
As the root user, execute the following command to install the HTTPD server:
sudo yum install httpd
Once you confirm the installation, yum will proceed to install Apache along with all necessary dependencies.
Step 2: Configuring Firewall
To ensure proper network security, it’s essential to configure the firewall. We’ll enable the HTTP service in firewalld using the following command:
sudo firewall-cmd --permanent --add-service=http
This command will allow HTTP traffic through the firewall, ensuring that the Apache server can communicate over the network.
Certainly! If you intend to configure Apache to serve content over HTTPS, it’s crucial to open port 443 by enabling the HTTPS service. Follow these steps:
Use the following command to enable the HTTPS service:
sudo firewall-cmd --permanent --add-service=https
This command allows traffic over port 443, ensuring secure communication via HTTPS.
To implement the new rules, reload the firewall:
sudo firewall-cmd –reload
Reloading the firewall ensures that the changes take effect immediately, enabling Apache to serve content securely over HTTPS.
Step 3: Your Web Server
After installing Apache, it doesn’t automatically start on CentOS. You’ll need to initiate the Apache process manually. Here’s how:
Start the Apache service using the following command:
sudo systemctl start httpd
To verify if the service is running, execute the command:
sudo systemctl status httpd
If the service is active and running, you’ll see output similar to the following:
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2024-04-09 09:00:00 UTC; 10min ago
Docs: man:httpd(8)
man:apachectl(8)
This confirms that the Apache HTTP Server is up and running successfully.
To confirm that Apache is running properly, you can access the default Apache landing page through your server’s IP address. Follow these steps:
- Get your server’s IP address.
- Enter the IP address into your browser’s address bar using the following format:
http://your_server_ip
For example, if your server’s IP address is 192.168.1.100, you would enter:
http://192.168.1.100
After entering the IP address, you should see the default CentOS 7 Apache web page, which typically looks like the following:
Seeing this page confirms that Apache is running properly on your server.
Step 4: Managing the HTTPD (Apache) Process
Now that your web server is up and running, let’s delve into some basic management commands for Apache:
sudo systemctl stop httpd
sudo systemctl start httpd
sudo systemctl restart httpd
Apache will now start automatically whenever the server boots up. To enable this feature, use the command:
sudo systemctl enable httpd
Conclusion
In the preceding guide, you installed and administered the HTTPD Apache web server. Now that your web server is installed and primed for use, a multitude of opportunities await. You have a plethora of options at your disposal for the types of content you can serve, along with various technologies that can be employed to enhance user experience and create richer online interactions.