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:

1.2.3.4 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
Success
# firewall-cmd --reload
Success

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
</Directory>

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)
Loading...
2 comments on “RHEL7: How to install an Apache service.
  1. michaels says:

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

Leave a Reply

RHCSA7: Task of the day

Allowed time: 5 minutes.
Create a new user account called "bob" with password "redhat" and set expiration in one week.

RHCE7: Task of the day

Allowed time: 10 minutes.
Set up a default secure MariaDB database called maria and back up the database with mysqldump.

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

Archives