You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Michael Olds <Mi...@themozone.net> on 2002/12/28 02:29:40 UTC

[users@httpd] ScriptAlias two Virtual Host Directories

Hello,

I am trying to get ScriptAlias working for two separate Named Virtual Hosts
and nothing I am doing is working.

This is a Debian Woody stock setup, with 2 users (both me) with two domains.
At present the server serves html pages properly to both domains, but will
execute CGI only for the first domain. I have tried a number of different
configurations the last of which is this:

(The Directory/File structure is the same for both domains, and the
users/groups and permissions are both exactly the same)

<Directory "/www/usr-1/public_html/cgi-bin">
   AllowOverride None
   Options ExecCGI
   Order allow,deny
   Allow from all
</Directory>

Same same for user2...

NameVirtualHost 000etc

<VirtualHost 000etc>
   UseCanonicalName off
   ServerName www.domain1.net
   ServerAlias *.domain.net domain.net domain
   DocumentRoot "/www/usr-1/public_html"
   ServerAdmin me@mine
   ScriptAlias /cgi-bin/ /www/usr/public_html/cgi-bin/
</VirtualHost>


<VirtualHost 000etc>
   UseCanonicalName off
   ServerName www.domain2.net
   ServerAlias *.domain.net domain.net domain
   DocumentRoot "/www/usr/public_html"
   ServerAdmin me@mine
   ScriptAlias /cgi-bin/ /www/usr-2/public_html/cgi-bin/
</VirtualHost>

The error I am getting is "No such file or directory" when I try to execute
a script from usr2s cgi-bin. In the main configuration the language speaks
of Script Aliases (plural) but I have not found one example of the use of
more than one in any of the documentation.

I have read the relevant materials in two books, asked on the Debian User
board, looked at the FAQ and docs here and this looks like it should be
working. So I am thinking there is something at a higher level than the
configuration file that I have incorrectly set up. Does anyone have any
ideas?

Best Wishes!
Mike Olds www.buddhadust.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] ScriptAlias two Virtual Host Directories

Posted by Michael Olds <Mi...@themozone.net>.
Ok I arrived at the idea I must have had it wrong because on one occasion it
went to the wrong directory when there was no script there, so it couldn't
have read the script first.

Now we're back at what are these guys doing that have what you call "the
same ScriptAlias" in each of two VirtualHost directories.

How does that work.


Best Wishes!
Michael Olds
Los Altos   California
http://www.BuddhaDust.org




-----Original Message-----
From: Gary Turner [mailto:kk5st@sbcglobal.net]
Sent: Saturday, December 28, 2002 1:09 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] ScriptAlias two Virtual Host Directories


Michael Olds wrote:

<snip>
>
>OK! Now I understand. In my own words, the server doesn't even see the URL
>called by the user's browser; it goes from the user's browser to the
script,
>from the script to the server; from the server through the ScriptAlias to
>the cgi-bin.

Close.  Apache sees the URL, goes where it says to (via the alias) and
since it is a ScriptAlias, causes the script to execute.  It then
returns the result to the client.

--
gt                  kk5st@sbcglobal.net
 If someone tells you---
 "I have a sense of humor, but that's not funny."
                                  ---they don't.

---------------------------------------------------------------------
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] ScriptAlias two Virtual Host Directories

Posted by Gary Turner <kk...@sbcglobal.net>.
Michael Olds wrote:

<snip>
>
>OK! Now I understand. In my own words, the server doesn't even see the URL
>called by the user's browser; it goes from the user's browser to the script,
>from the script to the server; from the server through the ScriptAlias to
>the cgi-bin.

Close.  Apache sees the URL, goes where it says to (via the alias) and
since it is a ScriptAlias, causes the script to execute.  It then
returns the result to the client.

--
gt                  kk5st@sbcglobal.net
 If someone tells you---
 "I have a sense of humor, but that's not funny." 
                                  ---they don't.

---------------------------------------------------------------------
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] ScriptAlias two Virtual Host Directories

Posted by Michael Olds <Mi...@themozone.net>.
Gary

You asked:
Do you have a directory directive for /home/user/www/cgi-bin? (your
equivalent, of course)  Keep in mind that if this is the same alias as
the global, it will override and you won't be able to reach your global
CGIs from this domain.

I have a global
<Directory /www> (My Document root)
Options ~ ExecCGI
Order allow,deny
Allow from all
</Directory>

Right now I have no Global ScriptAlias.

