linux_wiki:configure_a_virtual_host

This is an old revision of the document!


Configure A Virtual Host

General Information

Red Hat preferred method of configuring virtual hosts.


Lab Setup

The following virtual machines will be used:

  • server1.example.com (192.168.1.150) → Perform all connectivity tests from here
  • server2.example.com (192.168.1.151) → Install Apache Web Server here

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/myvhost.conf
 
<VirtualHost *:80>
  ServerAdmin admin@myvhost.example.com
  DocumentRoot /var/www/html/myvhost
  ServerName myvhost.example.com
  ErrorLog logs/myvhost-error_log
  CustomLog logs/myvhost-access_log combined
</VirtualHost>


On server2: Create directory and index file for myvhost

mkdir /var/www/html/myvhost
echo "The myvhost virtual host index" > /var/www/html/myvhost/index.html


On server2: Restart httpd

systemctl restart httpd


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

vim /etc/hosts
 
192.168.1.151 server2 mysite.example.com


On server1: Check virtual host site

elinks http://myvhost.example.com

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