Article

Table of Contents
Theme:
Was this article helpful?

3  out of  3 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles.

How to Install Apache on CentOS 7

Last Updated: Thu, Mar 9, 2017
CentOS System Admin Web Servers

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 -y

Step 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.conf

Prevent 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.conf

Before 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/tcp

Start the Apache service and set it to auto-start on system boot:

sudo systemctl start httpd.service

sudo systemctl enable httpd.service

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 vi text editor to review and edit various settings in that file:

sudo vi /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

That's it. Thanks for reading.

Want to contribute?

You could earn up to $600 by adding new articles.