You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Darrel Austin <da...@darrelaustin.com> on 2002/04/29 16:54:28 UTC

Re: Congig'ing CGI's (was: Two odd (but probably basic) problems with executables)

> Where did you get that syntax from?

Umm...from:

http://httpd.apache.org/docs/mod/core.html#options

and

http://httpd.apache.org/docs/misc/FAQ-F.html#CGIoutsideScriptAlias

Oh...wait...to clarify, I'm running 1.3...NOT 2.0. While that's on my to-do
list, I'm just trying to get Bugzilla up and running for now...

-Darrel


> That is not even close to the
> correct way to use AddHandler.  See, for example,
> http://httpd.apache.org/docs-2.0/howto/cgi.html




on 4/29/02 9:26 AM, Joshua Slive at joshua@slive.ca wrote:

> 
> On Mon, 29 Apr 2002, Darrel Austin wrote:
>> 
>> <VirtualHost xxx.xxx.xxx.xxx>
>> DocumentRoot /var/www/virtualhosts/site/html
>> ServerName servername.com
>> Options +ExecCGI
>> AddHandler /var/www/virtualhosts/site/html/bugzilla .cgi
> 
> Where did you get that syntax from?  That is not even close to the
> correct way to use AddHandler.  See, for example,
> http://httpd.apache.org/docs-2.0/howto/cgi.html
> 
> 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
> 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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Config'ing CGI's (was: Two odd (but probably basic) problems with executables)

Posted by Josh Glover <jm...@incogen.com>.
Darrel Austin wrote:
>>So you can't feed AddHandler a path to a cgi script.  It should look
>>more like
>>AddHandler cgi-script .cgi
> 
> 
> Ah. My interpretation of the documentation was that "cgi-script" was the
> path to the directory with the scripts in it. Is that incorrect?

(Oh yeah, and you might want to add .pl to your AddHandler line.)

Yes, that is incorrect. cgi-script is a MIME type. You have to tell 
Apache what to do with content, because the default is to serve it up as 
an HTML doc:

#
# DefaultType is the default MIME type the server will use for a
# document if it cannot otherwise determine one, such as from filename
# extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain


> Changing it to "AddHandler cgi-script .cgi" produces the 403 forbidden error
> again. The actual error (in the logs) is:
> 
> [error] [client xxx.xxx.xxx.xxx] Options ExecCGI is off in this directory:
> /var/www/virtualhosts/server/html/bugzilla/enter_bug.cgi

Right, so you need to turn on ExecCGI for that directory. Something like 
this should do it:

<Directory "/var/www/cgi-bin">
    Options ExecCGI ...
    ...
</Directory>


> If I go back to making "chi-script" the actual path to the directory, then I
> regain access to the directory via my web browser, but the scripts don't
> actually execute...just render as text.

For the above reasons.


-- 
Josh Glover <jm...@incogen.com>

Associate Systems Administrator
INCOGEN, Inc.


---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Config'ing CGI's (was: Two odd (but probably basic) problems with executables)

Posted by CJ Kucera <ck...@hbs.net>.
I said:
> This is because of another syntax error.  You're using "Options +ExecCGI"
> in your httpd.conf.  Take out the plus, so you've just got
> "Options ExecCGI"

Hm.  Way to put my foot in my mouth; turns out the plus sign is entirely
correct.  It just happens to be optional, too, and I've never used it.
Yeah . . .

Sorry 'bout that.
-CJ


---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Premature end of script error (WAS: Config'ing CGI's)

Posted by Darrel <da...@darrelaustin.com>.
>The problem is almost surely that the shebang line at the top of the
>script doesn't point to the correct location of perl.  Therefore,
>when the OS goes to try to execute it, it fails.

Thanks Joshua...that appears to be part of the culprit. This BugZilla 
app has some messy scripting configurations in it.

Anyways, this appears to be more of a perl issue know...thanks for 
getting me to this point!

-Darrel
-- 

---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Premature end of script error (WAS: Config'ing CGI's)

Posted by Joshua Slive <jo...@slive.ca>.
On Mon, 29 Apr 2002, Darrel Austin wrote:
> [Mon Apr 29 14:36:12 2002] [error] (2)No such file or directory: exec of
> /var/www/virtualhosts/site/html/bugzilla/query.cgi failed
> [Mon Apr 29 14:36:12 2002] [error] [client xxx.xxx.xxx.xxx] Premature end of
> script headers: /var/www/virtualhosts/site/html/bugzilla/query.cgi
>
> It appears that it both can NOT find the file AND that it CAN find the file,
> but is puking on the headers. What does that mean? For the record, that file
> does exist in that location.

