Knowledgebase

How to Install Apache on CentOS Print

  • 0

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.

In this article, we will outline the process of installing Apache 2.4 on CentOS 7 Server. Prerequisites: An up-to-date CentOS 7 Server. A sudo user. 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.

Was this answer helpful?
Back

Powered by WHMCompleteSolution