In this article, we will outline the process of installing Apache 2.4 on CentOS 7 Server.
Prerequisites:
Step 1: Install Apache using YUM
sudo yum install httpd -yStep 2: Configure Apache
Remove the default Apache welcome page:
sudo cp /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.bak
sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.confPrevent Apache from exposing files in visitors' web browser:
sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.confBefore starting the Apache service, we need to 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/tcpStart the Apache service and set it to auto-start on system boot:
sudo systemctl start httpd.service
sudo systemctl enable httpd.serviceThe 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 vi text editor to review and edit various settings in that file:
sudo vi /etc/httpd/conf/httpd.confAfter the editing is done, you should restart the Apache service in order to apply your modifications:
sudo systemctl restart httpd.serviceThat's it. Thanks for reading.