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

Re: cgi-bin works with IP but not domain name



Hi, Zachary:

On Monday 08 November 2010 11:54:17 Zachary Uram wrote:
> I have various name based virtual hosts setup. They all work fine.
> However if I try to run a script in /usr/lib/cgi-bin it fails when I
> specify the domain name, but works if I specify my IP name (this is a
> VPS)!

As a general matter these kind of symptoms always points out a 
misconfiguration at the virtual server level.

> So this, http://97.107.134.151/cgi-bin/awstats.pl, works
>
> But this, http://www.oggthebase.org/cgi-bin/awstats.pl,  gives error
> "Oops! This link appears to be broken."

So cgi-bin is properly configured for the "default" server but it is not at 
the given virtual server level.

> I'm running apache 2.2.16-3.
>
> Here is my /etc/apache2/sites-available/default:
>
> <VirtualHost 97.107.134.151:80>

[...]

>         ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
>         <Directory "/usr/lib/cgi-bin">
>                 AllowOverride None
>                 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
>                 Order allow,deny
>                 Allow from all
>         </Directory>

"Default" doesn't mean "use config stanzas from this site if you don't find 
anything more specific at the virtual server level" but "use this site if you 
can't find the one asked for".


> Here is my /etc/apache2/sites-available/oggthebase.org:
>
> <VirtualHost 97.107.134.151:80>
>      ServerAdmin root@oggthebase.org
>      ServerName oggthebase.org
>      ServerAlias www.oggthebase.org
>      DocumentRoot /var/www/oggthebase.org/
>      ErrorLog /var/www/oggthebase.org/logs/error.log
>      CustomLog /var/www/oggthebase.org/logs/access.log combined
> </VirtualHost>

So you didn't define a specific cgi-bin resource at the oggthebase.org level.

You said in a different message this:
> When I went to http://www.oggthebase.org/cgi-bin/awstats.pl it generated:
> 
> [Mon Nov 08 10:56:52 2010] [error] [client 72.0.209.165] File does not
> exist: /var/www/oggthebase.org/cgi-bin
>
> So it is going to /var/www/oggthebase.org/cgi-bin

Of course it is!  You didn't define anything specific to /cgi-bin at the 
virtual server level, so it's going to search for the resource at [document 
root]/[asked-for path], exactly as it should.

> I do *not* want to have a special cgi-bin for each vhost. I only want
> it to use the system's /usr/lib/cgi-bin
> 
> How can I make this happen?

Making sure you "tell" that to each and every virtual server.  You can add the 
cgi-bin definition at every defined virtual server, so it looks like...

/etc/apache2/sites-available/oggthebase.org:
<VirtualHost 97.107.134.151:80>
      ServerName oggthebase.org
      ServerAlias www.oggthebase.org
[...]
      ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
       <Directory "/usr/lib/cgi-bin">
               AllowOverride None
               Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
               Order allow,deny
               Allow from all
       </Directory>
[...]
</VirtualHost>

Or you can "move" that config snipet to a different file and make sure 
you "include" it from each virtual server that needs it (the advantage being 
that you will need to change the definition only on one file should the need 
arises).

Cheers.


Reply to: