- 论坛徽章:
- 0
|
1、安装前,确保你已经安装了Perl解释器,我机器上安装了ActivePerl 5.8。可以去http://www.perl.org下载,
最终地址:
http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.4.810-MSWin32-x86.zip (ZIP包)
http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.4.810-MSWin32-x86.msi (MSI)
还有5.6版本的Perl,下载页面:
http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl
安装后,查看系统环境变量的PATH项,如果没有perl的路径,自己添加。一般是安装时自动添加的。
2、下载mod_perl源代码,Apache2需要下载1.9或者2.0的,推荐下载2.0
http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz
3、将mod_perl-2.0-current.tar.gz解压,比如H:\mod_perl-2.0-current
开始编译:
H:\mod_perl-2.0-current>;perl Makefile.pl MP_AP_PREFIX=D:\Server\Apache2
这里的D:\Server\Apache2是你安装Apache的路径。
编译时会提示
Install apxs now? [yes]
默认是yes,输入y后回车继续。
编译完成后,你应该得到mod_perl.so。
接下来在命令行执行:
H:\>;ppm install http://theoryx5.uwinnipeg.ca/ppms/mod_perl.ppd
4、配置Apache:
修改https.conf,加入:
- LoadModule perl_module modules/mod_perl.so
- LoadFile "D:/Server/perl/bin/perl58.dll"
- PerlRequire "D:/Server/Apache2/conf/extra.pl"
复制代码
这里的extra.pl内容为:
- use Apache2 ();
- use ModPerl::Util ();
- use Apache::RequestRec ();
- use Apache::RequestIO ();
- use Apache::RequestUtil ();
- use Apache::ServerRec ();
- use Apache::ServerUtil ();
- use Apache::Connection ();
- use Apache::Log ();
- use Apache::Const -compile =>; ':common';
- use APR::Const -compile =>; ':common';
- use APR::Table ();
- use Apache::compat ();
- use ModPerl::Registry ();
- use CGI ();
- 1;
复制代码
httpd.conf中加入:
- Alias /perl/ "E:/wwwroot/perl/"
- <Location /perl>;
- SetHandler perl-script
- PerlResponseHandler ModPerl::Registry
- Options +ExecCGI
- PerlOptions +ParseHeaders
- </Location>;
复制代码
在AddHandler那里加入:
- AddHandler perl-script .pl .cgi
复制代码
重启Apache2。
5、设置perl虚拟目录的everyone权限,加上执行权限。
在你的虚拟目录物理路径中建议一个测试的perl脚本:
test.pl
- ## printenv -- demo CGI program which just prints its environment
- ##
- use strict;
- print "Content-type: text/html\n\n";
- print "<HTML>;<BODY>;<H3>;Environment variables</H3>;<UL>;";
- foreach (sort keys %ENV) {
- my $val = $ENV{$_};
- $val =~ s|\n|\\n|g;
- $val =~ s|"|\\"|g;
- print "<LI>;$_ = \"${val}\"</LI>;\n";
- }
- #sleep(10);
- print "</UL>;</BODY>;</HTML>;";
复制代码
通过http://localhost/test.pl访问,你应该可以看到
Environment variables
COMSPEC = "C:\WINDOWS\system32\cmd.exe"
DOCUMENT_ROOT = "E:/wwwroot/www/"
GATEWAY_INTERFACE = "CGI/1.1"
HTTP_ACCEPT = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*"
HTTP_ACCEPT_LANGUAGE = "en-us"
HTTP_CONNECTION = "Keep-Alive"
HTTP_HOST = "localhost"
HTTP_USER_AGENT = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)"
MOD_PERL = "mod_perl/1.99_17"
PATH = "D:\Server\Perl\bin\;D:\Program Design\MinGW\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;D:\Server\JAVA\jdk1.5.0\bin;D:\Server\cvsnt"
PATHEXT = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH"
QUERY_STRING = ""
REMOTE_ADDR = "127.0.0.1"
REMOTE_PORT = "4346"
REQUEST_METHOD = "GET"
REQUEST_URI = "/perl/hello.cgi"
SCRIPT_FILENAME = "E:/wwwroot/perl/test.pl"
SCRIPT_NAME = "/perl/test.pl"
SERVER_ADDR = "127.0.0.1"
SERVER_ADMIN = "webmaster@wwcec.net"
SERVER_NAME = "localhost"
SERVER_PORT = "80"
SERVER_PROTOCOL = "HTTP/1.0"
SERVER_SIGNATURE = "
Apache/2.0.52 (Win32) mod_perl/1.99_17 Perl/v5.8.4 PHP/5.0.2 mod_python/3.1.3 Python/2.3.4 Server at localhost Port 80
\n"
SERVER_SOFTWARE = "Apache/2.0.52 (Win32) mod_perl/1.99_17 Perl/v5.8.4 PHP/5.0.2 mod_python/3.1.3 Python/2.3.4"
SystemRoot = "C:\WINDOWS"
TEMP = "C:\WINDOWS\TEMP"
WINDIR = "C:\WINDOWS"
这是系统的一些信息。此时,你的mod_perl应该配置成功。
随便写一个脚本:
hello.pl
- print "Content-type:text/html";
- print "Hello World";
复制代码
运行后可以看到Hello World
6、注意的问题:
(1)编译的时候,会出现找不到库的错误,我没管,我的目的是得到mod_perl.so
(2)这一步不能少,否则,PerlRequire "D:/Server/Apache2/conf/extra.pl"会出错。
- ppm install http://theoryx5.uwinnipeg.ca/ppms/mod_perl.ppd
复制代码
对mod_perl了解不多,不知道这么配置是否正确,欢迎批评指正。
Mail:fzj_w@yahoo.com.cn |
|