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

Please Login to comment
1 Comment threads
1 Thread replies
Most reacted comment
Hottest comment thread
2 Comment authors
CertDepotmichaels Recent comment authors
newest oldest
Notify of

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

Upcoming Events (Local Time)

There are no events.

RHCSA7: Task of the day

Allowed time: 10 minutes.
Create an EXT4 file system mounted by UUID in /etc/fstab under /vol based on a logical volume of 28 logical extents.

RHCE7: Task of the day

Allowed time: 10 minutes.
Change the SSH process configuration to only listen on the 443 port.

Follow me on Twitter

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