Note: This is an RHCE 7 exam objective.


First, follow the instructions to install an Apache web server.

Note: Don’t forget to install the httpd-manual package. This could help you a lot with any syntax issue.

Configuration Procedure

Let’s assume your website is called

Create the /var/www/html/ directory:

# cd /var/www/html
# mkdir

Create an index.html file and assign the correct SELinux context:

# echo "This is a test." >
# restorecon -R

Create the /etc/httpd/conf.d/vhosts.conf file and paste the following lines:

<VirtualHost *:80>
DocumentRoot /var/www/html/
ErrorLog logs/
CustomLog logs/ common

Optionaly, rename the /etc/httpd/conf.d/ssl.conf file, otherwise you get an additional non-working https virtual host displayed in the configuration.

# cd /etc/httpd/conf.d; mv ssl.conf ssl.conf2

Check the validity of the configuration:

# apachectl configtest
Syntax OK

Note: You can also type: # httpd -t

Restart the httpd service:

# apachectl restart

Note1: You can also type: # systemctl restart httpd Note2: For minor configuration changes, it is also possible to restart the Apache daemon without losing the current connections: # apachectl graceful

Check the virtual host(s) configuration:

# httpd -D DUMP_VHOSTS
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server (/etc/httpd/conf.d/vhosts.conf:1)
         port 80 namevhost (/etc/httpd/conf.d/vhosts.conf:1)
         port 80 namevhost (/etc/httpd/conf.d/vhosts.conf:1)

Testing Time

Check the configuration:

# yum install -y elinks
# elinks