I have a dedicated server running Red Hat 7.2 and I just upgraded Apache to 1.3.26 and mod_perl. For some reason I can't get my .cgi or .pl scripts to run.
When accessing a simple .cgi script, it comes up with a 'Forbidden' error. I've tried everythign I can think of and I'm out of guesses.
1. The path to perl is correct in the shebang line of my script. Here's what came upf or the location of perl:
perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz
2. This is what I have in the httpd.conf file:
LoadModule cgi_module libexec/mod_cgi.so
AddModule mod_cgi.c
------------------------------------
# AddHandler allows you to map certain file extensions to "handlers",
# actions unrelated to filetype. These can be either built into the server
# or added with the Action command (see below)
#
# If you want to use server side includes, or CGI outside
# ScriptAliased directories, uncomment the following lines.
#
# To use CGI scripts:
#
#AddHandler cgi-script .cgi
#AddHandler perl-script .pl
---------------------------------
NameVirtualHost 205.15.XX.XXX
<VirtualHost 205.15.XX.XXX>
DocumentRoot /home/login/public_html
UseCanonicalName off
ErrorLog /home/login/logs/error_log
CustomLog /home/login/logs/access_log combined
ScriptAlias /cgi-bin/ /home/login/public_html/cgi-bin/
AddHandler cgi-script .cgi
AddHandler perl-script .pl
DirectoryIndex index.htm index.html index.php index.cgi index.pl index.shtml
</VirtualHost>
3. I enabled the cgi module when compiling Apache.
If anybody could offer some suggestions as to how I can get them to work I would REALLY appreicate it.
Thanks,
JTM
infinite
07-14-2002, 06:11 PM
What's going into the error log when you access a file?
Here are the two errors that are showing up in the logs:
[Sun Jul 14 18:43:49 2002] [error] [client 12.133.124.200] Directory index forbidden by rule: /home/tickets/public_html/images/
[Sun Jul 14 18:43:55 2002] [error] [client 12.133.124.200] file permissions deny server execution: /home/tickets/public_html/cgi-bin/perldiver.cgi
I'm almost positive I enabled directory indexing. What do I need to do to allow this?
How can I get the server to recognize the .pl scripts? Nothing even showed up in the error log because it doesn't recognize teh mime type.
Also, I CHMODED all the directories/.cgi files to 755. I would also like to be able to run .cgi scripts from any directory instead of just the cgi-bin.
JTM
dandanfirema
07-14-2002, 06:29 PM
Is this a cpanel server by chance?
Nope.....but I am using Webmin.
JTM
dandanfirema
07-14-2002, 06:35 PM
Oh, ok. You using suexec?
I didn't enable it when I compiled Apache and since it isn't installed by default I guess that is why I'm having this problem. Since I'm going to have to recompile Apache is there anyway I can check to make sure mod_perl is working properly? Shouldn't it saw mod_perl when I check my server using What's that site running? on www.netcraft.com? It currently isn't showing up in the list, but it used to in the default install when I got the server.
This is what I used in the makefile script:
build_apache:
@echo "#### Building Apache parts..."
BUILD_PWD=`pwd` && cd $(APACHE_PACKAGE) && PERL5LIB=$$BUILD_PWD/$(PERL_BUILD)/lib/site_perl:$$PERL5LIB ./configure \
--prefix=$(APACHE_PREFIX) \
--activate-module=src/modules/perl/libperl.a \
--enable-shared=max \
--disable-shared=perl \
--enable-module=access --enable-shared=access \
--enable-module=alias --enable-shared=alias \
--enable-module=asis --enable-shared=asis \
--enable-module=auth --enable-shared=auth \
--enable-module=autoindex --enable-shared=autoindex \
--enable-module=cgi --enable-shared=cgi \
--enable-module=dir --enable-shared=dir \
--enable-module=env --enable-shared=env \
--enable-module=info --enable-shared=info \
--enable-module=imap --enable-shared=imap \
--enable-module=include --enable-shared=include \
--enable-module=mime --enable-shared=mime \
--enable-module=mime_magic --enable-shared=mime_magic \
--enable-module=negotiation --enable-shared=negotiation \
--enable-module=proxy --enable-shared=proxy \
--enable-module=rewrite --enable-shared=rewrite \
--enable-module=setenvif --enable-shared=setenvif \
--enable-module=speling --enable-shared=speling\
--enable-module=status --enable-shared=status\
--enable-module=userdir --enable-shared=userdir && \
make && \
make install
build_modperl:
@echo "#### Building MOD_PERL ..."
BUILD_PWD=`pwd` && cd $(MODPERL_PACKAGE) && perl Makefile.PL \
APACHE_SRC=../$(APACHE_PACKAGE)/src \
DO_HTTPD=1 \
USE_APACI=1 \
PREP_HTTPD=1 \
EVERYTHING=1 && \
make && \
Should I just add this under build_apache?
--suexec-enable \
--suexec-caller=nobody \
Are they any other important modules or options that I'm missing?
JTM
allan
07-14-2002, 09:24 PM
Set both Add-Handlers to exec-cgi:
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
You also need to add the following directory statement:
<Directory "/home/tickets/public_html/">
Options Indexes ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
That will enable both CGI execution and allow visitors to view files in a directory if there is no default document.
I added what you said to the httpd.conf file in the virtual hosts section for that website and instead of getting the forbidden error when accessing .cgi scripts, it just shows the code.
Do I still need to recompile apache and enable suexec in order to get my scripts to run?
JTM
Shyne
07-15-2002, 01:54 AM
Have you tried installing apache without mod_perl. I saw mod_perl some times stop perl scripts from running.
Do you even need mod_perl?
chirpy
07-15-2002, 02:57 AM
Just noticed something in the information you gave. In your VirtualHost directive you have ScriptAlias /cgi-bin/ /home/login/public_html/cgi-bin/
In your error log you have file permissions deny server execution: /home/tickets/public_html/cgi-bin/perldiver.cgi
Different directories. Since you've explicitly specified a ScriptAlias, IIRC for that VirtualHost you need to make sure it's path is correct ;)
allan
07-15-2002, 04:50 AM
Originally posted by JTM
I added what you said to the httpd.conf file in the virtual hosts section for that website and instead of getting the forbidden error when accessing .cgi scripts, it just shows the code.
Do I still need to recompile apache and enable suexec in order to get my scripts to run?
You shouldn't need sueec to get CGI scripts to run, suexec is a security enhancement.
The Directory directive is not added in the virtual hosts section, you should have a seperate section in your httpd.conf for directory statements.
Also, try commenting out this line from your Virtual Hosts directive:
ScriptAlias /cgi-bin/ /home/login/public_html/cgi-bin/
Since we are enabling CGI execution for the root directory, you should not need a script alias directory.
It worked! Thanks a lot for all of your help. Thank God I didn't have to go and recompile everything again.
Just one last question.....How can I tell whether or not mod_perl is installed and working properly?
JTM