Virtual hosts are used to run more than one web site on a single machine.
Virtual hosts can be “IP-based”, meaning that you have a different IP address for every web site, or “name-based”, meaning that you have multiple names running on each IP address.

I want to show you one of mine scripts for easy create virtual hosts in Debian Squeeze or ubuntu.

#!/bin/bash
VHOST_CONF=/etc/apache2/sites-enabled/
ROOT_UID=0
NOTROOT=87
WWW_ROOT=/var/www/

# Check if is root
if [ "$UID" -ne "$ROOT_UID" ]
then
echo “You must be root to run this script.”
exit $NOTROOT
fi

if [ -n "$1" ]
then
DOMAIN=$1
else
echo “You must provide a full domain name for this site, i.e. ‘example.com’ ”
echo -n “Run this script like ./script example.com .”
exit
fi

#Create document root site folder
mkdir -p $WWW_ROOT/$DOMAIN

Continue Reading…

Page 1 of 11