In this tutorial we’ll learn how to install Apache on CentOS 7. We will also install and configure its prerequisites.The Apache web server is among the most popular and powerful web servers in the world, as a result of its ease of administration and flexibility. In this tutorial we will install Apache on a host which doesn’t have a web server or database server installed.
I recommend to use a minimal CentOS server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.
Install Apache on CentOS 7
Step 1. First, ensure your system is fully up-to-date by running the following:
yum -y install epel-release yum -y update
Step 2. Installing Apache web server.
Installing Apache is as simple as running just one command:
yum -y install httpd
Once Apache has finished installing, the httpd service will need to be started and enabled so it will run automatically when the server starts:
sudo systemctl start httpd sudo systemctl enable httpd
The above settings are only basic settings for running an Apache web server. More specific settings can be found in the Apache configuration file /etc/httpd/conf/httpd.conf. You can use the nano text editor to review and edit various settings in that file:
sudo nano /etc/httpd/conf/httpd.conf
After the editing is done, you should restart the Apache service in order to apply your modifications:
sudo systemctl restart httpd.service
Step 3. Configure Firewall for Apache.
Allow the default HTTP and HTTPS port, ports 80 and 443, through firewalld:
sudo firewall-cmd --permanent --add-port=80/tcp sudo firewall-cmd --permanent --add-port=443/tcp
Congratulation’s! You have successfully install and configured Apache on your CentOS 7 server. Thanks for using this tutorial for installing Apache on CentOS 7 system.