itnifl
asked on
Enable CGI scripts in Debian Apache2
My /etc/apache2/sites-availab le/default is set up to handle cgi or pl files like this:
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options FollowSymLinks +ExecCGI
#Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
AddHandler cgi-script .cgi .pl
</Directory>
/usr/lib/cgi-bin/perltest. pl is set to chmod 755 and contains this:
###Start###
#!/usr/bin/perl -w
print "Content-type: text/html\r\n\r\n";
print "Hello there!<br />\nJust testing .<br />\n";
for ($i=0; $i<10; $i++)
{
print $i."<br />";
}
###End###
I try to execute the script via the browser:
http://server/cgi-bin/perltest.pl
I get the error: HTTP 500 page can not be displayed, internal server error.
I followed this guide to set this up: http://www.ubuntugeek.com/how-to-install-apache2-webserver-with-phpcgi-and-perl-support-in-ubuntu-server.html
I know my setup is slightly different.
Any suggestions?
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options FollowSymLinks +ExecCGI
#Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
AddHandler cgi-script .cgi .pl
</Directory>
/usr/lib/cgi-bin/perltest.
###Start###
#!/usr/bin/perl -w
print "Content-type: text/html\r\n\r\n";
print "Hello there!<br />\nJust testing .<br />\n";
for ($i=0; $i<10; $i++)
{
print $i."<br />";
}
###End###
I try to execute the script via the browser:
http://server/cgi-bin/perltest.pl
I get the error: HTTP 500 page can not be displayed, internal server error.
I followed this guide to set this up: http://www.ubuntugeek.com/how-to-install-apache2-webserver-with-phpcgi-and-perl-support-in-ubuntu-server.html
I know my setup is slightly different.
Any suggestions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The script has these rights as described in the question: 755 = u=rwx,g=rx,o=rx.
/var/log/apache2/error.log :
[Tue Mar 24 16:17:16 2009] [error] [client 192.168.1.101] (8)Exec format error: exec of '/usr/lib/cgi-bin/perltest .pl' failed
[Tue Mar 24 16:17:16 2009] [error] [client 192.168.1.101] Premature end of script headers: perltest.pl
So I guess there is something wrong with the script. I have not really started reading on creating CGI files with Perl, but wanted to see my Apache server being able to run the scripts anyway. The script was copied from a tutorial page on the net. Anyone see anything wrong with it?
/var/log/apache2/error.log
[Tue Mar 24 16:17:16 2009] [error] [client 192.168.1.101] (8)Exec format error: exec of '/usr/lib/cgi-bin/perltest
[Tue Mar 24 16:17:16 2009] [error] [client 192.168.1.101] Premature end of script headers: perltest.pl
So I guess there is something wrong with the script. I have not really started reading on creating CGI files with Perl, but wanted to see my Apache server being able to run the scripts anyway. The script was copied from a tutorial page on the net. Anyone see anything wrong with it?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah, it was. Didnt think it mattered.. thanks...
ASKER
Thanks!
use CGI::Carp 'fatalsToBrowser';
in your script.
Did you chmod +x the script?