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 172.16.1.200

<VirtualHost 172.16.1.200:80>
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>

<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
</IfModule>
</Directory>
</VirtualHost>

create a directory vhosts

sudo mkdir /var/www/vhosts

suppose you have to create a subdomain nrathi.xyz.com so create a directory by name nrathi.xyz.com

mkdir nrathi,xyz.com

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
or
sudo service httpd restart
make a entry in local if required in host file
in linux
/etc/hosts
in windows
c:/windows/system32/drivers/etc/hosts
add the entry like
<ipaddress of server> <hostname>
you are ready to go.

enter the url <hostname>  in browser

No comments:

Post a Comment