Thursday, December 15, 2011

Create multiple virtual hosts in Apache/XAMPP

I am working with both IIS and Apache, so I assigned port number 9000 to apache web server. You may change as you wish.

Step 1: Please modify your httpd.vhosts as follows :
It is locating under D:\xampp\apache\conf\extra

NameVirtualHost *:9000



<VirtualHost *:9000>
ServerAdmin webmaster@localhost
DocumentRoot D:\YourSite
ServerName yoursite


<Directory "D:\YourSite">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:9000>
ServerAdmin webmaster@localhost
DocumentRoot D:\YourSite1
ServerName yoursite1


<Directory "D:\YourSite1">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


<VirtualHost *:9000>
ServerAdmin webmaster@localhost
DocumentRoot D:\xampp\htdocs
ServerName localhost


<Directory "D:\xampp\htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Step 2:
Open your notepad with administrator permission, then go to C:\Windows\System32\drivers\etc


and Open that file called hosts and add your virtual hosts as follows

127.0.0.1 yoursite
127.0.0.1 yoursite1

You don't need to add your localhost. 

Now, you can browse your sites as follows

http://yoursite:9000 which will get you to your site hosted on your apache web server.
http://yoursite1:9000 which will get you to your site1.


If you want to go to your xampp page, just browse like http://localhost:9000, then it will get you to this:

And finally you can get to Microsoft IIS by typing http://localhost in your browser's address bar and go.

If you think there is some mistakes in my post, please leave a comment. Thanks.
Enjoy!!! 

No comments:

Post a Comment