Those are actually both part of the same error.  When Apache execs the
script, it gets the response from the operating system "No such file ..."
and therefore it doesn't get the appropriate script headers.

The problem is almost surely that the shebang line at the top of the
script doesn't point to the correct location of perl.  Therefore,
when the OS goes to try to execute it, it fails.

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

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
For additional commands, e-mail: users-help@httpd.apache.org


Premature end of script error (WAS: Config'ing CGI's)

Posted by Darrel Austin <da...@darrelaustin.com>.
> It looks like you are getting there (slowly ;-).

Yes! Thank you! I wouldn't be this far without the helpful advice from this
list.

So, here's what I have now, for the record:

<VirtualHost xxx.xxx.xxx.xxx>
DocumentRoot /var/www/virtualhosts/site/html
ServerName server.com
AddHandler cgi-script .cgi
<Directory /var/www/virtualhosts/site/html/bugzilla/>
Options +ExecCGI
</Directory>
</VirtualHost>

And this takes care of the execution and permissions problem. Thanks!

On to the next problem. ;o)

(This actually may be drifting away from an actual Apache issue, so, if it
is, let me know.)

Upon accessing this directory now, I get an Internal Server error. My error
logs show the following:


[Mon Apr 29 14:36:12 2002] [error] (2)No such file or directory: exec of
/var/www/virtualhosts/site/html/bugzilla/query.cgi failed
[Mon Apr 29 14:36:12 2002] [error] [client xxx.xxx.xxx.xxx] Premature end of
script headers: /var/www/virtualhosts/site/html/bugzilla/query.cgi

It appears that it both can NOT find the file AND that it CAN find the file,
but is puking on the headers. What does that mean? For the record, that file
does exist in that location.

-Darrel






on 4/29/02 2:06 PM, Joshua Slive at joshua@slive.ca wrote:

> 
> On Mon, 29 Apr 2002, Darrel Austin wrote:
> 
>> Thanks everyone for the feedback! I'm still trying to digest this.
> 
> It looks like you are getting there (slowly ;-).
> 
>> 
>> OK, so here's what I have now:
>> 
>> <VirtualHost xxx.xxx.xxx.xxx>
>> DocumentRoot /var/www/virtualhosts/site/html
>> ServerName servername.com
>> Options +ExecCGI
>> AddHandler cgi-script .cgi
>> </VirtualHost>
> 
>> Does the "Options +ExecCGI" command apply to nested directories, or only the
>> parent directory spec'ed in the virtual host directive?
> 
> This is answered by the FAQ reference I gave you, but I'll rephrase it
> here: Options directives (and pretty much every other directive) do apply
> to nested directories.  But Options directives can override each other,
> and since the Options in the <VirtualHost> is applied before other Options
> directives that you probably have elsewhere in <Directory> containers, it
> gets overriden by those other Options.  Note in particular that
> 
> <VirtualHost xxx>
> Options +ExecCGI
> </VirtualHost>
> <Directory /var/www>
> Options Indexes
> </Directory>
> will result in ExecCGI being OFF in /var/www and below directories,
> because "Options Indexes" sets everything but Indexes to off.
> 
>> Am I even putting the options and the AddHandler in the correct part of the
>> config file?
> 
> The AddHandler is fine there, because it isn't likely to get overridden.
> It could also be placed in a specific <Directory> section.
> 
>> quite grasp the manual in context. The examples seem to make sense in and of
>> themselves, but I get completely lost when attempting to figure out WHERE
>> specific commands should go.
>> http://httpd.apache.org/docs/misc/FAQ.html#options mentions the DIRECTORY
>> tag, but I can't figure out where it goes in relation to the VirtualHost
>> tag.)
> 
> It can go pretty much anywhere.  If you want it to apply ONLY to that
> virtualhost, then put it inside the <VirtualHost> tags.  Otherwise, put it
> immediately before or after the <VirtualHost> section.
> 
>> For future reference, just so I get this straight, from what I understand
>> the +/- appends any previous Options statement while if you don't use the
>> +/- the options are all defaulted to none before applying the new
>> declaration. Correct?
> 
> Exactly.
> 
> 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
> 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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Config'ing CGI's (was: Two odd (but probably basic) problems with executables)

Posted by Joshua Slive <jo...@slive.ca>.
On Mon, 29 Apr 2002, Darrel Austin wrote:

> Thanks everyone for the feedback! I'm still trying to digest this.

It looks like you are getting there (slowly ;-).

>
> OK, so here's what I have now:
>
> <VirtualHost xxx.xxx.xxx.xxx>
> DocumentRoot /var/www/virtualhosts/site/html
> ServerName servername.com
> Options +ExecCGI
> AddHandler cgi-script .cgi
> </VirtualHost>