Right at this moment there is
A ScriptAlias in user1s <VirtualHost> container,
there is no <Directory /www/user/cgi-bin> etc
in the <VirtualHost> container but I have tried it with it with one and with
both and with neither always with the same results: Again as, right now, CGI
is working for #1 with this setup and not for #2.

Best Wishes!
Mike Olds www.buddhadust.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] ScriptAlias two Virtual Host Directories

Posted by Gary Turner <kk...@sbcglobal.net>.
Michael Olds wrote:

<snip>
>
><VirtualHost 192.168.1.10>
>ServerAdmin admin@domain.com
>ServerName domain.com
>ServerAlias *.domain.com
>DocumentRoot /home/user/www
>ErrorLog logs/domain.com-error_log
>TransferLog logs/domain.com-access_log
>ScriptAlias "/cgi-bin/" /home/user/www/cgi-bin
></VirtualHost>
>
<snip>
>So how is this fellow doing it? There is no mention of any special
>configuration in the global section of the httpd.conf

Do you have a directory directive for /home/user/www/cgi-bin? (your
equivalent, of course)  Keep in mind that if this is the same alias as
the global, it will override and you won't be able to reach your global
CGIs from this domain.

BTW, putting the CGI directory under the doc-root is dangerous.
--
gt                  kk5st@sbcglobal.net
 If someone tells you---
 "I have a sense of humor, but that's not funny." 
                                  ---they don't.

---------------------------------------------------------------------
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] ScriptAlias two Virtual Host Directories

Posted by Michael Olds <Mi...@themozone.net>.
Gary,

<------------->

OK! Now I understand...

I have to take this back, sorry!

<-------------->

I think we must be having some kind of miscommunication about what I am
doing.

Here is an example (one of several) that describe ScriptAlias Virtual Host
Configuration that looks to my eye just like what I am doing:

Name-Based Virtual Hosting

#The following VirtualHost directive will answer for domain.com and
*.domain.com (* being a wildcard)

<VirtualHost 192.168.1.10>
ServerAdmin admin@domain.com
ServerName domain.com
ServerAlias *.domain.com
DocumentRoot /home/user/www
ErrorLog logs/domain.com-error_log
TransferLog logs/domain.com-access_log
ScriptAlias "/cgi-bin/" /home/user/www/cgi-bin
</VirtualHost>


# This Virtual Host will answer for circle.com, square.com and triangle.com.
It *WILL NOT* answer for www.circle.com, www.square.com or www.triangle.com.

<VirtualHost 192.168.1.10>
ServerAdmin admin@circle.com
ServerName circle.com
ServerAlias square.com
ServerAlias triangle.com
ErrorLog logs/circle.com-error_log
TransferLog logs/circle.com-access_log
ScriptAlias "/cgi-bin/"  /home/circle/www/cgi-bin
</VirtualHost>


So how is this fellow doing it? There is no mention of any special
configuration in the global section of the httpd.conf






---------------------------------------------------------------------
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] ScriptAlias two Virtual Host Directories

Posted by Michael Olds <Mi...@themozone.net>.
Gary,

You said:

Your script is called through the URL passed to the server by a form or href
anchor.  So, if

   ScriptAlias /cgi/ /usr/local/lib/cgi-bin/

then the script "dothis" might be called with "/cgi/dothis"

<------------->

OK! Now I understand. In my own words, the server doesn't even see the URL
called by the user's browser; it goes from the user's browser to the script,
from the script to the server; from the server through the ScriptAlias to
the cgi-bin.

Thank you for taking the time to get this through...that is if I do have it
correctly or approximately correctly.

Best Wishes!
Mike Olds www.buddhadust.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] ScriptAlias two Virtual Host Directories

Posted by Michael Olds <Mi...@themozone.net>.
Gary,
Of course you're right, I'll end up installing the scripts anyway...but it's
not a matter of trust in these (very few) cases.

But the larger issue is wanting to understand this.

I have this feeling that when I can't do something, something is wrong with
my setup. When I get that right I can go another direction.

Best Wishes!
Mike Olds www.buddhadust.org

-----Original Message-----
From: Gary Turner [mailto:kk5st@sbcglobal.net]
Sent: Saturday, December 28, 2002 1:04 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] ScriptAlias two Virtual Host Directories


Michael Olds wrote:

<snip>
>
>My only hesitation about going with one cgi-bin (except that I was
following
>the way my BuddhaDust host was set up) was that what I am doing is trying
to
>set up my own two-domain self in such a way as it will teach me what to do
>when I offer this to a couple of friends. Then having one cgi-bin looks
like
>a lot of hand-holding which I do not particularly want to have to do.

