RHEL7: How to install an Apache service.

Share this link

Installation Procedure

To install an Apache server, execute the following steps:
Install the Web Server package group:

# yum groupinstall -y "Web Server"

Edit the /etc/hosts file and the ip address and fully qualified domain name of the server: server.example.com

Note: This is not mandatory but avoids further warning messages.

Optionally, you can set the ServerName directive in the /etc/httpd/conf/httpd.conf file.

Activate at boot time and start the service:

# systemctl enable httpd
# systemctl start httpd

Firewall Configuration

Add the HTTP service to the firewall configuration and reload it:

# firewall-cmd --permanent --add-service=http
# firewall-cmd --reload

Note: If you plan to use the HTTPS protocol, the command should be # firewall-cmd –permanent –add-service=https

Welcome Page

If you send a request to your new webserver, you will get the welcome page whatever you put into the /var/www/html directory. This is due to the IncludeOptional conf.d/*.conf statement at the end of the /etc/httpd/conf/httpd.conf file that instructs Apache to load the files finishing by *.conf located in the /etc/httpd/conf.d directory.

If you really want to display the content of the /var/www/html directory, you need to go to the /etc/httpd/conf.d directory and remove all the files there (you can also rename them but with an extension different from .conf).

Then, still in the /etc/httpd/conf.d directory, you can create a file (here mywebserver.conf) like below (the name doesn’t matter, only the extension in .conf):

<Directory /var/www/html>
AllowOverride None
Require all granted

Now, every file created in the /var/www/html directory will be displayed by the webserver.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Leave a Reply

2 Comments on "RHEL7: How to install an Apache service."

Notify of

Sort by:   newest | oldest
1 year 5 months ago

Just tell you that the configuration file is httpd.conf (with the “d”).


RHCSA7: Task of the day

Allowed time: 5 minutes.
Set up time services pointing to default time servers.

RHCE7: Task of the day

Allowed time: 8 minutes.
Set up an iScsi target based on a fileio backstore of 100MB called /opt/shareddata with CHAP authentication (username=usr/password=pwd), xfs filesystem and standard firewall configuration.

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...