安装,设定并且配置CGI和Perl在Windows XP
前提
Obvioulsy,网络服务器需要跑在窗口机器。 参考此 岗位 为指示关于怎样安装Apache2在窗口。
下载ActivePerl
下载ActivePerl从 http://www.activestate.com/Products/ActivePerl/?mp=1. 点击免费下载开始下载过程。 没有需要输入所有联络信息。 请其次任它空白和新闻`’开始下载。
然后下载窗口MSI包裹的lastest版本。
安装ActivePerl
开始设施通过双击设定文件。 遵守在屏幕指示。 如果您使用Perl CGI节目和想要维护轻便的某一水平在Linux机器和窗口机器之间,您可以想要安装Perl在同一个地点在作为它是在多数Linux机器的您的窗口机器。
例如,在Linux机器, Perl位于/usr/bin/perl,并且那么我写的每个Perl节目开始与 #! /usr/bin/perl. 如此,这是最佳,当安装Perl在窗口机器时,而不是安装它在默认位置(即。 C:\perl),在C:\usr改为安装它,因此Perl可执行位于/usr/bin/perl。 这允许在窗口机器写的代码被移动向,不用变动,对Linux机器,并且安排它那里和反之亦然跑。
要更换设施道路,点击浏览按钮,当您是在提示选择的您特点您想要设施的设施屏幕时。 设置它对C:\usr\,如果需要。
切记以下选择被检查(选择) :
增加Perl到道路环境变量
创造Perl文件扩展名协会
激活的CGI
打开httpd.conf文件为编辑通过选择起动>节目>亚帕基印第安人Http服务器>配置Apache Server >编辑亚帕基印第安人httpd.conf配置文件。 二者择一地,打开httpd.conf用所有文本编辑程序。
在主要目录部分,查寻选择索引FollowSymLinks (在大约线267),和增加ExecCGI到末端,因此它看喜欢:
选择索引FollowSymLinks ExecCGI
搜寻以下线并且去除军役袖张字符(#)对uncomment这条线。 (您能也改变.cgi到.pl,或者增加.pl在.cgi之后,如果您更喜欢perl extention也对待cgi归档)例如:
#AddHandler cgi剧本.cgi
如果神色喜欢:
AddHandler cgi剧本.cgi .pl
或
AddHandler cgi剧本.pl
或
AddHandler cgi剧本.cgi
保存httpd.conf配置文件,重新开始Apache Server。 测试配置如所描述在测试您的网络服务器CGI配置在这篇文章的结尾。
任意: Enabling CGI in Any Directory
If you want to use CGI outside ScriptAliased directory (ScriptAlias is usually the Apache2/cgi-bin/), comment out the following line:
ScriptAlias /cgi-bin/ “C:/Program Files/Apache Group/Apache2/cgi-bin/”
Should look like:
#ScriptAlias /cgi-bin/ “C:/Program Files/Apache Group/Apache2/cgi-bin/”
Alternatively, if you want to specify just one directory to put all your cgi programs, change the path instead, but makes ure that directory exists.
Should look like (for default settings):
ScriptAlias /cgi-bin/ “your_prefer_cgi-bin_direcotry”
Save the httpd.conf file. Restart the Apache server.
Finding Perl Executable Location
If you don’t know where is perl.exe installed to, go to Start -> Search and search for perl.exe. This location is the path to the perl executable that has to be put on the top of all cgi scripts. If you follow default installation procedure, the path should be C:/perl/bin/perl.exe
For the path to perl.exe path, all of these format are valid:
#!c:/perl/bin/perl.exe
#!c:/perl/bin/perl
#!/perl/bin/perl.exe
#!/perl/bin/perl
Testing Your Web Server CGI Configuration
Save the following test script in your DocumentRoot directory (if you have uncomment ScriptAlias, you can put it anywhere inside your DocumentRoot directory, or if you have set ScriptAlias to some particular directory, put the cgi in that directory only, i.e Apache2/cgi-bin) as test.pl or test.cgi (depending on your configuration of the AddHandler line) and modify the first line as required to point to your ActivePerl interpreter:
#!c:\perl\bin\perl.exe
# ^^^ this must be the first line of the script! ^^^
# start code
use strict;
use CGI;
my $q = new CGI;
# print header and start the markup output
print $q->header( “text/html” ),$q->start_html( “hello from perl cgi!” );
print $q->h2(”hello dave…”);
print $q->end_html;
# end code
Now go to http://localhost/cgi-bin/test.cgi (scripts in Apache2/cgi-bin/ are read as http://localhost/cgi-bin/ by default). You should see a page that displays a level two heading with the following text:
hello dave
If you see the above message, CGI is running. If you get a 500 error, go to the last entry in your Apache2/logs/error.log (or the Review Error Log in the Start menu) to see exactly what caused this error.
IMPORTANT: This is a machine translated page which is provided "as is" without warranty. Machine translation may be difficult to understand. Please refer to original English article whenever possible.
Share and contribute or get technical support and help at My Digital Life Forums.
Related Articles
- Install AWStats- Free Logfile Analyzer for Site Statistics
- Easily Set Up Web Server with XAMPP
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4
- CPAN Missing Parameter auto_commit Message
- Internal Error 2739 Error in Vista (32 or 64-bit) When Install Adobe Photoshop CS3 and Reflector Related Programs
- Enable and Display Security Tab in Windows XP Home Edition
- eMule 0.48a for Windows Vista Free Download
- Hack and Workaround to Clean or Fresh Install Windows Vista with Upgrade License DVD
- Trick to Install Windows XP SP3 RC in Non-English Language Editions
- Download Yahoo! Messenger with Voice 8 Full Standalone Installer

































January 2nd, 2006 02:19
[...] As AWStats is Perl based, a Perl Interpreter need to be installed first to take anvantage of AWStats. For instruction on how to install Perl in Windows machine, check out this article. [...]
July 25th, 2006 20:53
I have installed cgi and configured apache as you said, but i got this erro:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
——————————————————————————–
Apache/2.0.58 (Win32) PHP/5.1.4 Server at localhost Port 80
May 10th, 2007 19:25
Cool4you,guys.
June 20th, 2007 08:09
Just for the record, the above test script throws a 500 error when used as is. Maybe it is just a problem with firefox displaying text or something, but the quotation marks are mixed up, so that could lead to problems
October 8th, 2007 23:05
Hi all,
I really need some help on this subject =)
I have followed the steps above, and changed the quotation marks, and what I get is 9 error messages:
Backslash found where operator expected at Z.\test.cgi line 1, near “rtf1\”
or …. , near “ansi\”
or …. , near “deff0″
or …. , near “f1\”
etc..
I am a total rookie with these things, any help appreciated =)
Thanks,
Johanna
November 28th, 2007 22:14
I did everything you said. But cgi is still not running. Please help.
my apache is 2.2