Are you really gonna let people put executables on your machine without
a lot of hand-holding, not to mention close scrutiny :(
--
gt                  kk5st@sbcglobal.net
 If someone tells you---
 "I have a sense of humor, but that's not funny."
                                  ---they don't.

---------------------------------------------------------------------
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] ScriptAlias two Virtual Host Directories

Posted by Gary Turner <kk...@sbcglobal.net>.
Michael Olds wrote:

<snip>
>
>My only hesitation about going with one cgi-bin (except that I was following
>the way my BuddhaDust host was set up) was that what I am doing is trying to
>set up my own two-domain self in such a way as it will teach me what to do
>when I offer this to a couple of friends. Then having one cgi-bin looks like
>a lot of hand-holding which I do not particularly want to have to do.

Are you really gonna let people put executables on your machine without
a lot of hand-holding, not to mention close scrutiny :(
--
gt                  kk5st@sbcglobal.net
 If someone tells you---
 "I have a sense of humor, but that's not funny." 
                                  ---they don't.

---------------------------------------------------------------------
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] ScriptAlias two Virtual Host Directories

Posted by Michael Olds <Mi...@themozone.net>.
Nevermind catching me up...the archive at:
http://marc.theaimsgroup.com/?l=apache-httpd-users&r=1&w=2

is really good, amost exactly up to the minute.

My only hesitation about going with one cgi-bin (except that I was following
the way my BuddhaDust host was set up) was that what I am doing is trying to
set up my own two-domain self in such a way as it will teach me what to do
when I offer this to a couple of friends. Then having one cgi-bin looks like
a lot of hand-holding which I do not particularly want to have to do.

...ok...so if you don't hear anything for a bit it's not because I've given
up or disagree, I'm thinking...or making the attempt...

Best Wishes!
Mike Olds www.buddhadust.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] ScriptAlias two Virtual Host Directories

Posted by Michael Olds <Mi...@themozone.net>.
I was down most of the night and didn't catch what came after my last and
before this...any hope of getting me caught up?


Best Wishes!
Michael Olds
Los Altos   California
http://www.BuddhaDust.org




-----Original Message-----
From: Gary Turner [mailto:kk5st@sbcglobal.net]
Sent: Saturday, December 28, 2002 3:14 AM
To: users@httpd.apache.org
Subject: Re: [users@httpd] ScriptAlias two Virtual Host Directories


Gary Turner wrote:

<snip>

>	 In fact, on your test bed, try the defaults (except
>for HVs, of course).  I'd guess that you would have a working setup.
     ^^^
phthwwwwp s/b VHs, of course

<snip>
--
gt                  kk5st@sbcglobal.net
 If someone tells you---
 "I have a sense of humor, but that's not funny."
                                  ---they don't.

---------------------------------------------------------------------
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] ScriptAlias two Virtual Host Directories

Posted by Gary Turner <kk...@sbcglobal.net>.
Gary Turner wrote:

<snip>

>	 In fact, on your test bed, try the defaults (except
>for HVs, of course).  I'd guess that you would have a working setup.
     ^^^
phthwwwwp s/b VHs, of course

<snip>
--
gt                  kk5st@sbcglobal.net
 If someone tells you---
 "I have a sense of humor, but that's not funny." 
                                  ---they don't.

---------------------------------------------------------------------
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] ScriptAlias two Virtual Host Directories

Posted by Gary Turner <kk...@sbcglobal.net>.
Michael Olds wrote:

>OK, Gary, I wasn't ignoring you! I spent most of the day reading (including
>the apache docs on ScriptAlias and VirtualDomains) and trying to work this
>out and did not feel I had enough to get back to you on Debian.

OK, no problema.  Though it is better not to post the same question to
multiple lists.  This is probably the more appropriate list, anyway.

>
>When you said I was using the same alias for both locations, I thought you
>were refering to the way I had it set up when I posted to debian, which was
>to have both ScriptAliases in the main configuration. As I read the
>examples, it seemed like putting them into the VirtualHost directories was a
>different thing.

A global alias is fine.  It is simpler to maintain.  But, each CGI-root
needs a different (unique) alias (nickname).

>
>If you don't mind, please think of me as dyslexic. When you say:
>You can make a ScriptAlias for each virtual host, like fred to refer to
>domain1, ethel for domain2, and lucy for domain3.  Each
>domain/CGIDirectory needs a unique nickname (alias).

Actually, I was not very accurate/lucid here.  The ScriptAlias is not
inherently linked/associated to any given domain.  The ScriptAlias
compares to the document-root.  It is where the executable scripts live
while only needing to reference the nickname without writing out the
entire path.

