Configure A Virtual Host

General Information

Red Hat preferred method of configuring virtual hosts.

Lab Setup

The following virtual machines will be used:

  • ( → Perform all connectivity tests from here
  • ( → Install Apache Web Server here

Previous Sections Completed

Virtual Host Creation

Examples: Example config at

less /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf

On server2: Create virtual host file

vim /etc/httpd/conf.d/vhosts.conf
<VirtualHost *:80>
  # Basic Info (URL, Document Root)
  DocumentRoot /var/www/html/bluesite
  # Log files
  ErrorLog logs/bluesite-error_log
  CustomLog logs/bluesite-access_log combined

On server2: Create directory and index file for myvhost

mkdir /var/www/html/bluesite
echo '<html><body>This is the <font color=blue>BLUE SITE</font>.</body></html>' > /var/www/html/bluesite/index.html

On server2: Restart httpd

systemctl restart httpd

On server1: Create /etc/hosts entry for new name

vim /etc/hosts server2

On server1: Check virtual host site


  • linux_wiki/configure_a_virtual_host.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)