Install, Setup and Configure CGI and Perl in Windows XP安裝,安裝和配置的CGI和Perl在Windows XP

Prerequisite 先決條件

Obvioulsy, a web server needs to be running on the Windows machine. obvioulsy , Web服務器必須運行於Windows機器。 Refer to this參照此 post郵政 for instructions on how to install Apache2 in Windows.為說明如何安裝的Apache2在Windows 。

Download ActivePerl 下載activeperl

Download ActivePerl from下載activeperl從 http://www.activestate.com/Products/ActivePerl/?mp=1 http://www.activestate.com/products/activeperl/?mp=1 . Click on Free Download to start the download process.按一下就可以免費下載開始下載進程。 There is no need to input any contact info.有沒有需要輸入任何聯繫信息。 Just leave it blank and press ‘Next’ to start the download.剛才請將它留為空白,並按下'下一步' ,開始下載。

Then download the lastest version of Windows MSI package.然後下載最新版的Windows MSI程序包。

Install ActivePerl 安裝activeperl

Start the installation by double clicking the setup file.開始安裝雙擊安裝文件。 Follows the on-screen instruction.跟隨在螢幕上的指示。 If you will be using Perl CGI programs and want to maintain some level of portability between both Linux machines and Windows machines, you may want to install Perl at the same location on your Windows machine as it is on most Linux machines.如果您將使用Perl的CGI程序,並希望維持某種程度的可攜雙方Linux的機器和Windows機器,您可能會想要安裝的Perl在同一地點在你的Windows機器,因為這是對大部分Linux機器。

For example, on Linux machine, Perl is located at /usr/bin/perl and so every Perl program that I write begins with #!/usr/bin/perl .舉例來說, Linux的機器, Perl是位於修改/ usr / bin / Perl和使每一個的Perl程式,我寫開始# !修改/ usr / bin /的Perl So, it’s best when install Perl on an Windows machine, instead of installing it in the default location (ie C:\perl), install it in C:\usr instead, so that the Perl executable is located at /usr/bin/perl.所以,最好的,當安裝的Perl對1的Windows機器,而不是安裝在默認位置(即為C : \的Perl ) ,它安裝在C : \ usr ,反而使該可執行的Perl是位於在/ usr /斌/的Perl 。 This allows codes written on Windows machine been moved to, without changes, to Linux machine, and have it run there, and vice versa.這使得代碼寫在Windows機器被移動到,如果沒有變化,到Linux的機器,它有運行,反之亦然。

To change the installation path, click on browse button when you’re on the installation screen that prompts you to select which features you want to install.要改變安裝路徑,點擊瀏覽按鈕,當您對安裝屏幕提示您選擇其中的功能,你要安裝的。 Set it to C:\usr\ if needed.其設置到C : \ usr \如果需要。

Make sure that the following options is checked (selected):確保下列選項選中(選中) :
Add Perl to the PATH environment variable新增的Perl到PATH環境變量
Create Perl file extension association創建的Perl的文件擴展協會

Activating CGI 激活的CGI

Open the httpd.conf file for editing by selecting Start > Programs > Apache HTTP Server > Configure Apache Server > Edit the Apache httpd.conf Configuration File.打開httpd.conf文件的編輯選擇開始> “程序” > Apache HTTP服務器>配置Apache服務器> “編輯的Apache的httpd.conf配置文件。 Alternatively, open the httpd.conf with any text editor.另外,打開httpd.conf中與任何文本編輯器。

In the main directory section, search for Options Indexes FollowSymLinks (at about line 267), and add ExecCGI to the end so it looks like:在主要的目錄節,搜索選項指標followsymlinks (約267線) ,並添加execcgi到去年底,所以看起來就像這樣:

Options Indexes FollowSymLinks ExecCGI選擇指標followsymlinks execcgi

