开发者

How can I enable Perl web scripts to run on Apache?

I have a Perl script which is scripted to print "Hello!" on a web browser. I am using apache as my localhost server. The OS I am using is the Red Hat 5.

The problem is that when I type the address http://localhost/example.pl or http://127.0.0.1/example.pl, it shows me exactly the entire script codes but not the "Hello!" word that should be output.

The Perl script:

开发者_JAVA百科#!/usr/bin/perl

print "content-type: text/html \n\n";

print "Hello, Perl!";

Anyone has any ideas on this? Thanks!


You have to put it in cgi-bin

As you noticed, files that are not processed by the interpreter are returned as downloadable text files, therefore apache designates space where files will be interpreted/processed by the server (the common gateway interface bin).

First you have to set up apache to point to a cgi-bin directory - it does this by default, you can put your file there. Once your file is there the URI would be something like: http://localhost/cgi-bin/example.pl


Note: you cannot put html/js in the cgi-bin as they will be processed and will cause a server fault.

I recommend reading more from apache's website.


The Apache docs tell you how to configure your webserver to run CGI programs in Apache Tutorial: Dynamic Content with CGI.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