> Does the "Options +ExecCGI" command apply to nested directories, or only the
> parent directory spec'ed in the virtual host directive?

This is answered by the FAQ reference I gave you, but I'll rephrase it
here: Options directives (and pretty much every other directive) do apply
to nested directories.  But Options directives can override each other,
and since the Options in the <VirtualHost> is applied before other Options
directives that you probably have elsewhere in <Directory> containers, it
gets overriden by those other Options.  Note in particular that

<VirtualHost xxx>
Options +ExecCGI
</VirtualHost>
<Directory /var/www>
Options Indexes
</Directory>
will result in ExecCGI being OFF in /var/www and below directories,
because "Options Indexes" sets everything but Indexes to off.

> Am I even putting the options and the AddHandler in the correct part of the
> config file?

The AddHandler is fine there, because it isn't likely to get overridden.
It could also be placed in a specific <Directory> section.

> quite grasp the manual in context. The examples seem to make sense in and of
> themselves, but I get completely lost when attempting to figure out WHERE
> specific commands should go.
> http://httpd.apache.org/docs/misc/FAQ.html#options mentions the DIRECTORY
> tag, but I can't figure out where it goes in relation to the VirtualHost
> tag.)

It can go pretty much anywhere.  If you want it to apply ONLY to that
virtualhost, then put it inside the <VirtualHost> tags.  Otherwise, put it
immediately before or after the <VirtualHost> section.

> For future reference, just so I get this straight, from what I understand
> the +/- appends any previous Options statement while if you don't use the
> +/- the options are all defaulted to none before applying the new
> declaration. Correct?

Exactly.

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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Config'ing CGI's (was: Two odd (but probably basic) problems with executables)

Posted by Darrel Austin <da...@darrelaustin.com>.
Thanks everyone for the feedback! I'm still trying to digest this.

OK, so here's what I have now:

<VirtualHost xxx.xxx.xxx.xxx>
DocumentRoot /var/www/virtualhosts/site/html
ServerName servername.com
Options +ExecCGI
AddHandler cgi-script .cgi
</VirtualHost>

So, in english, this is how I read the above:

The directory is set to allow ExecCGI and any file ending in .cgi should be
processed through Apache's CHI-SCRIPT processor.

Of course, the CGIs are actually in /var/www/virtualhosts/site/html/bugzilla

Does the "Options +ExecCGI" command apply to nested directories, or only the
parent directory spec'ed in the virtual host directive?

Am I even putting the options and the AddHandler in the correct part of the
config file? Right now they are part of the VirtualHost config, but Joshua's
example:

<Directory /var/www/virtualhosts/server/html/bugzilla/>
Options +ExecCGI
</Directory>

hints that maybe that's NOT where they should go. (And Joshua, while I
COMPLETELY respect your RTFM method of citing references, I still can't
quite grasp the manual in context. The examples seem to make sense in and of
themselves, but I get completely lost when attempting to figure out WHERE
specific commands should go.
http://httpd.apache.org/docs/misc/FAQ.html#options mentions the DIRECTORY
tag, but I can't figure out where it goes in relation to the VirtualHost
tag.)

> Hm.  Way to put my foot in my mouth; turns out the plus sign is entirely
> correct.  It just happens to be optional, too, and I've never used it.
> Yeah . . .

For future reference, just so I get this straight, from what I understand
the +/- appends any previous Options statement while if you don't use the
+/- the options are all defaulted to none before applying the new
declaration. Correct?

Brain getting less cloudy...

-Darrel


---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Config'ing CGI's (was: Two odd (but probably basic) problems with executables)

Posted by CJ Kucera <ck...@hbs.net>.
Darrel Austin wrote:
> Ah. My interpretation of the documentation was that "cgi-script" was the
> path to the directory with the scripts in it. Is that incorrect?

Yeah, your interpretation was incorrect.  What the line means is that
any file ending in ".cgi" will be handled by Apache's "cgi-script"
handler.

> Changing it to "AddHandler cgi-script .cgi" produces the 403 forbidden error
> again. The actual error (in the logs) is:
> 
> [error] [client xxx.xxx.xxx.xxx] Options ExecCGI is off in this directory:
> /var/www/virtualhosts/server/html/bugzilla/enter_bug.cgi

This is because of another syntax error.  You're using "Options +ExecCGI"
in your httpd.conf.  Take out the plus, so you've just got
"Options ExecCGI"

That'll work much better.

> If I go back to making "chi-script" the actual path to the directory, then I
> regain access to the directory via my web browser, but the scripts don't
> actually execute...just render as text.