Search for the following line and remove the hash mark character (#) to uncomment this line.搜索以下行並刪除哈希馬克字符( # )的註釋,這條線。 (You can also change .cgi to .pl, or add .pl behind .cgi if you prefer that perl extention is also treated as cgi files) For example: (您也可以變更。 CGI模式。特等,或者添加。特等落後。 CGI模式如果您希望的Perl延伸,也是被視為CGI文件) ,例如:

#AddHandler cgi-script .cgi # addhandler的CGI -腳本。 CGI模式

Should look like:看起來應該像這樣:

AddHandler cgi-script .cgi .pl addhandler的CGI -腳本。 CGI模式。特等
or
AddHandler cgi-script .pl addhandler的CGI -腳本。特等
or
AddHandler cgi-script .cgi addhandler的CGI -腳本。 CGI模式

Save the httpd.conf configuration file, restart the Apache server.保存的httpd.conf配置文件,重新啟動Apache服務器。 Test the configuration as described in Testing Your Web Server CGI Configuration at the end of this article.測試配置中所述的測試您的Web服務器的CGI配置在本月底的文章。

Optional: Enabling CGI in Any Directory 可選:有利的CGI在任何目錄

If you want to use CGI outside ScriptAliased directory (ScriptAlias is usually the Apache2/cgi-bin/), comment out the following line:如果您想要使用的CGI以外scriptaliased目錄( scriptalias通常是apache2/cgi-bin / ) ,註釋掉下面一行:

ScriptAlias /cgi-bin/ “C:/Program Files/Apache Group/Apache2/cgi-bin/” scriptalias /的CGI斌/的“ C : /程序文件/阿帕奇group/apache2/cgi-bin / ”

Should look like:看起來應該像這樣:

#ScriptAlias /cgi-bin/ “C:/Program Files/Apache Group/Apache2/cgi-bin/” # scriptalias /的CGI斌/的“ C : /程序文件/阿帕奇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.另外,如果您要指定一個目錄把您所有的CGI程序,更改路徑,而不是,但使餘呂杏茜指出,目錄存在。

Should look like (for default settings):看起來應該像這樣(默認設置) :

ScriptAlias /cgi-bin/ “your_prefer_cgi-bin_direcotry” scriptalias /的CGI斌/ “ your_prefer_cgi - bin_direcotry ”

Save the httpd.conf file.保存httpd.conf文件。 Restart the Apache server.重新啟動Apache服務器。

Finding Perl Executable Location 找到的Perl可執行的位置

If you don’t know where is perl.exe installed to, go to Start -> Search and search for perl.exe.如果您不知道在哪裡,是perl.exe安裝,到開始“ ->的搜索和搜索為p erl.exe。 This location is the path to the perl executable that has to be put on the top of all cgi scripts.這個位置是路徑向的Perl的可執行文件已被提上了上方的所有CGI腳本。 If you follow default installation procedure, the path should be C:/perl/bin/perl.exe如果您按照默認的安裝程序,則路徑應該是C : /的Perl /斌/ perl.exe

For the path to perl.exe path, all of these format are valid:為路徑perl.exe的路徑,所有這些格式都是有效的:
#!c:/perl/bin/perl.exe # ! c : /的Perl /斌/ perl.exe
#!c:/perl/bin/perl # ! c : /的Perl /斌/的Perl
#!/perl/bin/perl.exe # ! /的Perl /斌/ perl.exe
#!/perl/bin/perl # ! /的Perl /斌/的Perl

Testing Your Web Server CGI Configuration 測試您的Web服務器的CGI配置

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, ie 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:保存下面的測試腳本在您的documentroot目錄(如果你有註釋scriptalias ,你可以把它在任何地方內的documentroot目錄,或如果您已設置scriptalias一些特定目錄中,提出的CGI在該目錄中只,即apache2/cgi-斌)作為test.pl或test.cgi (視您的配置的addhandler線)和修改第一線,視需要為指向您的activeperl翻譯:

#!c:\perl\bin\perl.exe # !為C : \的Perl \斌\ perl.exe
# ^^^ this must be the first line of the script! # ^ ^ ^這必須是第一線的腳本! ^^^ ^ ^ ^
# start code #啟動代碼

use strict;使用嚴格;
use CGI;使用CGI模式;
my $q = new CGI;我的元q =新的CGI ;

# print header and start the markup output #打印頭,並開始標記輸出

print $q->header( “text/html” ),$q->start_html( “hello from perl cgi!” );打印元的Q - >標題(的“ text / html ” ) ,美元的Q - > start_html ( “您好:由Perl的CGI ! ” ) ;
print $q->h2(”hello dave…”);打印元的Q - >與H2 ( “你好戴夫… … ” ) ;
print $q->end_html;打印元的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). (腳本在apache2/cgi-bin /閱讀作為http://localhost/cgi-bin/默認情況下) 。 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.如果您看到上述訊息, CGI模式運行。 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.如果你得到500錯誤,到最後一個條目在您的apache2/logs/error.log (或檢討錯誤日誌在開始菜單) ,看看究竟是什麼造成了這一錯誤。

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 我的數字生活論壇 .



6 Responses to “Install, Setup and Configure CGI and Perl in Windows XP” 6回應“安裝,安裝和配置的CGI和Perl在Windows XP ”

  1. Install AWStats- Free Logfile Analyzer for Site Statistics » My Digital Life安裝awstats -免費日誌文件分析儀,用於網站的統計»我的數位生活
    January 2nd, 2006 02:19 2006年1月2日2時19分
    1

    [...] As AWStats is Perl based, a Perl Interpreter need to be installed first to take anvantage of AWStats. [ … … ]作為awstats的Perl是基於, 1的Perl口譯員,必須先安裝採取anvantage的awstats 。 For instruction on how to install Perl in Windows machine, check out this article.教學上如何安裝的Perl在Windows機器,請查看此文章。 [...] [ … … ]

  2. Besart besart
    July 25th, 2006 20:53 2006年7月25日20時53分
    2

    I have installed cgi and configured apache as you said, but i got this erro:我已經安裝了CGI和配置的Apache正如你所說的,但我得到這個誤差:

    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.這個錯誤的詳細信息,可能,可在Server錯誤日誌中。

    ——————————————————————————– ---------------------------

    Apache/2.0.58 (Win32) PHP/5.1.4 Server at localhost Port 80 apache/2.0.58 ( Win32的) php/5.1.4服務器上localhost端口80

  3. jack傑克
    May 10th, 2007 19:25 2007年5月10日19時25分
    3

    Cool4you,guys. cool4you ,傢伙。

  4. Mitchell米切爾
    June 20th, 2007 08:09 2007年6月20日8時09分
    4

    Just for the record, the above test script throws a 500 error when used as is.只是為了記錄在案,上述測試腳本拋出一個500錯誤時,用來作為是。 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也許這只是一個問題與Firefox顯示文本或一些,但引號,是混淆了,所以有可能導致問題 : )

  5. Johanna約翰娜
    October 8th, 2007 23:05 2007年10月8日23時05分
    5

    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:我已遵循上述步驟,並改變了引號,和我得到的是9錯誤訊息:

    Backslash found where operator expected at Z.\test.cgi line 1, near “rtf1\”反斜杠發現那裡的經營者,預計在Z的\ test.cgi 1號線,近“ rtf1 \ ”
    or ….或… … 。 , near “ansi\” ,近“的ANSI \ ”
    or ….或… … 。 , near “deff0″ ,近“ deff0 ”
    or ….或… … 。 , near “f1\” ,近“的F1 \ ”
    etc..等。

    I am a total rookie with these things, any help appreciated =)我是一個總的新秀這些事情,任何的幫助表示讚賞= )

    Thanks,謝謝,

    Johanna約翰娜

  6. Munir穆尼爾
    November 28th, 2007 22:14 2007年11月28日22時14分
    6

    I did everything you said.我盡了一切你說。 But cgi is still not running.但CGI模式仍是沒有運行。 Please help.請幫幫忙。
    my apache is 2.2我的Apache是2.2

