为了回家工作和学习perl,不得不在laptop上装一个windows的perl环境。
Google一下,安装步骤和注意事项。另外还是主要看看cpan上的介绍比较官方。
还是那句老话,按照这里的流程,但不要拘泥于这里,因为大家的知识背景和软件环境不一定相同,请随机应变吧~
1. 安装Apache ( http://httpd.apache.org) )和 ActiveState Perl (http://www.activestate.com/ )。
如果去cpan上看,还是可以到这里的。同时可以看到,除了ActiveState的perl外,还有一个开源的环境,应该也是可以用的。
2. 安装mod_perl。
ppm install http://theoryx5.uwinnipeg.ca/ppmpackages/mod_perl.ppd安装完毕之后会提示输入Apache的路径,输入类似于 D:/Apache2/modules。
注意:可以先到这里看看详情http://theoryx5.uwinnipeg.ca/ppmpackages,看到提示你安装跟自己的perl版本一致的版本,我的版本是(命令perl -v) 得到v5.12.2,所以应该用如下命令安装:
C:\setup\perl\bin>ppm install http://cpan.uwinnipeg.ca/PPMPackages/12xx/mod_perl.ppd
详情看这里:http://cpan.uwinnipeg.ca/PPMPackages/
另外:我碰到如下提示,所以就先安装gcc编译器吧。
It looks like you don't have a C compiler on your PATH, so you will not be
able to compile C or XS extension modules. You can install GCC from the
MinGW package using the Perl Package Manager by running:
ppm install MinGW
安装完毕后显示:
Fetching http://cpan.uwinnipeg.ca/PPMPackages/12xx/x86/mod_perl.so ... done!
Where should mod_perl.so be placed? [D:/Apache2.2/modules] C:\setup\Apache2.2\modules
mod_perl.so has been successfully installed to C:/setup/Apache2.2/modules.
To enable mod_perl, put in the directives
LoadFile "C:/Path/to/Perl/bin/perl510.dll"
LoadModule perl_module modules/mod_perl.so
in httpd.conf. For more information, visit
http://perl.apache.org/
and especially see
http://perl.apache.org/docs/2.0/rename.html
3. 配置mod_perl。修改httpd.conf。
增加以下几行:
LoadFile "c:/setup/perl/bin/perl512.dll"
LoadModule perl_module modules/mod_perl.so
如果安装的httpd自带ssh,则不需要手动配置添加如下行:
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
修改:
在Apache的安装目录下找到conf/httpd.conf文件,用记事本或其他的文本编辑器打开。
查找“ScriptAlias /cgi-bin/”,可能你的会是下面的这个结果:
ScriptAlias /cgi-bin/ “C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/”
如果这行前面的有个“#”符号,就将它去掉。
找到下面的这段文本:
<Directory />
Options FollowSymLinks
AllowOverride all
Order deny,allow
Deny from all
</Directory>
加上“+ExecCGI”,即:
<directory />
Options FollowSymLinks +ExecCGI
AllowOverride all
Order deny,allow
Deny from all
</Directory>
一般来说,Perl CGI脚本就是以cgi为拓展名的,不过你也可以设置成pl为拓展名。修改方法是这样的,查找下面的这行:
AddHandler cgi-script .cgi
在末尾加上“.pl”,即:
AddHandler cgi-script .cgi .pl
4. 重新启动Apache。
补充问题:
问题:The server encountered an internal error ormisconfiguration and was unable to completeyour request.
查看$HOME/logs/error.log可以看到下面的错误:
The system cannot find the file specified. : couldn't create child process: 720002: printenv.pl
The system cannot find the file specified. : couldn't spawn child process: C:/setup/Apache2.2/cgi-bin/printenv.pl
网上搜索了很多关于此问题的答案,无果。最终解决方法:
还是看httpd的官方文档,终于解决。可能的问题为:
#1. perl文件的文件头路径没有写正确,如#! c:/setup/perl /bin/perl.exe
#2. 新的httpd2.2(2.0可能也这样),需要在最前面增加下面一行(下面下划线)。
#! c:/setup/perl/bin/perl.exe
print "Content-type: text/html\n\n";
...your_content_below...
为这个问题折腾了整整一天半。这一行的作用主要是告诉浏览器返回的类型,这涉及到标准CGI输出,还要明白Server和CGI和客户端的关系、通信、作用。
--有些详细的东西,尤其是版本不一致的情况下,一定要看官方的文档,否则很容易走弯路。
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com