Search code examples
apacheperlhttpd.confcentos6.5

Cannot see perl script on webpage (correct in CMD)


My Perl program works correctly from the command line but not as a web page.

Here is my script:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<html>\n";
print "<title> PERL CGI</title>\n";
print "<body>";
print "hello perl-cgi!!!!!!!";
print "</body>";
print "</html>\n";

Error on wepbage is: Internal Server Error

Error from error log:

[Tue Oct 04 10:04:41 2016] [error] [client 172.23.40.113] (8)Exec format error: exec of '/var/www/html/test2.pl' failed
[Tue Oct 04 10:04:41 2016] [error] [client 172.23.40.113] Premature end of script headers: test2.pl

Here is a part of /etc/httpd/conf/httpd.conf

<Directory "/var/www/html">
Options ALL
AllowOverride None
Order allow,deny
Allow from all
Options +ExecCGI -Indexes
AddHandler cgi-script .cgi .pl  </Directory>

These are the contents of the www/html directory

786875 -rwxr-xr-x. 1 root root 16     3. ĹĂ­j     10.54 incex.html 
786669 -rwxr-xr-x. 1 root root 22     27. zåŠ  10.00 index.html 
786688 -rwxr-xr-x. 1 root root 21     3. ĹĂ­j     08.47 info.php 
786899 -rwxr-xr-x. 1 root root 2765   3. ĹĂ­j     14.51 test.pl 
786834 -rwxr-xr-x. 1 root root 161    3. ĹĂ­j     15.36 test2.cgi 
786833 -rwxr-xr-x. 1 root root 259    4. ĹĂ­j     11.43 test2.pl

Solution

  • Thanks for your help.. now it works.. problem was very simple (and stupid). I did not see it in nano.. my script started on second line.. so it was not start with #!/usr/bin/perl