>How can this be when virtually every cgi script is called by
>www.domain.com/cgi-bin/script or cgi-local/script; I am and have used hosts
>that have thousands of customers, it just cannot be that I was the one who
>got "cgi-bin" or "cgi-local" instead of "fred". I store my cgi scripts for
>BuddhaDust in directory path: ~/public/cgi-local/ and the url I use to call
>the script is http://www.buddhadust.org/cgi-local/dcforum/dcboard.cgi it
>would help me if I understood what they might be doing in terms of
>ScriptAlias here.

Your script is called through the URL passed to the server by a form or
href anchor.  So, if 

	ScriptAlias /cgi/ /usr/local/lib/cgi-bin/

then the script "dothis" might be called with "/cgi/dothis"

If there is another alias, ScriptAlias /fred/ /usr/local/lib/cgi-bin2/

then a script dothat, in /cgi-bin2/ is called with "/fred/dothat"

If you use an absolute address, then http://domain.com/cgi/dothis or
http://domain.com/fred/dothat



>And when the call comes in doesn't it go to the Virtual domain first...so ok
>this call to domain one, then it sees /cgi/, so it knows (should know) to go
>to the directory path (within that domain) for the cgi bin...in my case
>/www/user/public_html/cgi-bin/script

If there is no ScriptAlias in the VH directive, the global alias
prevails.

Your CGI directory should not be under your doc root.  This can open
security issues.  Is there some reason not to use the defaults provided
by the Debian binaries?  The defaults will place CGIs outside the
browseable tree.  In fact, on your test bed, try the defaults (except
for HVs, of course).  I'd guess that you would have a working setup.

If you use a single location for scripts, you will generally be able to
control and maintain easier.  You can still create sub-directories under
the CGI-root if it makes it easier to organize.

If there are further questions, please try to narrow the scope.
--
gt                  kk5st@sbcglobal.net
 If someone tells you---
 "I have a sense of humor, but that's not funny." 
                                  ---they don't.

---------------------------------------------------------------------
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] ScriptAlias two Virtual Host Directories

Posted by Michael Olds <Mi...@themozone.net>.
OK, Gary, I wasn't ignoring you! I spent most of the day reading (including
the apache docs on ScriptAlias and VirtualDomains) and trying to work this
out and did not feel I had enough to get back to you on Debian.

When you said I was using the same alias for both locations, I thought you
were refering to the way I had it set up when I posted to debian, which was
to have both ScriptAliases in the main configuration. As I read the
examples, it seemed like putting them into the VirtualHost directories was a
different thing.

If you don't mind, please think of me as dyslexic. When you say:
You can make a ScriptAlias for each virtual host, like fred to refer to
domain1, ethel for domain2, and lucy for domain3.  Each
domain/CGIDirectory needs a unique nickname (alias).

How can this be when virtually every cgi script is called by
www.domain.com/cgi-bin/script or cgi-local/script; I am and have used hosts
that have thousands of customers, it just cannot be that I was the one who
got "cgi-bin" or "cgi-local" instead of "fred". I store my cgi scripts for
BuddhaDust in directory path: ~/public/cgi-local/ and the url I use to call
the script is http://www.buddhadust.org/cgi-local/dcforum/dcboard.cgi it
would help me if I understood what they might be doing in terms of
ScriptAlias here.

And when the call comes in doesn't it go to the Virtual domain first...so ok
this call to domain one, then it sees /cgi/, so it knows (should know) to go
to the directory path (within that domain) for the cgi bin...in my case
/www/user/public_html/cgi-bin/script

In any case I tried using, within user2's domain: cgi-local for both the
name of the directory and the "nickname", and it still didn't work.

>(The Directory/File structure is the same for both domains, and the
>users/groups and permissions are both exactly the same)
>
><Directory "/www/usr-1/public_html/cgi-bin">
>   AllowOverride None
>   Options ExecCGI
>   Order allow,deny
>   Allow from all
></Directory>
>
>Same same for user2...
>
>NameVirtualHost 000etc
>
><VirtualHost 000etc>
>   UseCanonicalName off
>   ServerName www.domain1.net
>   ServerAlias *.domain.net domain.net domain
>   DocumentRoot "/www/usr-1/public_html"
>   ServerAdmin me@mine
>   ScriptAlias /cgi-bin/ /www/usr/public_html/cgi-bin/
></VirtualHost>
>
>
><VirtualHost 000etc>
>   UseCanonicalName off
>   ServerName www.domain2.net
>   ServerAlias *.domain.net domain.net domain
>   DocumentRoot "/www/usr/public_html"
>   ServerAdmin me@mine
>   ScriptAlias /cgi-bin/ /www/usr-2/public_html/cgi-bin/
></VirtualHost>
>
>The error I am getting is "No such file or directory" when I try to execute
>a script from usr2s cgi-bin. In the main configuration the language speaks
>of Script Aliases (plural) but I have not found one example of the use of
>more than one in any of the documentation.
a fred script, too.

