How do I add a new site under Htdocs?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How do I add a new site under Htdocs?

Postby rseiler » 27. September 2009 07:55

I've just got 1.7.2 up and running.

http://localhost or http://localhost/xampp bring up the Xampp site just fine. However, I have another site, which I've copied into a directory alongside xampp's. So, I have:

c:\xampp\htdocs\xampp
c:\xampp\htdocs\mysite

I want to browse mysite with this URL, and that doesn't quite work when I try it because links within it have no concept of the "mysite" directory:
http://localhost/mysite

I realize that I can edit httpd.conf to change "DocumentRoot" to point directly to my site, but then xampp's site breaks.

I also realize that I can move my site into the root of htdocs, and that works perfectly (when using http://localhost), but then what do I do when I have another site? I'd like to learn that sooner rather than later.

What do I have to change/add in order to allow me to browse http://localhost/mysite and yet still have access to http://localhost/xampp?
rseiler
 
Posts: 3
Joined: 27. September 2009 07:40

Re: How do I add a new site under Htdocs?

Postby Izzy » 27. September 2009 08:20

Apart from changing all the links in your web site, which is often nigh impossible, then perhaps your best solution would be to use a VirtualHost in the xampp\apache\conf\extra\httpd-vhosts.conf file - this method has a huge amount of flexibility and would do what you want quit easily.

This method would also allow you to use http://mysite instead of http://localhost/mysite and still be able to access XAMPP at either http://localhost or http://localhost/xampp - if you prefer, you can even place your mysite folder anywhere on your PC rather than under the htdocs folder by using this VirtualHost method.

Do an Advanced forum search and select the XAMPP for Windows forum then search for Key word vhost or virtualhost
(you may use my name Izzy in the Author box if you wish to narrow the huge amount of posts on this subject)
Select All available in the characters of posts box to see all the posts not just an abbreviated post.

After you give that a go and perhaps get stuck, then by all means post back with a copy and paste of your code in the httpd-vhosts.conf file so it can be checked out.

Good Luck.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: How do I add a new site under Htdocs?

Postby rseiler » 27. September 2009 15:37

Thanks very much, and I will try that later today.

I notice the VirtualHost file is just a dummy file right now, when I expected to see the Xampp site already configured in it. Instead, the Xampp site seems to know where it should be by virtue of the httpd-xampp.conf settings file, which appears to have multiple uses, perhaps why it was used instead of VirtualHost. Are separate settings files normally used, or is that an exception?
rseiler
 
Posts: 3
Joined: 27. September 2009 07:40

Re: How do I add a new site under Htdocs?

Postby Izzy » 27. September 2009 22:46

An alternative to using a VirtualHost is to use an Alias Directive placed in the httpd-xampp.conf file and simply follow an example that is already in use in that configuration file for example the Alias for Webalizer - again using an Alias allows you to place your web site folder anywhere on your PC.

The docs for the Alias Directive can be found here:
http://httpd.apache.org/docs/2.2/mod/mo ... html#alias

Also a similar forum search for alias may find many results.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: How do I add a new site under Htdocs?

Postby rseiler » 27. September 2009 23:13

OK, good to know.

I followed the earlier advice about a virtualhost, and after some hiccups found that it worked.

Just one follow-up question on <Directory>, since I've seen some variation on it in the examples.

Posting just the lines relevant to the question, sometimes I see these included:
Code: Select all
Options Indexes +FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all

But other times I see just those last two lines. I've looked up the definitions of the first two lines but am unclear whether they're worthwhile.

Thanks
rseiler
 
Posts: 3
Joined: 27. September 2009 07:40

Re: How do I add a new site under Htdocs?

Postby Izzy » 27. September 2009 23:40

When ever you use a directory outside of the DocumentRoot (the htdocs folder in a default XAMPP) you have to set those permission lines because the defaults set in the httpd.conf file are very restrictive, for obvious security reasons...

...but if the folder is in the htdocs tree then the permission are covered for the htdocs and all sub-directories <Directory> directive and so don't need to be specified again - take a look in the httpd.conf file in between all the comments. ;)

The order of Apache reading these conf files is first the httpd.conf file is read then those in the extra folder are read and the settings will override those duplicated settings in the httpd.conf file.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 138 guests