Wednesday, December 19, 2012

Mass VirtualHosting with apache

MASS Virtual Hosting with Apache

Hosting multiple server without changing the Apache config

config put all the content in the /etc/apache2/httpd.conf
sample config for IP

LimitInternalRecursion 100
AccessFileName .htaccess
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog /var/logs/access_log vcommon
VirtualDocumentRoot /var/www/vhosts/%0
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory /var/www/vhosts/%0>
#DirectoryIndex index.php index.html index.htm index.shtml
Options Indexes FollowSymLinks +Includes
AllowOverride All
Order allow,deny
Allow from all

<Directory /usr/lib/cgi-bin/>
AllowOverride None
# Options ExecCGI
Options +ExecCGI +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
<IfModule mod_access.c>
Order allow,deny
Allow from all

create a directory vhosts

sudo mkdir /var/www/vhosts

suppose you have to create a subdomain so create a directory by name

mkdir nrathi,

and put the contents in the directory if required make host entry and create a directory /var/logs/
mkdir /var/logs
restart the apache to reload the new configuration

sudo service apache2 restart
sudo service httpd restart
make a entry in local if required in host file
in linux
in windows
add the entry like
<ipaddress of server> <hostname>
you are ready to go.

enter the url <hostname>  in browser