You can make a ScriptAlias for each virtual host, like fred to refer to
domain1, ethel for domain2, and lucy for domain3.  Each
domain/CGIDirectory needs a unique nickname (alias).

I understand the principle, the actuality in my mind is that
the call coming in is to a unique host's cgi bin and is being directed to a
unique path to that cgi-bin and that nobody I see out there is using /fred/
in their url's to their scripts.

As I said on the Debian board, I must have this on backwards, but I do not
see the mirror!

Best Wishes!
Mike Olds www.buddhadust.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] ScriptAlias two Virtual Host Directories

Posted by Gary Turner <kk...@sbcglobal.net>.
Michael Olds wrote:

>Hello,
>
>I am trying to get ScriptAlias working for two separate Named Virtual Hosts
>and nothing I am doing is working.
>
>This is a Debian Woody stock setup, with 2 users (both me) with two domains.
>At present the server serves html pages properly to both domains, but will
>execute CGI only for the first domain. I have tried a number of different
>configurations the last of which is this:
>
>(The Directory/File structure is the same for both domains, and the
>users/groups and permissions are both exactly the same)
>
><Directory "/www/usr-1/public_html/cgi-bin">
>   AllowOverride None
>   Options ExecCGI
>   Order allow,deny
>   Allow from all
></Directory>
>
>Same same for user2...
>
>NameVirtualHost 000etc
>
><VirtualHost 000etc>
>   UseCanonicalName off
>   ServerName www.domain1.net
>   ServerAlias *.domain.net domain.net domain
>   DocumentRoot "/www/usr-1/public_html"
>   ServerAdmin me@mine
>   ScriptAlias /cgi-bin/ /www/usr/public_html/cgi-bin/
></VirtualHost>
>
>
><VirtualHost 000etc>
>   UseCanonicalName off
>   ServerName www.domain2.net
>   ServerAlias *.domain.net domain.net domain
>   DocumentRoot "/www/usr/public_html"
>   ServerAdmin me@mine
>   ScriptAlias /cgi-bin/ /www/usr-2/public_html/cgi-bin/
></VirtualHost>
>
>The error I am getting is "No such file or directory" when I try to execute
>a script from usr2s cgi-bin. In the main configuration the language speaks
>of Script Aliases (plural) but I have not found one example of the use of
>more than one in any of the documentation.
>
>I have read the relevant materials in two books, asked on the Debian User
>board, looked at the FAQ and docs here and this looks like it should be
>working. So I am thinking there is something at a higher level than the
>configuration file that I have incorrectly set up. Does anyone have any
>ideas?

For one thing, you are using the same alias for both locations.  So I'm
guessing that the first pathway is used, therefor there is no script2 to
be found.  See ch.1, p.13 of the O'Reilly book "CGI Programming with
Perl" 2nd edition.

As I pointed out in Debian Users ML;

	"Some of this stuff can be hard to grok.  Think of the alias as a
nickname for the directory your scripts are living in.  So if you do
this:

	ScriptAlias /fred/ /usr/local/lib/cgi-bin/
#(Fred is just another name for the directory)

	<Directory /usr/local/lib/cgi-bin/>
		...
		...
		Options ExecCGI
	</Directory>

it means that when you call /fred/somescript.pl
(http://domain1.com/fred/somescript.pl) Apache goes to
/usr/local/lib/cgi-bin/ and runs somescript.pl.  Of course domain2 can
call a fred script, too.

You can make a ScriptAlias for each virtual host, like fred to refer to
domain1, ethel for domain2, and lucy for domain3.  Each
domain/CGIDirectory needs a unique nickname (alias).

I have all CGI scripts in a single directory, so I haven't tried putting
the ScriptAlias within the virtual host directive. .htacces directives
can also be used.  Check the Apache documentation:

http://httpd.apache.org/docs/howto/cgi.html#configuringapachetopermitcgi

For a good overview of Apache see ch. 36:

	http://rute.sourceforge.net/

or, you may already have it installed on your machine."
--
gt                  kk5st@sbcglobal.net
 If someone tells you---
 "I have a sense of humor, but that's not funny." 
                                  ---they don't.

---------------------------------------------------------------------
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