ÿþ<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=unicode" /> <meta http-equiv="Content-Language" content="en-us" /> <title>Install, configure and test Perl on Windows 2003 Server (Standard Edition)</title> <style> <!-- p.MsoNormal {margin:0mm; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";} a:link {color:blue; text-decoration:underline;} a:visited {color:purple; text-decoration:underline;} p {margin-right:0mm; margin-left:0mm; font-size:12.0pt; font-family:"Times New Roman","serif";} ol {margin-bottom:0mm;} --> </style> <meta name="keywords" content="opensource, open source, Perl, script, sample, web, technology, applications, system, Internet, programs, programming" /> <meta name="description" content="Steps on how to install, configure and test Perl on Windows with detail screenshot steps" /> </head> <body lang="EN-US" link="#0000FF" vlink="#800080" topmargin="20" leftmargin="20" rightmargin="20" bottommargin="20"> <div class="WordSection1"> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <h1 align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font face="Arial">Installing ActivePerl on Windows 2003 Server with Apache</font></h1> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> &nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> &nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> &nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0" align="center"> <script type="text/javascript"><!-- google_ad_client = "pub-8089415323104206"; /* 728x90, created 5/16/08 javaos */ google_ad_slot = "1917524460"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> &nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> &nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">What do we have in this session?</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <ol> <li> <h1 style="margin-top: 0; margin-bottom: 0"><font size="3" face="Arial"> Download Perl Windows Installer</font></h1> </li> <li> <h1 style="margin-top: 0; margin-bottom: 0"><font size="3" face="Arial"> Activating CGI for Apache</font></h1> </li> <li> <h1 style="margin-top: 0; margin-bottom: 0"><font size="3" face="Arial"> Enabling CGI in any directory</font></h1> </li> <li> <h1 style="margin-top: 0; margin-bottom: 0"><font size="3" face="Arial"> Finding your location to perl</font></h1> </li> <li> <h1 style="margin-top: 0; margin-bottom: 0"><font size="3" face="Arial"> Some Notes</font></h1> </li> <li> <h1 style="margin-top: 0; margin-bottom: 0"><font size="3" face="Arial"> Testing CGI</font></h1> </li> <li> <h1 style="margin-top: 0; margin-bottom: 0"><font size="3" face="Arial"> Perl Command Invocation</font></h1> </li> </ol> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"><b> <font size="3" face="Arial"><span style="font-size:12.0pt;font-weight:bold"> Download Perl Windows Installer</span></font></b></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Download the Windows installer version at: <a href="http://www.activestate.com/downloads/" target="_blank" title="ActiveState perl for Windows download page"> activestate.com</a>. This complete and ready-to-install, the <a href="http://www.activestate.com/compare-editions" target="_blank" title="ActiveState perl for Windows features"> free ActivePerl distribution</a> includes core Perl, popular modules, the Perl Package Manager (PPM), and complete documentation. The Windows version provides other additional features that have made ActivePerl the worldwide standard for Perl on Windows.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Double click the MSI installer.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="655" height="76" src="installperlonwindows2k3server_files/perlonwindowsinstalltest001.png" alt="ActivePerl Windows installer file" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Click Next button.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="499" height="385" src="installperlonwindows2k3server_files/perlonwindowsinstalltest002.png" alt="ActivePerl - perl for Windows setup wizard welcome page" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Accept the License Agreement and click Next.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="499" height="385" src="installperlonwindows2k3server_files/perlonwindowsinstalltest003.png" alt="ActivePerl - perl for Windows setup wizard - license agreement" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">In this case we select all the features. Click Next.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="499" height="385" src="installperlonwindows2k3server_files/perlonwindowsinstalltest004.png" alt="ActivePerl - perl for Windows setup wizard - selecting features to be installed" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">View the disk space requirement and then click the OK button.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="499" height="385" src="installperlonwindows2k3server_files/perlonwindowsinstalltest005.png" alt="ActivePerl - perl for Windows setup wizard - disk space requirement" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">In this case we select all the options. Click Next.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="499" height="385" src="installperlonwindows2k3server_files/perlonwindowsinstalltest006.png" alt="ActivePerl - perl for Windows setup wizard - choosing options" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Click Install to start the installation.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="499" height="385" src="installperlonwindows2k3server_files/perlonwindowsinstalltest007.png" alt="ActivePerl - perl for Windows setup wizard - ready to install page" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">The installation should begin.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="499" height="385" src="installperlonwindows2k3server_files/perlonwindowsinstalltest008.png" alt="ActivePerl - perl for Windows setup wizard - installation in progress" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Click the Finish button. If there are any errors, those error should be displayed during the installation process.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="499" height="385" src="installperlonwindows2k3server_files/perlonwindowsinstalltest009.png" alt="ActivePerl - perl for Windows setup wizard - installation was completed" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Now, check the path in the Windows environment variables. All the path should be set as shown below by the installation wizard.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="384" height="423" src="installperlonwindows2k3server_files/perlonwindowsinstalltest010.png" alt="ActivePerl - perl for Windows setup wizard - perl path settings in Windows environment variables" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Then, test the perl command at the Windows command prompt.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="692" height="490" src="installperlonwindows2k3server_files/perlonwindowsinstalltest011.png" alt="ActivePerl - perl for Windows - running the perl command at Windows command prompt" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">The Perl Package Manager (PPM) used for package update/download should be visible from Windows Start menu.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="483" height="93" src="installperlonwindows2k3server_files/perlonwindowsinstalltest012.png" alt="ActivePerl - perl for Windows - the Perl Package Manager (PPM) short cut menu" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">The following screenshot shows the Perl root folder.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="347" height="283" src="installperlonwindows2k3server_files/perlonwindowsinstalltest013.png" alt="ActivePerl - perl for Windows - perl installation folder on drive C:" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">If you will be using Perl CGI programs and want to maintain some level of portability between both Linux and Windows machines, you will want to install Perl to the same location on your Windows machine that it is on most Linux machines which is highly recommended that you install perl to a directory like c:\usr\ which resembles the Linux system.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">For example, on a standard Linux machine, Perl is located at <b>/usr/bin/perl</b> and so every Perl program that we write begins with #!/usr/bin/perl. So, when we install Perl on a Windows machine, instead of installing it in the default location (for example, <b>c:\perl</b>) we install it in <b>C:\usr</b> so that the Perl executable is located at <b>/usr/bin/perl</b>. This allows us to write code on our Windows machine, then move it (without making any changes) to a Linux machine and have it run there and vice versa.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="394" height="157" src="installperlonwindows2k3server_files/perlonwindowsinstalltest014.png" alt="ActivePerl - perl for Windows - perl sub-folders" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p style="margin:0 0mm;"><strong><b><font size="3" face="Arial"> <span style="font-size:12.0pt">Activating CGI for Apache</span></font></b></strong></p> <p style="margin:0 0mm;">&nbsp;</p> <p style="margin:0 0mm;"><font face="Arial">Using Notepad (or other unformatted text editor) open </font><strong><b><font face="Arial">C:\Program Files\Apache2_2\conf\httpd.conf<span style="font-weight:normal">, Apache config file </span></font></b></strong><font face="Arial">(also should be a start-menu shortcut called &quot;</font><strong><b><font face="Arial">Edit Apache HTTP httpd.conf File<span style="font-weight:normal">&quot;</span></font></b></strong><font face="Arial">). Your path may be different.</font></p> <p style="margin:0 0mm;"><font size="3" face="Arial"> <span style="font-size:12.0pt">&nbsp;</span></font></p> <p align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="406" height="465" src="installperlonwindows2k3server_files/perlonwindowsinstalltest015.png" alt="ActivePerl - perl for Windows - opening the Apache web server config file" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">And search for</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font face="Courier New"> <span style="font-family:&quot;Arial&quot;; font-weight:700">Options Indexes FollowSymLinks</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">(About line 267) when you find it add ExecCGI to the end so it looks like:</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">Options Indexes FollowSymLinks ExecCGI</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> &nbsp;</p> <table border="0" width="100%"> <tr> <td> <p align="center"><font size="3" face="Arial"> <span style="font-size:12.0pt"> <img border="0" width="425" height="424" src="installperlonwindows2k3server_files/perlonwindowsinstalltest016.png" alt="ActivePerl - perl for Windows - editing the Apache config file" /></span></font></td> <td style="border-left-style: solid; border-left-width: 2px"> <p align="center"><script type="text/javascript"><!-- google_ad_client = "pub-8089415323104206"; /* 300x250, created 5/16/08javaos */ google_ad_slot = "8146009330"; google_ad_width = 300; google_ad_height = 250; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></td> </tr> </table> <p class="MsoNormal" align="center" style="text-align:left; margin-top:0; margin-bottom:0"> &nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> &nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"><b> <font size="3" face="Arial"><span style="font-size:12.0pt;font-weight:bold"> Enabling CGI in any directory</span></font></b></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font face="Arial">If you want to use CGI outside the <b>C:/Program Files/Apache2_2/cgi-bin/ ScriptAliased</b> directory, you will need to uncomment the following line (done in this case because we will use Apache s <b>root_document</b> to test the cgi file later):</font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">#AddHandler cgi-script .cgi</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Becomes (removing the #)</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">AddHandler cgi-script .cgi</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="410" height="215" src="installperlonwindows2k3server_files/perlonwindowsinstalltest017.png" alt="ActivePerl - perl for Windows - editing the Apache config file for CGI directory" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">We also added </span></font><font face="Courier New"> <span style="font-family: &quot;Arial&quot;">.pl</span></font><font face="Arial"> behind </font> <font face="Courier New"><span style="font-family:&quot;Arial&quot;">.cgi</span></font><font face="Arial"> so &#39;perl&#39; extension (<b>.pl</b>) is also treated as cgi files.</font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="644" height="304" src="installperlonwindows2k3server_files/perlonwindowsinstalltest018.png" alt="ActivePerl - perl for Windows - setting the cgi and pl extensions for Apache web server" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">If you will be creating your own cgi-bin, you will want to comment out (not done in this case):</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font face="Courier New"> <span style="font-family:&quot;Arial&quot;; font-weight:700">ScriptAlias /cgi-bin/ &quot;C:/Program Files/Apache2_2/cgi-bin/&quot;</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">So it becomes</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700"># ScriptAlias /cgi-bin/ &quot;C:/Program Files/Apache2_2/cgi-bin/&quot;</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="750" height="222" src="installperlonwindows2k3server_files/perlonwindowsinstalltest019.png" alt="ActivePerl - perl for Windows - editing the ScriptAlias for CGI path" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"><b> <font size="3" face="Arial"><span style="font-size:12.0pt;font-weight:bold"> Finding your location to perl</span></font></b></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">If you do not know where your perl.exe installed to, go to Start -&gt; Search and type in a search for perl.exe. This location is the path to perl that you put on the top of all your cgi scripts.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="394" height="164" src="installperlonwindows2k3server_files/perlonwindowsinstalltest020.png" alt="ActivePerl - perl for Windows - the perl executable file" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"><b> <font size="3" face="Arial"><span style="font-size:12.0pt;font-weight:bold"> Some Notes</span></font></b></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font face="Arial">For the perl path C:/perl/bin/perl.exe all of the following are valid. We prefer the last one because of the Linux and Windows portability.</font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font face="Courier New"> <span lang="DE" style="font-family:&quot;Arial&quot;; font-weight:700">#!C:/perl/bin/perl.exe</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font face="Courier New"> <span lang="DE" style="font-family:&quot;Arial&quot;; font-weight:700">#!C:/perl/bin/perl</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font face="Courier New"> <span lang="DE" style="font-family:&quot;Arial&quot;; font-weight:700">#!/perl/bin/perl.exe</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font face="Courier New"> <span lang="DE" style="font-family:&quot;Arial&quot;; font-weight:700">#!/perl/bin/perl </span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span lang="DE" style="font-size:12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"><b> <font size="3" face="Arial"><span style="font-size:12.0pt;font-weight:bold"> Testing CGI</span></font></b></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">If you uncommented (removed the <b>#</b> symbol) the line AddHandler cgi-script .cgi in previous (step #4), then create a file in your Apache s <b>document_root</b> called <b>hello.cgi</b> and put these three lines in it. (if you did not comment/disable it, put the CGI file in <b>C:/Program Files/Apache2_2/cgi-bin/</b>):</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">#!/usr/bin/perl</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">print &quot;Content-type:text/html\n\n&quot;;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">print &quot;hello world&quot;;</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="454" height="286" src="installperlonwindows2k3server_files/perlonwindowsinstalltest021.png" alt="ActivePerl - perl for Windows - a sample of CGI file for testing" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="352" height="228" src="installperlonwindows2k3server_files/perlonwindowsinstalltest022.png" alt="ActivePerl - perl for Windows - a very simple hello world perl script for testing" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Restart Apache if it is already running. Now go to <a href="http://localhost/hello.cgi">http://localhost/hello.cgi</a> (or wherever you put the file) and run the script.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="531" height="331" src="installperlonwindows2k3server_files/perlonwindowsinstalltest023.png" alt="ActivePerl - perl for Windows - running the Apache web server" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">If you get a <b>hello world</b> in your browser as shown below, CGI is running. If you get a 500 error, go to the last entry in <b>C:/Program Files/Apache2_2/logs/error.log</b> (or the Review Error Log in the start menu) to see exactly what caused this error.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="539" height="318" src="installperlonwindows2k3server_files/perlonwindowsinstalltest024.png" alt="ActivePerl - perl for Windows - cgi file executed through browser (Apache web server)" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">We think this will help you to run perl on windows platform using Apache web server. You may want to try another simple example using .pl extension. Create a file with <b>.pl</b> extension with the following simple script and run it through Internet browser as done previously.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="293" height="250" src="installperlonwindows2k3server_files/perlonwindowsinstalltest025.png" alt="ActivePerl - perl for Windows - running perl script with .pl extension" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="364" height="188" src="installperlonwindows2k3server_files/perlonwindowsinstalltest026.png" alt="ActivePerl - perl for Windows - a very simple perl script for testing" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"><b> <font size="3" face="Arial"><span style="font-size:12.0pt;font-weight:bold"> Perl Command Invocation</span></font></b></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Assuming that your Perl is correctly installed and working on your system, the simplest way to run a Perl program from Windows console is to type the following command:</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">perl filename.pl</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">The filename should be replaced by the name of the program that you are trying to run or execute. If you created a sample.pl file for example, you can run it like this:</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">perl sample.pl</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">This example assumes that perl is in the execution path; if not, you will need to supply the full path to perl too. For example, on UNIX the command might be:</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">/usr/local/bin/perl sample.pl</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Whereas on Windows NT, you might need to use:</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">c:\perl5\bin\perl sample.pl</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">As an example we create the following simple, sample.pl file and put it on C:\.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span lang="DE" style="font-size:12.0pt;font-family:&quot;Arial&quot;; font-weight:700"> #!C:/perl/bin/perl</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font face="Courier New"> <span style="font-family:&quot;Arial&quot;; font-weight:700">print &quot;Content-type:text/html\n\n&quot;;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font face="Courier New"> <span style="font-family:&quot;Arial&quot;; font-weight:700">print &quot;hello cruel world&quot;;</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Then we run it from Windows console.</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" align="center" style="text-align:center; margin-top:0; margin-bottom:0"> <font size="3" face="Arial"><span style="font-size:12.0pt"> <img border="0" width="245" height="133" src="installperlonwindows2k3server_files/perlonwindowsinstalltest027.png" alt="ActivePerl - perl for Windows - running perl script from Windows command prompt" /></span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">UNIX systems have another way to invoke a program. However, you need to do two things. The first is to place a line like</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">#!/usr/local/bin/perl</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">at the start of the Perl file. This tells UNIX that the rest of this script file is to be run by <b>/usr/local/bin/perl</b>. The second step is to make the program file itself executable by changing its mode</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">chmod +x sample.pl</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Now you can execute the program file directly and let the program file tell the operating system what interpreter to use while running it. The new command line is simply:</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Courier New"> <span style="font-size:12.0pt; font-family:&quot;Arial&quot;; font-weight:700">sample.pl</span></font></p> </blockquote> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">&nbsp;</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0"> <font size="3" face="Arial"><span style="font-size: 12.0pt">Well, that all folks!</span></font></p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0">&nbsp;</p> <p class="MsoNormal" style="margin-top: 0; margin-bottom: 0" align="center"><script type="text/javascript"><!-- google_ad_client = "pub-8089415323104206"; /* 728x15, created 5/16/08javaos */ google_ad_slot = "3545464564"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></p> <hr color="#FF0000" /> <p class="MsoNormal" style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center"> <font face="Arial" size="5"> <a title="The Java and open source applications" target="_top" href="http://www.javaguicodexample.com/"> Back to Main</a></font></p> <p class="MsoNormal" style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="left"> &nbsp;</p> <p class="MsoNormal" style="line-height: 100%; margin-top: 0; margin-bottom: 0" align="center"> <script src="http://tag.contextweb.com/TagPublish/getjs.aspx?action=VIEWAD&cwrun=200&cwadformat=728X90&cwpid=527221&cwwidth=728&cwheight=90&cwpnet=1&cwtagid=85440"></script></p> </div> </body> </html>