Apache mod_perl Problem ? Help!

Jason Stephenson jason at sigio.com
Mon Dec 23 11:17:18 EST 2002


Dan Coutu wrote:
> Ben Boulanger wrote:
> 
>  > Secondly, make sure this CGI is in the appropriate spot on the 
> webserver (/cgi-bin/) - there's a binary (suexec, I believe) that can 
> whack cgi's
>  > in other places - if anyone knows why this is, I'd love to hear it.


suexec is used to run cgi apps and scripts as the user that owns the 
file. It is most often used in ~user home directories to run scripts as 
the user that owns the directory. There are better solutions, such as 
cgiwrap, and the suexec documentation recommends you use something other 
than suexec. This is largely because suexec and/or the www server must 
be running as root. If you don't use suexec or something like it, then 
cgi apps and scripts are run as the user that the www server runs as. 
This is often a user account set up specifically for the web server or 
sometimes the user 'nobody'. If you're users are smart, they've set 
permissions on their directories so that no other users can write to 
their own files and subdirectories. This means that without suexec they 
won't be able to run cgis that write data to files in their own home 
directory.


>  >
>  > Ben
>  >
>  >
> 
> 
> Truth? Not quite. It is very possible to create a perl script that will 
> run properly under mod_perl but not as a CGI.
> 
> Yes, mod_perl can be thought of as an accelerator but that is not all it 
> does. It also provides a number of other useful features that you just 
> can't get in a CGI context, such as persistent database connections.
>

mod_perl can also be used to write Apache modules in perl. It can be 
used to do a lot more than just accelerate cgi execution. There are many 
useful modules out there (HTML::Mason, etc.) that are written for 
mod_perl and don't run at all as cgi applications.

mod_perl can also be used along with another module, emb_perl, that 
allows you to create web pages with embedded, executable perl in them. I 
prefer to use PHP, myself, but you can do this, too. These don't run as 
cgis, either.

> The suggestion about using the RPMs sounds like your best bet. See where 
> that gets you.
> 
> In wandering through the httpd.conf on my Red Hat system I see that by 
> default it will process scripts in /var/www/perl using mod_perl. (This 
> might be dependent on the above mentioned RPM stuff.) Besides that, you 
> can run CGIs in any directory you choose by making the appropriate 
> annotations in your httpd.conf file. It involves adding ExecCGI to a 
> Directory directive. Read the Fine Manual page for specific details.
> 

The directories where things run can be changed, and one can even 
configure Apache so that any file with the execute bit turned on gets 
treated as a cgi app. You can do all kinds of things in httpd.conf with 
executable content.




More information about the gnhlug-discuss mailing list