在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
wget http://apache.freelamp.com/httpd/httpd-2.2.11.tar.gz mod_perl2 wget http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz 将下载到的文件放入 /usr/local/src 中,本例是采用apache静态编译的方式将mod_perl编译进apache中的 在这里因为perl在安装系统是默认已经安装 perl v5.8.8 cd /usr/local/src tar xvzf httpd-2.2.11.tar.gz tar xvzf mod_perl-2.0-current.tar.gz cd mod_perl-2.0.4 perl Makefile.PL \ MP_USE_STATIC=1 \ MP_AP_PREFIX="/usr/local/src/httpd-2.2.11" \ MP_AP_CONFIGURE="--with-mpm=prefork" make make install 至此mod_perl已经安装到apache中了,我们来测试一下apache是否存在mod_perl模块 [root@localhost src]# /usr/local/apache2/bin/httpd -l |grep perl mod_perl.c mod_perl模块已经安装成功,我来配置一下httpd.conf文件后就可以启动apache来运行perl脚本了 打开httpd.conf文件找到 查找 AddHandler cgi-script .cgi .pl 去掉前门的# 查找 ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/" 行,在下面加入一行 ScriptAlias /perl/ "/usr/local/apache2/perl/" 接下来在 <Directory "/usr/local/apache2/cgi-bin"> AllowOverride All Options None Order allow,deny Allow from all </Directory> 下面加上 <Directory "/usr/local/apache2/perl"> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI AllowOverride None Order allow,deny Allow from all </Directory> 到此为止 mod_perl就可以正常工作了, 启动apache /usr/local/apache2/bin/apachectl start 将 cp /usr/local/apache2/cgi-bin/printenv /usr/local/apache2/perl/ 在浏览器中输入 http://192.168.1.199/perl/printenv 就可以看到以下的内容 DOCUMENT_ROOT="/usr/local/apache2/htdocs" GATEWAY_INTERFACE="CGI/1.1" HTTP_ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" HTTP_ACCEPT_CHARSET="gb2312,utf-8;q=0.7,*;q=0.7" HTTP_ACCEPT_ENCODING="gzip,deflate" HTTP_ACCEPT_LANGUAGE="en-us,zh-cn;q=0.5" HTTP_CONNECTION="keep-alive" HTTP_HOST="192.168.1.199" HTTP_KEEP_ALIVE="300" HTTP_USER_AGENT="Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6" MOD_PERL="mod_perl/2.0.4" MOD_PERL_API_VERSION="2" PATH="/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" QUERY_STRING="" REMOTE_ADDR="192.168.1.102" REMOTE_PORT="1549" REQUEST_METHOD="GET" REQUEST_URI="/perl/printenv" SCRIPT_FILENAME="/usr/local/apache2/perl/printenv" SCRIPT_NAME="/perl/printenv" SERVER_ADDR="192.168.1.199" SERVER_ADMIN="[email protected]" SERVER_NAME="192.168.1.199" SERVER_PORT="80" SERVER_PROTOCOL="HTTP/1.1" SERVER_SIGNATURE="" SERVER_SOFTWARE="Apache/2.2.11 (Unix) mod_perl/2.0.4 Perl/v5.8.8" |
请发表评论