I have a perl.cgi
file which has the content:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<h1>Hello World</h1>\n";
I made it executable. (chmod a+x perl.cgi
)
Then I created a new file perl.htm
in the same directory. Which has the following data:
Content-type: text/html
<p><a href="perl.cgi">RUN perl.cgi</a></p>
When I run the perl.htm
in my browser then I get the output as:
Content-type: text/html
RUN perl.cgi
When I click on RUN perl.cgi
another page opens and there the output is:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<h1>Hello World</h1>\n";
i.e. the perl.cgi
is not executing. Only the file contents are being shown.
EDIT: From the answers and comments I came to know that I will have to configure my web server (apache) to run cgi scripts. How can I do that? Let me know.
Sounds like Apache is not configured to run *.cgi files:
AddHandler cgi-script cgi pl
<Directory /path/to/cgi/files>
Options +ExecCGI
</Directory>
Make sure you are loading the CGI module in the httpd.conf file:
LoadModule cgi_module modules/mod_cgi.so
or
LoadModule cgi_module modules/mod_cgid.so
depending on which version of Apache you are running.
You can also read about additional solutions for Dynamic Content with CGI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With