Leave a Reply離開的答复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用這些標籤:的<a href="" title=""> <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> <刪除日期時間= “ ” >的<em>的<i> <q cite=""> <strike>的<strong>

Subscribe without commenting訂閱無評論


Custom Search

New Articles新的條款,

Incoming Search Terms for the Article傳入的搜索條件文章

download perl.exe 下載perl.exe - - install perl on windows xp 安裝的Perl在Windows XP - - Perl.exe download perl.exe下載 - - perl.exe perl.exe - - apache2 enable cgi Apache2中啟用的CGI - - perl apache2 的Perl的Apache2 - - perl for windows XP 的Perl用於Windows XP - - perl vista Vista中的Perl - - enable cgi apache2 使的CGI的Apache2 - - install perl on vista 安裝的Perl在Vista - - how to install perl on windows XP 如何安裝的Perl在Windows XP - - configure perl 配置的Perl - - perl setup download 下載安裝的Perl - - install perl xp XP中安裝的Perl - - download perl for windows xp 下載的Perl用於Windows XP - - PERL for windows vista 的Perl適用於Windows Vista - - perl download for windows xp 的Perl下載適用於Windows XP - - XAMPP Perl CGI xampp的Perl的CGI - - xampp path to perl xampp路徑的Perl - - download perl setup 下載安裝的Perl - - perl windows vista 的Perl的Windows Vista - - install perl vista Vista的安裝的Perl - - xampp perl path xampp的Perl路徑 - - free download perl.exe 免費下載perl.exe - - perl download xp XP中的Perl下載 - - apache2 perl Apache2中的Perl - - apache2 cgi enable Apache2中的CGI使 - - configure cgi 配置的CGI - - how to configure perl 如何配置的Perl - - free download perl interpreter 免費下載的Perl口譯 - - INSTALL PERL FOR WINDOWS XP 安裝的Perl用於Windows XP - - apache2 configure cgi Apache2中配置的CGI - - Perl interpreter for windows XP 口譯員的Perl用於Windows XP - - all 全部 - - how to install perl on vista 如何安裝的Perl在Vista - - perl interpreter free download 的Perl口譯免費下載 - - perl for xp 用於Windows XP的Perl - - install perl windows xp 安裝的Perl的Windows XP - - perl interpreter vista 口譯Vista中的Perl - - windows xp cgi Windows XP中的CGI - - how to install perl in windows xp 如何安裝的Perl在Windows XP - - perl download for xp 下載的Perl用於Windows XP - - apache perl configuration 阿帕奇的Perl配置 - - perl.exe free download perl.exe免費下載 - - install perl on xp 安裝在XP上的Perl - - how to configure cgi 如何配置的CGI - - perl exe download exe下載文檔的Perl - - perl setup 安裝的Perl - - enable cgi in apache2 使在Apache2中的CGI - - apache2 allow cgi Apache2中允許的CGI - - Free Download Perl for Windows XP 免費下載的Perl用於Windows XP - - perl interpreter for vista 口譯員的Perl對Vista - - perl for windows XP download 的Perl為Windows XP下載 - - apache2 perl setup Apache2中的Perl安裝 - - apache2 configure perl Apache2中配置的Perl - - how to install perl on windows vista 如何安裝的Perl在Windows Vista - - Perl Windows XP Windows XP中的Perl - - perl setup for windows 的Perl安裝的Windows - - perl windows configuration 的Perl的Windows配置 - - download perl exe 下載的Perl的EXE - - download perl Windows XP 下載的Perl的Windows XP - - configure perl apache2 配置的Perl的Apache2 - - enable cgi on apache 使的CGI就阿帕奇 - - xampp perl configure xampp的Perl配置 - - free perl download for Windows XP 免費的Perl下載適用於Windows XP - - "perl for vista" “的Perl為柳暗花明” - - how to install perl on xp 如何安裝的Perl在XP上 - - perl windows install Windows安裝的Perl - - How to Configure Perl in Windows 如何配置的Perl在Windows - - xampp enable cgi xampp啟用的CGI - - apache2 cgi configuration Apache2中的CGI配置 - - perl download windows xp 的Perl下載Windows XP - - perl configure 的Perl配置 - - perl interpreter windows vista 口譯員的Perl的Windows Vista - - configure cgi apache2 配置的CGI的Apache2 - -