Xampp/virtual hosts

I’m stumped here, have been trying since yesterday to figure this out… like most people, I suppose, I need to run more than one website on xampp (just like I do on Tomcat…) but I’m finding it difficult to set it up: example of a virutal host for my installation of xampp is as follows in C:\xampp\apache\conf\extra\httpd-vhosts.conf:

##<VirtualHost *:80>
##ServerAdmin postmaster@dummy-host2.localhost
##DocumentRoot “C:/xampp/htdocs/dummy-host2.localhost”
##ServerName dummy-host2.localhost
##ServerAlias www.dummy-host2.localhost
##ErrorLog “logs/dummy-host2.localhost-error.log”
##CustomLog “logs/dummy-host2.localhost-access.log” combined
##</VirtualHost>

following this example, did:

<VirtualHost *:80>
ServerAdmin webmaster@clientA.localhost
DocumentRoot “C:\Documents and Settings\<me>\My Documents\clientA\html”
ServerName clientA.localhost
ServerAlias www.clientA.localhost
ErrorLog “logs/host.clientA.com-error_log”
CustomLog “logs/clientA.localhost-access.log” combined
</VirtualHost>

but don’t see where you tell it what the actual dir is where the files are for the website, like in this example:

http://sawmac.com/xampp/virtualhosts/

following example in above url, I did:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot “C:\Documents and Settings\<Me>\My Documents\clientA\website”
ServerName clientA.local
<Directory “C:\Documents and Settings\<Me>\My Documents\clientA\website”>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

but nothing I try seems to work… (don’t know what version of xampp/apache I have, where do you look this up? at any rate installed very recently, whatever is latest here, www.apachefriends.org/en/xampp-windows.html)

how come example in my C:\xampp\apache\conf\extra\httpd-vhosts.conf doesn’ thave <Directory>…</Directory>? (and what is diff betw DocumentRoot and Directory? )

I did do what you’re supposed to do in that ‘hosts’ file (namely add “127.0.0.1 clientA.local” )

thank you…

I just stick each site into a different folder in htdocs and call from the address bar:
http://localhost/website1/
http://localhost/website2/

I think your document root is wrong as all the the files need to be in the htdocs folder ?

I tried that, but when you do that, the links/paths inside the site that start with “/” don’t work, which means sites created this way are not technically webapps… I need to make the virtual hosts thing work (this is so much simpler in Tomcat; in Tomcat you just put all your webapp in ‘webapps’ folder and that’s it…)

(according to instructions here, http://sawmac.com/xampp/virtualhosts/ the files for the can be anywhere in yr computer… unless I missed something…)

thank you…

for HTML only websites, sure you can have them anywhere on your computer.
But for PHP based sites, they must be placed within the xampp/htdocs folder.

Thats interesting as I did not know you could do that - anyway worked OK for me :cool:

The only thing I think I did differently to you was I used * as per the instructions in two places and not *:80 as per the XAMPP examples.

Had a bit of a fight modifying the hosts file in the end I had to save as a text file, delete the original and then remove the .txt from the text file :shifty:

P.S. Thanks for that zalucius the instructions did say:

The first five lines of code turn on the Virtual Host feature on Apache, and set up the C:\xampp\htdocs folder as the default location for http://localhost. That’s important since you need to be able to access the XAMPP web pages at http://localhost/ so that you can use PHPMyAdmin.

But nothing about php.

Maybe we should move this to the Server Management forum?

Sounds OK to me Anthony as it is not really php related.

well, they’re html-only sites now, but once I’m running them on PHP they will be PHP sites, and all .html files will be converted to .php files…

oh brother… this is frustrating… ok, following instructions here,
http://sawmac.com/xampp/virtualhosts/

this is exaclty what I have now:

NameVirtualHost *
<VirtualHost *>
DocumentRoot “C:\xampp\htdocs”
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot “C:\Documents and Settings\Me\My Documents\clientA\website”
ServerName clientA.local
<Directory “C:\Documents and Settings\Me\My Documents\clientA\website”>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

(changed locations of files, of course, to where they are in my computer, and put correct name of website…) but it’s just not working… when load this in browser, http://clientA.local/, get: Oops! Firefox could not find cilentA.local (no problem loading site at the root, i.e., in C:\xampp\htdocs\ (http://localhost/))

would very much appreciate some help… thank you…

Hey Maya90
I found myself asking these questions last nite and I came across the same instructions from sawmac, but this site actually hit the nail on the head for me. http://www.5min.com/Video/How-to-Create-Multiple-Websites-Using-ApacheXAMPP-245252120

You must create instances of htdocs folders (htdocs2, htdocs3) and add your new domain folder.

Unfortunately the website for nerdnetworks007 is not up and running in order to copy his code, but I copied it from his screen cast.

You must also go into the windows\system32\drivers\etc folder and add
127.0.0.1 myfirstdomain.local
127.0.0.1 myseconddomain.local
ect…

NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot “C:/xampp/htdocs”
<Directory “C:/xampp/htdocs”>
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig Fileinfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

My First Domain

<VirtualHost *:80>
ServerName myfirstdomain.local
ServerAlias www.myfirstdomain.local
DocumentRoot “C:/xampp/htdocs”
</VirtualHost>

My Second Domain

<VirtualHost *:80>
ServerName myseconddomain.local
ServerAlias www.myseconddomain.local
DocumentRoot “C:/xampp/htdocs2”
<Directory “C:/xampp/htdocs2”>
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig Fileinfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

My Third Domain

<VirtualHost *:80>
ServerName mythirddomain.local
ServerAlias www.mythirddomain.local
DocumentRoot “C:/xampp/htdocs3”
<Directory “C:/xampp/htdocs3”>
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig Fileinfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

I am now in the process of creating a local server in between watching the football games. I will post back with my progress.
Hope this helps…