You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by George Pitcher <ge...@ingenta.com> on 2005/11/13 13:22:03 UTC

[users@httpd] Getting started - problem with virtual sites (not necessarily 'hosts')

Hi,

After 6 years, I'm moving over from IIS to Apache 2, still on Windows. My
server is on NT4, but my development machine runs Windows XP.

I have a series of websites that share a document root, so that when they
use the url 'www.mysite.com/site_a or www.mysite.com/site_b or
www.mysite.com/site_c, they will be directed to the same directory (under
the server's document root) and I have configured my PHP code so that they
will use configuration files in a site_a, site_b or site_c folder within
that directory.

It took a while to work out how to get this structure to work under IIS and
I have not yet been able to find out how to do this under Apache2.

Can anyone point me in the right direction please?

George in Oxford


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Getting started - problem with virtual sites (not necessarily 'hosts')

Posted by Sean Brown <se...@gmail.com>.
You really only need one virtual host, but with several aliases.  I
assume PHP is taking care of reading the host headers to know whether
it should serve site A or Site B's content.  Like so:

<VirtualHost 192.168.1.10:80>
        ServerName   siteA.com:80
        ServerAlias  siteB.com
        ServerAlias siteC.com
        UseCanonicalName Off
        DocumentRoot /www/website/htdocs
</VirtualHost>

However, if you want separate log files for each, then you'd want
separate virtual hosts (all with the same DocumentRoot:

<VirtualHost 192.168.1.10:80>
        ServerName   siteA.com:80
        UseCanonicalName Off
        DocumentRoot /www/website/htdocs
        ErrorLog /www/website/logs/siteA_error.log
        CustomLog  /www/website/logs/siteA_access.log combined
</VirtualHost>

<VirtualHost 192.168.1.10:80>
        ServerName   siteB.com:80
        UseCanonicalName Off
        DocumentRoot /www/website/htdocs
        ErrorLog /www/website/logs/siteB_error.log
        CustomLog  /www/website/logs/siteB_access.log combined
</VirtualHost>


I hope this helps.

Sean

On 11/14/05, George Pitcher <ge...@ingenta.com> wrote:
> > > This isn't a website with three sub-directories. Its actually
> > five websites
> > > that use the same directory and it isn't the document root.
> > >
> > > When the user come in with the url
> > 'http://www.website.com/site_a/' it takes
> > > them to 'home.php' which breaks down the url and loads the config file
> > > according to the site. This makes site maintenance much easier
> > for me as I
> > > only have one set of templates and scripts to maintain for the
> > five sites.
> > >
> > > Hope this clarifies things.
> >
> > Not really.  Your message is still subject to many different
> > interpretations.  But if the "config file" that you speak of is the
> > php config file, then you should consider taking your question to the
> > php list.
> >
> Joshua,
>
> It isn't a PHP issue. On IIS, I set a virtual site called 'site_a' and
> specify which folder was going to be used. I then set up another 4 virtual
> sites with their own names and they all point to the same folder. I want to
> know how to do that with Apache2. In time, with some success on the sales
> side, I could have hundreds of sites pointing to this folder. PHP simply
> takes car of serving up the appropriate images, admin details etc on a per
> site basis.
>
> Cheers
>
> George
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Getting started - problem with virtual sites (not necessarily 'hosts') SOLVED

Posted by George Pitcher <ge...@ingenta.com>.
Joshua et al,

Thanks for the input guys. I've got it working now.

Cheers

George

> -----Original Message-----
> From: Joshua Slive [mailto:jslive@gmail.com]
> Sent: 14 November 2005 2:54 pm
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] Getting started - problem with virtual sites
> (not necessarily 'hosts')
>
>
> On 11/14/05, George Pitcher <ge...@ingenta.com> wrote:
>
> > It isn't a PHP issue. On IIS, I set a virtual site called 'site_a' and
> > specify which folder was going to be used. I then set up
> another 4 virtual
> > sites with their own names and they all point to the same
> folder. I want to
> > know how to do that with Apache2. In time, with some success on
> the sales
> > side, I could have hundreds of sites pointing to this folder. PHP simply
> > takes car of serving up the appropriate images, admin details
> etc on a per
> > site basis.
>
> Words like "website" and "virtual site" are incredibly vague and don't
> at all describe what you are trying to do.  All I can do is guess.
> Perhaps you want four different url-paths that all point to the same
> directory, as in:
>
> Alias /site_a /path/to/directory
> Alias /site_b /path/to/directory
> Alias /site_c /path/to/directory
> etc..
>
> Then if you need any particular apache configuration, you can use
> <Location /site_a>
> config stuff here
> </Location>
> <Locaiton /site_b>
> config stuff here
> </Location>
> etc..
>
> Your php script can look at the original url-path to determine what
> content to serve.
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Getting started - problem with virtual sites (not necessarily 'hosts')

Posted by Joshua Slive <js...@gmail.com>.
On 11/14/05, George Pitcher <ge...@ingenta.com> wrote:

> It isn't a PHP issue. On IIS, I set a virtual site called 'site_a' and
> specify which folder was going to be used. I then set up another 4 virtual
> sites with their own names and they all point to the same folder. I want to
> know how to do that with Apache2. In time, with some success on the sales
> side, I could have hundreds of sites pointing to this folder. PHP simply
> takes car of serving up the appropriate images, admin details etc on a per
> site basis.

Words like "website" and "virtual site" are incredibly vague and don't
at all describe what you are trying to do.  All I can do is guess. 
Perhaps you want four different url-paths that all point to the same
directory, as in:

Alias /site_a /path/to/directory
Alias /site_b /path/to/directory
Alias /site_c /path/to/directory
etc..

Then if you need any particular apache configuration, you can use
<Location /site_a>
config stuff here
</Location>
<Locaiton /site_b>
config stuff here
</Location>
etc..

Your php script can look at the original url-path to determine what
content to serve.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Getting started - problem with virtual sites (not necessarily 'hosts')

Posted by George Pitcher <ge...@ingenta.com>.
> > This isn't a website with three sub-directories. Its actually
> five websites
> > that use the same directory and it isn't the document root.
> >
> > When the user come in with the url
> 'http://www.website.com/site_a/' it takes
> > them to 'home.php' which breaks down the url and loads the config file
> > according to the site. This makes site maintenance much easier
> for me as I
> > only have one set of templates and scripts to maintain for the
> five sites.
> >
> > Hope this clarifies things.
>
> Not really.  Your message is still subject to many different
> interpretations.  But if the "config file" that you speak of is the
> php config file, then you should consider taking your question to the
> php list.
>
Joshua,

It isn't a PHP issue. On IIS, I set a virtual site called 'site_a' and
specify which folder was going to be used. I then set up another 4 virtual
sites with their own names and they all point to the same folder. I want to
know how to do that with Apache2. In time, with some success on the sales
side, I could have hundreds of sites pointing to this folder. PHP simply
takes car of serving up the appropriate images, admin details etc on a per
site basis.

Cheers

George


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Getting started - problem with virtual sites (not necessarily 'hosts')

Posted by Joshua Slive <js...@gmail.com>.
On 11/14/05, George Pitcher <ge...@ingenta.com> wrote:

> This isn't a website with three sub-directories. Its actually five websites
> that use the same directory and it isn't the document root.
>
> When the user come in with the url 'http://www.website.com/site_a/' it takes
> them to 'home.php' which breaks down the url and loads the config file
> according to the site. This makes site maintenance much easier for me as I
> only have one set of templates and scripts to maintain for the five sites.
>
> Hope this clarifies things.

Not really.  Your message is still subject to many different
interpretations.  But if the "config file" that you speak of is the
php config file, then you should consider taking your question to the
php list.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Getting started - problem with virtual sites (not necessarily 'hosts')

Posted by George Pitcher <ge...@ingenta.com>.
Joshua,

> -----Original Message-----
> From: Joshua Slive [mailto:jslive@gmail.com]
> Sent: 13 November 2005 6:15 pm
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] Getting started - problem with virtual sites
> (not necessarily 'hosts')
>
>
> On 11/13/05, George Pitcher <ge...@ingenta.com> wrote:
> > Hi,
> >
> > After 6 years, I'm moving over from IIS to Apache 2, still on
> Windows. My
> > server is on NT4, but my development machine runs Windows XP.
> >
> > I have a series of websites that share a document root, so that
> when they
> > use the url 'www.mysite.com/site_a or www.mysite.com/site_b or
> > www.mysite.com/site_c, they will be directed to the same
> directory (under
> > the server's document root) and I have configured my PHP code
> so that they
> > will use configuration files in a site_a, site_b or site_c folder within
> > that directory.
>
> I'm not really sure what you mean by "configuration files" in this
> context.  How does this setup differ from any old website that
> contains three sub-directories?
>
> Joshua.
>
This isn't a website with three sub-directories. Its actually five websites
that use the same directory and it isn't the document root.

When the user come in with the url 'http://www.website.com/site_a/' it takes
them to 'home.php' which breaks down the url and loads the config file
according to the site. This makes site maintenance much easier for me as I
only have one set of templates and scripts to maintain for the five sites.

Hope this clarifies things.

Cheers

George


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Getting started - problem with virtual sites (not necessarily 'hosts')

Posted by Joshua Slive <js...@gmail.com>.
On 11/13/05, George Pitcher <ge...@ingenta.com> wrote:
> Hi,
>
> After 6 years, I'm moving over from IIS to Apache 2, still on Windows. My
> server is on NT4, but my development machine runs Windows XP.
>
> I have a series of websites that share a document root, so that when they
> use the url 'www.mysite.com/site_a or www.mysite.com/site_b or
> www.mysite.com/site_c, they will be directed to the same directory (under
> the server's document root) and I have configured my PHP code so that they
> will use configuration files in a site_a, site_b or site_c folder within
> that directory.

I'm not really sure what you mean by "configuration files" in this
context.  How does this setup differ from any old website that
contains three sub-directories?

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org