centos 5.0内已带用mod_perl,机器没有的话用yum安装:

yum -y install mod_perl

修改mod_perl配置文件: vi /etc/httpd/conf.d/perl.conf

LoadModule perl_module modules/mod_perl.so

PerlModule Apache::compat
<Location /perl-status>
    SetHandler perl-script
    PerlResponseHandler Apache::Status
    Order deny,allow
#    Deny from all
    Allow from all

vi /etc/httpd/conf/httpd.conf

改/var/www/html部分,以便用perl程序在/下能运行:

#
<Directory “/var/www/html”>

    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    PerlOptions +ParseHeaders
    Options +ExecCGI
#    Options Indexes FollowSymLinks

    Order allow,deny
    Allow from all

编写一个测试页:

vi /var/www/html/test.pl

#!/usr/bin/perl -w

use strict;

print Content-type: text/htmlnn;

print Date: , scalar localtime, n;

print %ENV:n, map { _ = ENV{$_}n } keys %ENV;

设置运行权限: chmod 755 /var/www/html/test.pl

重启apache: service httpd restart

测试: http://ip/perl-status/ http://ip/test.pl

能看到运行信息就说明配置成功了。