How to Install The Latest Apache Server (httpd) on Centos 7
To install the latest Apache HTTP Server (httpd) on CentOS 7, you can follow these simple steps.
There is a great custom repo created by CodeIT It provides latest versions of web servers.
-
Update Your System:
It's a good practice to ensure that your CentOS 7 system is up-to-date before installing any software. Open a terminal and run the following commands:
sudo yum update
-
Install Apache (httpd):
You can install Apache using the
yum
package manager. To ensure you get the latest version, you may need to add the EPEL (Extra Packages for Enterprise Linux) repository first. Here's how to do it:sudo yum install epel-release
Enable the CodeIT repository.
cd /etc/yum.repos.d && wget https://repo.codeit.guru/codeit.el`rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)`.repo
Now you can Install the latest Apache package.:
sudo yum install httpd
-
Start and Enable Apache:
After the installation is complete, you can start Apache and enable it to start automatically on boot:
sudo systemctl start httpd sudo systemctl enable httpd
-
Configure Firewall:
If you have a firewall running on your CentOS 7 server, you'll need to allow HTTP traffic (port 80) to pass through. You can use the following command to open the HTTP port:
sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --reload
-
Test Apache:
To verify that Apache is installed and 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.
If you don't know your server's IP address, you can find it by running:
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
-
Configuration Files:
Apache's main configuration file is located at
/etc/httpd/conf/httpd.conf
. You can edit this file to customize Apache's settings according to your needs. Make sure to restart Apache after making any changes:sudo systemctl restart httpd systemctl enable httpd
-
Document Root:
By default, Apache serves files from the
/var/www/html/
directory. You can place your website files in this directory or configure Apache to use a different document root as needed.
Congratulations! You've installed the latest Apache HTTP Server on CentOS 7. You can now begin configuring and hosting your websites.