I just was given a new Cent OS virtual server to setup with a web application running Apache 2.2. I have one perl script that needs to run through a browser and I just get error 500 in my browser when trying to run it.
I setup a simple helloworld test to simply get perl to output some info to the browser.
I added this to httpd.conf
<Directory "/var/www/my_main_dir/testperl">
AddHandler cgi-script .cgi .pl
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
I created a hello.pl file that simply contains two lines:
print "Content-type: text/html\n\n";
print "Hello, world!\n";
Trying to pull this up in a browser ( http://mydomain.com/testperl/hello.pl ) results in the 500 Internal Server Error.
Meanwhile, I created hello.html:
print <HTML><BODY>
Hello, world!
</BODY></HTML>
and that comes up fine in my browser ( http://mydomain.com/testperl/hello.html )
Any help would be appreciated.
The comment is right, you need a shebang so knows what to do with your Perl script. Assuming Perl is as /usr/bin/perl, add
#!/usr/bin/perlas the first line.If it still doesn’t work, make sure that the Perl script is executable, and that the user Apache runs as has permission to execute it.