Default CGI bin in Apache
Written by Frank Contreras on November 26, 2011 – 9:48 pm
The default path for the cgi-bin is
/var/www/cgi-bin
that are served up by requests to
http://<server>/cgi-bin/<myscript.pl>
In order for scripts to be executed in that directory, security needs to be set on the file. For example:
chmod a+x myscript.pl
An example of a Perl script is something like this:
#!/usr/bin/perl print "Content-type: text/html\n\n"; print "Hello world!";
When trying to use CGI.pm in your script with something like:
#!/usr/bin/perl
use CGI qw(:standard);
print header;
print start_html("Welcome!\n");
print h1("My Page");
print h2("page 1...");
print end_html;
And it produces an “Error 500 Internal Server Error” on your browser, but the previous example worked, you’re probably missing perl-CGI. Try installing it using:
yum install perl-CGI
I discovered it was missing when running this command from /:
find -iname CGI.*
Nothing was found. After I ran the installation of perl-CGI, the file is now located here:
/usr/share/perl5/CGI.pm
Tags: Apache, CGI, cgi bin, chmod, perl script