Right, because ".cgi" isn't set up to go through Apache's CGI Handler.
The AddHandler line just sets up Apache to be able to use CGI scripts.
The "Options" line is used for finer-grained permissions.  Like one
VirtualHost would be allowed to use CGIs, and other not.  Or only allowing
CGIs in a specific directory.

Hope that helps . . .

-CJ


---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Config'ing CGI's (was: Two odd (but probably basic) problems with executables)

Posted by Joshua Slive <jo...@slive.ca>.
On Mon, 29 Apr 2002, Darrel Austin wrote:
> > AddHandler cgi-script .cgi
>
> Ah. My interpretation of the documentation was that "cgi-script" was the
> path to the directory with the scripts in it. Is that incorrect?

That is litterally "cgi-script" not a path to anyting.


>
> Changing it to "AddHandler cgi-script .cgi" produces the 403 forbidden error
> again. The actual error (in the logs) is:
>
> [error] [client xxx.xxx.xxx.xxx] Options ExecCGI is off in this directory:
> /var/www/virtualhosts/server/html/bugzilla/enter_bug.cgi

Right.  Which is why I pointed to you here:

> > Try with that, and also
> > see http://httpd.apache.org/docs/misc/FAQ.html#options
> > if you still have problems with "ExecCGI not set" errors.

which tells you that you probably need
<Directory /var/www/virtualhosts/server/html/bugzilla/>
Options +ExecCGI
</Directory>

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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Config'ing CGI's (was: Two odd (but probably basic) problems with executables)

Posted by Darrel Austin <da...@darrelaustin.com>.
> Well, you are seriously misunderstanding those references.

Oh...no doubt. I'll be the first to admit that the Apache Documentation is
rather difficult for me to digest.

In all fairness, I really need to get a book on this...

> So you can't feed AddHandler a path to a cgi script.  It should look
> more like
> AddHandler cgi-script .cgi

Ah. My interpretation of the documentation was that "cgi-script" was the
path to the directory with the scripts in it. Is that incorrect?

Changing it to "AddHandler cgi-script .cgi" produces the 403 forbidden error
again. The actual error (in the logs) is:

[error] [client xxx.xxx.xxx.xxx] Options ExecCGI is off in this directory:
/var/www/virtualhosts/server/html/bugzilla/enter_bug.cgi

If I go back to making "chi-script" the actual path to the directory, then I
regain access to the directory via my web browser, but the scripts don't
actually execute...just render as text.

Ugh. Confused as ever... ;o)

-Darrel






> Try with that, and also
> see http://httpd.apache.org/docs/misc/FAQ.html#options
> if you still have problems with "ExecCGI not set" errors.
> 
> Joshua.




on 4/29/02 12:05 PM, Joshua Slive at joshua@slive.ca wrote:

> 
> On Mon, 29 Apr 2002, Darrel Austin wrote:
> 
>>> Where did you get that syntax from?
>> 
>> Umm...from:
>> 
>> http://httpd.apache.org/docs/mod/core.html#options
>> 
>> and
>> 
>> http://httpd.apache.org/docs/misc/FAQ-F.html#CGIoutsideScriptAlias
> 
> Well, you are seriously misunderstanding those references.
> AddHandler takes a "handler" as an argument.  Handlers are internal
> Apache references to particular actions (see
> http://httpd.apache.org/docs/handler.html
> )
> 
> So you can't feed AddHandler a path to a cgi script.  It should look
> more like
> AddHandler cgi-script .cgi
> 
> Try with that, and also
> see http://httpd.apache.org/docs/misc/FAQ.html#options
> if you still have problems with "ExecCGI not set" errors.
> 
> 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
> 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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Congig'ing CGI's (was: Two odd (but probably basic) problems with executables)

Posted by Joshua Slive <jo...@slive.ca>.
On Mon, 29 Apr 2002, Darrel Austin wrote:

> > Where did you get that syntax from?
>
> Umm...from:
>
> http://httpd.apache.org/docs/mod/core.html#options
>
> and
>
> http://httpd.apache.org/docs/misc/FAQ-F.html#CGIoutsideScriptAlias

Well, you are seriously misunderstanding those references.
AddHandler takes a "handler" as an argument.  Handlers are internal
Apache references to particular actions (see
http://httpd.apache.org/docs/handler.html
)

So you can't feed AddHandler a path to a cgi script.  It should look
more like
AddHandler cgi-script .cgi

Try with that, and also
see http://httpd.apache.org/docs/misc/FAQ.html#options
if you still have problems with "ExecCGI not set" errors.

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
For additional commands, e-mail: users-help@httpd.apache.org