Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Can I make a subdirectory of localhost behave like a root directory for a site?



Dave M G wrote:
> However, I also had a few PHP and HTML files that weren't associated
> with any web site, not in any subdirectory. Just files for testing
> scripts and whatnot.
> 
> Now that I've set up some subdirectories to behave as web sites, I can
> no longer access these other files. If I go to http://localhost, it
> defaults to the first of the virtual web sites I have.
> 
> Now that I'm mapping some directories to behave like web sites, do I
> have to do that for any files I want to access through my local Apache
> server? Or have I made a mistake somewhere that is making the first in
> the list of web sites be the default for localhost?

Hello,

Where are these "files for testing located"? Once you know this check
your apache configuration to see if you have a DocumentRoot directive
that points to that location. e.g If your testing files are in /var/www
then you should have something like this in you config: DocumentRoot
/var/www/

You may have inadvertently deleted your default DocumentRoot when you
implemented virtual directories. The way I have mine setup is to use sub
domains (or fake domains) for most virtual hosts: e.g.

NameVirtualHost *
<VirtualHost *>
  ServerName www.bawdo.com
 DocumentRoot /var/www/main

...

<VirtualHost *>
  ServerName work.bawdo.com
  DocumentRoot /var/www/work

...

If you do not want to setup your own local DNS server then put entries
in your /etc/hosts file and ensure files comes before dns in your
/etc/nsswitch.conf file (e.g.  hosts:          files dns)

This way you can test your multiple sites out using the "real" URLs. For
example if you had two clients: www.fred.com and www.wilma.com you would
setup your hosts file as such:

127.0.0.1 www.fred.com
127.0.0.1 www.wilma.com

Now with the appropriate virtual hosts setup you can work with
http://www.fred.com and http://www.wilma.com locally.

Regards, Keith


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links