home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2004 July / APC0407D2.iso / workshop / apache / files / ActivePerl-5.6.1.638-MSWin32-x86.msi / _771e06324249a6cec1172cdd6675ebc8 < prev    next >
Encoding:
Text File  |  2004-04-13  |  28.9 KB  |  621 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3.  
  4. <head>
  5. <title>ActivePerl FAQ - Web Server Information</title>
  6. <link rel="STYLESHEET" href="../../Active.css" type="text/css" media="screen">
  7. </head>
  8.  
  9. <body>
  10.  
  11. <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EAE2BB">
  12. <tr> 
  13. <td width="57"><a target=_blank href="http://www.ActiveState.com/ActivePerl/">
  14. <img src="../../images/activeperl_logo.gif" width="57" height="48" border="0" alt="ActivePerl"></a></td>
  15. <td><div align="center" class="heading">ActivePerl User Guide</div></td>
  16. <td width="112"><a target=_blank  href="http://www.ActiveState.com">
  17. <img src="../../images/AS_logo.gif" width="112" height="48" border="0"  alt="ActiveState" /></a></td>
  18. </tr>
  19. <tr>
  20. <td class="lineColour" colspan="3"></td>
  21. </tr>
  22. </table>
  23.  
  24. <h1>Web Server Information</h1>
  25.  
  26. <ul>
  27.   <li><a class="doc" href="#NAME">NAME</a></li>
  28.   <li><a class="doc" href="#DESCRIPTION">DESCRIPTION</a>
  29.     <ul>
  30.       <li><a class="doc" href="#What_HTTP_servers_support_Perl_f">What HTTP servers support
  31.         ActivePerl?</a></li>
  32.       <li><a class="doc" href="#How_do_I_use_Perl_for_Win32_unde">How do I use ActivePerl
  33.         under Apache?</a></li>
  34. <!--      <li><a class="doc" href="#How_do_I_configure_the_EMWAC_htt">How do I configure the
  35.         EMWAC https server to support ActivePerl?</a></li>-->
  36.       <li><a class="doc" href="#How_do_I_configure_IIS_3_0_or_lo">How do I configure IIS 3.0
  37.         or lower to support Perl</a></li>
  38.       <li><a class="doc" href="#How_do_I_configure_Microsoft_IIS">How do I configure
  39.         Microsoft IIS 4.0/IIS 5.0 to support Perl</a></li>
  40.       <li><a class="doc" href="#How_do_I_configure_iPlanet_web_">How do I configure
  41.         iPlanet web servers to support ActivePerl?</a></li>
  42. <!--      <li><a class="doc" href="#How_do_I_configure_WebSite_1_0_t">How do I configure WebSite
  43.         1.0 to support ActivePerl?</a></li>
  44.       <li><a class="doc" href="#How_do_I_configure_WebSite_Profe">How do I configure WebSite
  45.         Professional to support ActivePerl?</a></li>-->
  46.       <li><a class="doc" href="#How_do_I_configure_Microsoft_Per">How do I configure
  47.         Microsoft Personal Web Server 1.0x for Windows 95 to</a></li>
  48.       <li><a class="doc" href="#How_do_I_configure_other_web_ser">How do I configure other
  49.         web servers to support ActivePerl?</a></li>
  50.       <li><a class="doc" href="#My_program_runs_fine_from_the_co">My program runs fine from
  51.         the command line, but bombs out when</a></li>
  52.       <li><a class="doc" href="#This_is_all_such_a_hassle_why_c">This is all such a hassle;
  53.         why can't I just put perl.exe in my CGI</a></li>
  54.     </ul>
  55.   </li>
  56.   <li><a class="doc" href="#AUTHOR_AND_COPYRIGHT">AUTHOR AND COPYRIGHT</a></li>
  57. </ul>
  58.  
  59. <h2><a name="NAME">NAME</a></h2>
  60. <p>ActivePerl-faq6 - Web server information</p>
  61.  
  62. <h2><a name="DESCRIPTION">DESCRIPTION</a></h2>
  63. <p>ActivePerl Web Server Configuration and Troubleshooting</p>
  64.  
  65. <h2><a name="What_HTTP_servers_support_Perl_f">What HTTP servers support
  66. ActivePerl?</a></h2>
  67.  
  68. <p>Most Windows web servers that use the CGI standard or ISAPI
  69. will run ActivePerl scripts. The following servers are known to work with
  70. ActivePerl (known protocols in brackets):</p>
  71. <dl>
  72.   <dt><h3><a name="item_Apache">Apache for Win32 [CGI, mod_perl]</a></h3></dt>
  73.   <dd>
  74.     <pre>    <a class="doc" href="http://www.apache.org">http://www.apache.org</a>
  75.     mod_perl home page: <a class="doc" href="http://perl.apache.org">http://perl.apache.org</a>
  76. </pre>
  77.   </dd>
  78.   <dt><h3><a name="item_Microsoft">Microsoft Internet Information Server
  79.     [CGI, ISAPI]</a></h3></dt>
  80.   <dd>
  81.     <pre>    <a class="doc" href="http://www.microsoft.com/iis/">http://www.microsoft.com/iis/</a>
  82. </pre>
  83.   </dd>
  84.   <dt><h3><a name="item_iPlanet">iPlanet Enterprise and FastTrack Server [CGI]</a></h3></dt>
  85.   <dd>
  86.     <pre>    <a class="doc" href="http://www.iplanet.com/">http://www.iplanet.com/</a>
  87. </pre>
  88. </dl>
  89.  
  90. <h2><a name="How_do_I_use_Perl_for_Win32_unde">How do I use ActivePerl under
  91. Apache?</a></h2>
  92. <p>If you want to put all of your CGI scripts into one directory, add the
  93. following line to your <i>srm.conf</i> file (You can choose any directory
  94. you'd like, but make sure it exists):</p>
  95. <pre>
  96.     ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/"
  97. </pre>
  98. <p>After you have made this change, stop and restart the Apache service.</p>
  99. <p>Apache provides an emulation of the UNIX shebang (#!/path/to/perl) syntax, so
  100. the next step is easy. You can put you Perl scripts into your <i>cgi-bin</i>
  101. directory, as long as you have a path to a valid interpreter at the top. For
  102. example:</p>
  103. <pre>
  104.     #!C:\PERL\5.00464\bin\MSWin32-x86\perl.exe
  105.      
  106.     use CGI qw(:standard) ;
  107.     print header();
  108.     print "Hello, world";
  109. </pre>
  110. <p>If you want to enable CGI scripts based on an extension, such as <i>.pl</i>,
  111. you need to add the following line to <i>srm.conf</i>:</p>
  112. <pre>
  113.     AddHandler cgi-script .pl
  114. </pre>
  115. <p>By default, CGI scripts are not allowed in your DocumentRoot directory, but
  116. they are allowed in other document directories. Document directories are created
  117. with the Alias command in <i>srm.conf</i>:</p>
  118. <pre>
  119.     Alias /ResourceKit/ "E:/utilsamp/"
  120. </pre>
  121. <p>You can then include files that end in <i>.pl</i> within a document
  122. directory. You will still need to include the #! line with the full path to the <i>perl.exe</i>
  123. interpreter, as shown earlier.</p>
  124. <p>If you want to allow CGI scripts in the DocumentRoot directory, add the
  125. ExecCGI option to the Options directive between the <Directory> and
  126. </Directory> entry for your DocumentRoot in <i>access.conf</i> (these
  127. appear directly after the comment titled:</p>
  128. <pre>
  129.     # This should be changed to whatever you set DocumentRoot to.
  130. </pre>    
  131. <p>After you have updated it, your Options directive may look something like:
  132. <pre>
  133.     Options Indexes FollowSymLinks ExecCGI
  134. </pre>
  135.  
  136. <h2><a name="How_do_I_configure_IIS_3_0_or_lo">How do I configure IIS 3.0 or
  137. lower to support ActivePerl?</a></h2>
  138. <p>By default, the ActivePerl installation maps the <i>.plx</i> extension to
  139. Perl for ISAPI. You can override the extension used during installation. Because
  140. the installation does this only when IIS is already installed, you must install
  141. IIS first, then install ActivePerl. If you need to reconfigure these settings,
  142. or if you must set these by hand, the instructions in this section will prove
  143. useful.</p>
  144. <p>Microsoft Internet Information Server (IIS) ships with Windows NT Server.
  145. Peer Web Services (PWS) ships with Windows NT Workstation. Configuring the
  146. products is essentially the same. First, you should consult Chapter 8,
  147. Publishing Information and Applications, in the IIS documentation.</p>
  148. <p>You need to follow these steps to get ActivePerl scripts to run under IIS:</p>
  149. <ol>
  150.   <li>
  151.     <p>Associate the extension for your scripts with the appropriate interpreter
  152.     in the script map for IIS. This is under the Registry key HKEY_LOCAL_SYSTEM,
  153.     with the sub-key ``System\CurrentControlSet\Services\W3SVC\Parameters\Script
  154.     Map''. Many people map two extensions: one to <i>perl.exe %s</i> (for
  155.     example, <i>.pl</i>) and another to <i>PerlIS.dll</i> (for example, <i>.plx</i>).
  156.     Note that mapping an extension in the script map is <i>not</i> the same as
  157.     associating the extension in Explorer. Use the full paths to the executable
  158.     files in the script map.</p>
  159.   </li>
  160.   <li>
  161.     <p>Put your scripts in a virtual directory on the server that has Execute
  162.     access but not Read access. You can add virtual directories or view their
  163.     access with the Internet Service Manager. Remember that the URLs for your
  164.     virtual directories can't overlap with URLs to directories in the WWW root
  165.     directory. For example, You can't have a <i>cgi-bin</i> virtual directory
  166.     and a real <i>cgi-bin</i> subdirectory of the WWW root.</p>
  167.   </li>
  168.   <li>
  169.     <p>Ensure that your scripts are readable by the account used by the IIS
  170.     server. You set this account in Internet Service Manager; it is set to
  171.     IUSR_[your server name] by default. See also <a class="doc" href="ActivePerl-Winfaq4.html#What_is_a_Windows_NT2000_service_">What
  172.     is a Windows NT service?</a> and <a class="doc" href="ActivePerl-Winfaq4.html#How_do_I_set_permissions_on_a_fi">How
  173.     do I set permissions on a file?</a>.</p>
  174.   </li>
  175.   <li>
  176.     <p>Ensure that all supporting files, like the perl binary files, the perl
  177.     library files, and the modules that you use, are all readable by the account
  178.     used by the IIS server. See also <a class="doc" href="ActivePerl-Winfaq4.html#What_is_a_Windows_NT2000_service_">What
  179.     is a Windows NT service?</a> and <a class="doc" href="ActivePerl-Winfaq4.html#How_do_I_set_permissions_on_a_fi">How
  180.     do I set permissions on a file?</a>.</p>
  181.   </li>
  182. </ol>
  183. <p>You need to restart the web service after making the Registry changes or
  184. installing Perl.</p>
  185. <p>Because IIS runs as a service (see <a class="doc" href="ActivePerl-Winfaq4.html#What_is_a_Windows_NT2000_service_">What
  186. is a Windows NT service?</a>), you need to take special steps to make sure that
  187. files and environment variables are available to it.</p>
  188.  
  189. <h2><a name="How_do_I_configure_Microsoft_IIS">How do I configure Microsoft IIS
  190. 4.0/IIS 5.0 to support ActivePerl?</a></h2>
  191.  
  192. <p>Microsoft IIS 4.0 ships with Windows NT Server 5.0, and PWS 4.0 ships with Windows NT Workstation 5.0.
  193. Both IIS and PWS are available as part of the Microsoft Windows NT 4.0 Option Pack. You can find a link to the
  194. Option Pack at <a class="doc" href="http://www.microsoft.com/iis/">http://www.microsoft.com/iis/</a></p>
  195.  
  196. <p>Microsoft IIS 5.0 is not automatically installed on all Windows 2000 systems. Check your Windows 2000 
  197. documentation on
  198. how to install IIS 5.0.
  199.  
  200. <p>To configure IIS or PWS 4.0 to run Perl scripts:</p>
  201. <ol>
  202.   <li>
  203.     <p>Open the Internet Service Manager. This will bring up the
  204.     Microsoft Management Console with the Internet Service Manager snap-in
  205.     already selected.</p>
  206.   </li>
  207.   <li>
  208.     <p>From the tree display on the left, select the level at which to apply the
  209.     mappings. You can choose an entire server, web site, or a given virtual
  210.     directory.</p>
  211.   </li>
  212.   <li>
  213.     <p>Select Properties from the Action menu.</p>
  214.   </li>
  215.   <li>
  216.     <p>If you chose to administer the properties for the entire server, the
  217.     Server Properties dialog will appear. Select WWW Service from the Master
  218.     Properties pull-down menu and click the Edit button under Master Properties.
  219.     This opens WWW Service Master Properties. Select the Home Directory tab and
  220.     proceed to step 7.</p>
  221.   </li>
  222.   <li>
  223.     <p>If you chose to administer the properties for an entire web site, the Web
  224.     Site Properties sheet appears. Select the Home Directory tab and proceed to
  225.     step 7.</p>
  226.   </li>
  227.   <li>
  228.     <p>If you chose to administer the properties for a virtual directory, the
  229.     Virtual Directory Properties sheet appears. Select the Virtual Directory tab
  230.     and proceed to step 7.</p>
  231.   </li>
  232.   <li>
  233.     <p>Click the Configuration button. This opens the Application Configuration
  234.     dialog.</p>
  235.   </li>
  236.   <li>
  237.     <p>Select the App Mappings tab and click the Add button. You see the
  238.     Add/Edit Application Extension Mapping dialog.</p>
  239.   </li>
  240.   <li>
  241.     <p>To run Perl as a CGI application, type the full path to <i>Perl.exe</i>
  242.     followed by <code>%s %s</code>. When a script is executed, the first <code>%s</code>
  243.     will be replaced by the full path to the script, and the second <code>%s</code>
  244.     will be replaced by the script parameters.</p>
  245.   </li>
  246.   <li>
  247.     <p>To run Perl for ISAPI, type the full path to <i>PerlIS.dll</i>. The <code>%s
  248.     %s</code> is not required for ISAPI DLLs.</p>
  249.   </li>
  250.   <li>
  251.     <p>In the Extension field, type <i>.pl</i> or <i>.plx</i> (or whatever
  252.     extension you want to use).</p>
  253.   </li>
  254.   <li>
  255.     <p>The application mapping is now complete. Click the OK button and click OK
  256.     to dismiss any remaining dialogs/property sheets.</p>
  257.   </li>
  258.   <li>
  259.     <p>Close the IIS Internet Service Manager.</p>
  260.   </li>
  261. </ol>
  262. <p>Because IIS runs as a service (see <a class="doc" href="ActivePerl-Winfaq4.html#What_is_a_Windows_NT2000_service_">What
  263. is a Windows NT service?</a>), you need to take special steps to make sure that
  264. files and environment variables are available to it.</p>
  265.  
  266. <h2><a name="How_do_I_configure_iPlanet_web_">How do I configure iPlanet web
  267. servers to support ActivePerl?</a></h2>
  268. <p>To set up ActivePerl to run on FastTrack Server, follow these steps:</p>
  269. <ol>
  270.   <li>
  271.     <p>Install FastTrack Server, and make sure you can retrieve HTML pages.</p>
  272.   </li>
  273.   <li>
  274.     <p>Associate Perl scripts with the perl interpreter, if you haven't already.
  275.     See <a class="doc" href="ActivePerl-Winfaq4.html#How_do_I_associate_Perl_scripts_">How
  276.     do I associate Perl scripts with perl?</a> for how to do this. Re-start the server after making the association.</p>
  277.   </li>
  278.   <li>
  279.     <p>Set up a Shell CGI directory to run Perl scripts. A regular CGI directory
  280.     will not work -- that is only for executable files. You set this up with the
  281.     FastTrack Administrator; see the documentation for details.</p>
  282.   </li>
  283. </ol>
  284. <p>If you would like to access Perl CGI scripts in other directories, you need
  285. to associate an extension, such as <i>.pl</i>, with the shellcgi MIME type.
  286. Before you follow these steps, you must add at least one Shell CGI directory -
  287. this will enable shellcgi on your server (you can delete this directory, and
  288. shellcgi will remain enabled). Follow these steps to associate <i>.pl</i> with
  289. the shellcgi MIME type:</p>
  290. <ol>
  291.   <li>
  292.     <p>In the Server Administrator, click Server Preferences, then select MIME
  293.     Types from the frame on the left.</p>
  294.   </li>
  295.   <li>
  296.     <p>If you want to use <i>.pl</i> as the extension for Perl scripts, find
  297.     and remove the application/x-perl MIME type (this is mapped to <i>.pl</i>
  298.     by default).</p>
  299.   </li>
  300.   <li>
  301.     <p>Add a new MIME Type with magnus-internal/shellcgi as the Content Type,
  302.     and pl as the File Suffix. If a type for magnus-internal/shellcgi already
  303.     exists, simply add pl to the list of File Suffixes. Don't include the
  304.     leading dot on the file suffix.</p>
  305.   </li>
  306.   <li>
  307.     <p>Save and apply these changes, then re-start the server. You should be able to put a Perl CGI script
  308.     in any directory, provided the script ends with the <i>.pl</i> suffix.</p>
  309.   </li>
  310. </ol>
  311. <p>If you are having trouble running Perl scripts on your iPlanet server, check
  312. the following:</p>
  313. <ul>
  314.   <li>
  315.     <p>Ensure that the script is readable by the account used by the iPlanet
  316.     service. Generally, this means you should make the script readable by the
  317.     Everyone group.</p>
  318.   </li>
  319.   <li>
  320.     <p>Ensure that all supporting files, like the perl binary files, the perl
  321.     library files, and the modules that you use, are all readable by the account
  322.     used by the iPlanet service (i.e., the Everyone group).</p>
  323.   </li>
  324. </ul>
  325. <p>One nice thing about FastTrack server is that the Error Log will give
  326. detailed reasons why your CGI script isn't running, so this is a good thing to
  327. check first when you are having configuration problems.</p>
  328. <p>Because iPlanet servers run as services (see <a class="doc" href="ActivePerl-Winfaq4.html#What_is_a_Windows_NT2000_service_">What
  329. is a Windows NT service?</a>), you need to take special steps to make sure that
  330. files and environment variables are available to them.</p>
  331. <p>Some people have reported problems with handling POST'ed data with Perl
  332. programs with iPlanet servers. Since iPlanet apparently uses associations to
  333. run scripts, and POST'ed data is sent on STDIN to a program. This may be related
  334. to the problems with redirection.</p>
  335.  
  336. <!-- <h2><a name="How_do_I_configure_WebSite_1_0_t">How do I configure WebSite 1.0 to
  337. support ActivePerl?</a></h2>
  338. <p>The following information is for setting up O'Reilly WebSite to use
  339. ActivePerl for standard CGI (not PerlIS).</p>
  340. <ol>
  341.   <li>
  342.     <p>Install WebSite. Make sure you can retrieve HTML pages before continuing.</p>
  343.   </li>
  344.   <li>
  345.     <p>Associate Perl scripts with the perl interpreter, if you haven't already.
  346.     See <a class="doc" href="ActivePerl-Winfaq4.html#How_do_I_associate_Perl_scripts_">How
  347.     do I associate Perl scripts with perl?</a> for how to do this. You may need
  348.     to re-start the server after making the association.</p>
  349.   </li>
  350.   <li>
  351.     <p>Set up a Standard CGI directory to hold your Perl scripts. You can use
  352.     the Server Properties dialog box do to this.</p>
  353.   </li>
  354.   <li>
  355.     <p>Ensure that the script is readable by the account used by the WebSite
  356.     service. Generally, this means you should make the script readable by the
  357.     Everyone group.</p>
  358.   </li>
  359.   <li>
  360.     <p>Ensure that all supporting files, like the perl binary files, the perl
  361.     library files, and the modules that you use, are all readable by the account
  362.     used by the WebSite service (i.e., the Everyone group).</p>
  363.   </li>
  364. </ol>
  365. <p>Because WebSite servers run as services (see <a class="doc" href="ActivePerl-Winfaq4.html#What_is_a_Windows_NT_service_">What
  366. is a Windows NT service?</a>), you need to take special steps to make sure that
  367. files and environment variables are available to them.</p>
  368.  
  369. <h2><a name="How_do_I_configure_WebSite_Profe">How do I configure WebSite
  370. Professional to support ActivePerl?</a></h2>
  371. <p>The following information is for setting up O'Reilly WebSite Professional to
  372. use ActivePerl CGI (not PerlIS).</p>
  373. <ol>
  374.   <li>
  375.     <p>Install WebSite Professional. Make sure you can retrieve HTML pages
  376.     before continuing.</p>
  377.   </li>
  378.   <li>
  379.     <p>Open Server Properties and click the Mapping tab. Server Properties is in
  380.     the WebSite Professional folder on the Start menu.</p>
  381.   </li>
  382.   <li>
  383.     <p>From the List Selector on the Mapping tab, choose Content Types.</p>
  384.   </li>
  385.   <li>
  386.     <p>If there is an existing mapping for the extension you want to use (such
  387.     as <i>.pl</i>), highlight the mapping and click Delete. Click Apply to
  388.     immediately apply the change.</p>
  389.   </li>
  390.   <li>
  391.     <p>Choose a file extension for Perl, such as <i>.pl</i>, and type it into
  392.     the File Extension field. Make sure you include the leading period/full stop
  393.     (.) in the file extension.</p>
  394.   </li>
  395.   <li>
  396.     <p>Type wwwserver/shellcgi in the Media or Server-Side Content Type field.</p>
  397.   </li>
  398.   <li>
  399.     <p>Click Add. Click Apply to immediately apply the change.</p>
  400.   </li>
  401.   <li>
  402.     <p>Change the List Selector to Associations.</p>
  403.   </li>
  404.   <li>
  405.     <p>If there is an existing mapping for the extension you want to use (such
  406.     as <i>.pl</i>), highlight the mapping and click Delete. Click Apply to
  407.     immediately apply the change.</p>
  408.   </li>
  409.   <li>
  410.     <p>Type the file extension you chose in step 5 in the File Extension field.
  411.     Make sure you include the leading period/full stop (.) in the file
  412.     extension.</p>
  413.   </li>
  414.   <li>
  415.     <p>Type the full path to Perl.exe, such as <i>C:\Perl\5.00500\bin\MSWin32-x86\Perl.exe</i>,
  416.     in the Associated EXE or DLL field.</p>
  417.   </li>
  418.   <li>
  419.     <p>Click Add. Click Apply to immediately apply the change.</p>
  420.   </li>
  421.   <li>
  422.     <p>Close Server Properties. Reply appropriately to ``Terminate active
  423.     connections and update the server settings?''. The server is now configured
  424.     to execute Perl CGI scripts in directories marked as cgi-bin as well as
  425.     document directories.</p>
  426.   </li>
  427. </ol>
  428. <p>If you have trouble running scripts, ensure that the script is readable by
  429. the account used by the WebSite service. Generally, this means you should make
  430. the script readable by the Everyone group. Also, ensure that all supporting
  431. files, like the perl binary files, the perl library files, and the modules that
  432. you use, are all readable by the account used by the WebSite service (i.e., the
  433. Everyone group).</p>
  434. <p>Because WebSite servers run as services (see <a class="doc" href="ActivePerl-Winfaq4.html#What_is_a_Windows_NT_service_">What
  435. is a Windows NT service?</a>), you need to take special steps to make sure that
  436. files and environment variables are available to them.</p>
  437.  -->
  438.  
  439. <h2><a name="How_do_I_configure_Microsoft_Per">How do I configure Microsoft
  440. Personal Web Server 1.0x for Windows 95 to support ActivePerl?</a></h2>
  441. <p>Microsoft Personal Web Server for Windows 95 is a scaled-down version of
  442. Microsoft Internet Information Server. Although it is not documented, it appears
  443. that the method used to support ActivePerl with IIS will also work with Personal
  444. Web Server. See <a class="doc" href="#How_do_I_configure_IIS_3_0_or_lo">How do I configure
  445. IIS 3.0 or lower to support ActivePerl?</a>.</p>
  446.  
  447. <h2><a name="How_do_I_configure_other_web_ser">How do I configure other web
  448. servers to support ActivePerl?</a></h2>
  449. <p>If your web server isn't listed, check the server's documentation on how to
  450. set up a CGI interpreter. In general the process is as follows:</p>
  451. <ul>
  452.   <li>
  453.     <p>Associate a file extension like <i>.pl</i> with the perl binary, and
  454.     let the server know where the binary is. This may be a shell association,
  455.     (see <a class="doc" href="ActivePerl-Winfaq4.html#How_do_I_associate_Perl_scripts_">How
  456.     do I associate Perl scripts with perl?</a>), or a custom association.</p>
  457.   </li>
  458.   <li>
  459.     <p>Set up a directory where executable scripts go, and put your Perl script
  460.     there.</p>
  461.   </li>
  462.   <li>
  463.     <p>Ensure that the user account that the web server uses can read the script
  464.     as well as any ancillary files (perl binary files, library files, modules,
  465.     etc.). This usually means making the files available to the Everyone group.</p>
  466.   </li>
  467. </ul>
  468. <p>Because most web servers run as services (see <a class="doc" href="#How_do_I_configure_IIS_3_0_or_lo">How
  469. do I configure IIS 3.0 or lower to support ActivePerl?</a>), you need to take
  470. special steps to make sure that files and environment variables are available to
  471. them.</p>
  472.  
  473. <h2><a name="My_program_runs_fine_from_the_co">My program runs fine from the
  474. command line, but bombs out when run as a CGI script.</a></h2>
  475. <p>Usually, this means one of two things: either you have misconfigured your
  476. system, or your script does not output the right stuff to be a CGI script.</p>
  477. <p>Before you do anything else, check this list:</p>
  478. <ul>
  479.   <li>
  480.     <p>Make sure you have correctly configured your server for <i>perl.exe</i>
  481.     or <i>PerlIS.dll</i>. This is often accomplished by mapping a specific
  482.     extension, such as <i>.pl</i> or <i>.plx</i>, to <i>perl.exe</i> or <i>
  483.     PerlIS.dll</i>.
  484.     Usually, web servers rely on their own mappings, rather than the Windows
  485.     command-line mappings.</p>
  486.   </li>
  487.   <li>
  488.     <p>If your web server depends on the <code>PATH</code> variable to find <i>perl.exe</i>,
  489.     make sure that you put <i>perl.exe</i> in your system <code>PATH</code>,
  490.     not just your user <code>PATH</code>. This only applies to Windows NT/2000.</p>
  491.   </li>
  492.   <li>
  493.     <p>If your web server requires directories to be marked as executable, make
  494.     sure the directory that contains the script is marked as such.</p>
  495.   </li>
  496.   <li>
  497.     <p>Since the web server can be configured to run as a local user, be sure
  498.     that the user has access to the script file and the Perl binaries and
  499.     libraries. Many web servers run as the ``Local System'' account, which
  500.     generally has sufficient permissions.</p>
  501.   </li>
  502.   <li>
  503.     <p>If <i>Perl.exe</i> or Perl for ISAPI fail to work as expected check
  504.     your event logs for clues.</p>
  505.   </li>
  506. </ul>
  507. <p>Check the information above with a script that you know produces the right
  508. output for the CGI protocol (scripts in this FAQ are a good first choice). Try
  509. it with your own script after you're sure the test script will work.</p>
  510. <p>If you are sure the server is running the script, but it only generates error
  511. messages in your browser, there are some tools that may help you out. CGI::Carp
  512. is used to send debugging information to the browser or log file. Even if your
  513. script has a compilation error, it can usually intercept and report errors. To
  514. use CGI::Carp, include the following lines in your program:</p>
  515. <pre>
  516.     # The stuff in the BEGIN block will be executed very early
  517.     # on, even before the rest of this script is parsed.
  518.     #
  519.     BEGIN {
  520.         
  521.         # Use the CGI::Carp module and import the carpout() function.
  522.         #
  523.         use CGI::Carp qw(carpout);
  524.         
  525.         # Send warnings and die messages to the browser.
  526.         #
  527.         carpout(STDOUT);
  528.         
  529.     }
  530. </pre>
  531. <p>If your script has an error, you may see something like this in the browser:</p>
  532. <pre>
  533.     [Wed Jun 3 09:32:28 1998] C:\inetpub\scripts\test.pl: Error message! at
  534.     C:\inetpub\scripts\test.pl line 38. 
  535. </pre>
  536. <p>Sometimes, it can be helpful to put yourself in somebody else's position. The
  537. libwww-perl bundle (LWP) is available from CPAN, but you can install it using
  538. the Perl Package Manager (PPM). LWP may be included with future releases of
  539. ActivePerl.</p>
  540. <p>LWP includes the powerful <i>lwp-request</i> script, which lets you see
  541. things from the browser's perspective. Invoke <i>lwp-request</i> with the name
  542. of a URL to see the content of the response, as in <code>lwp-request
  543. http://localhost</code>. To inspect the headers of an HTTP response, invoke <i>lwp-request</i>
  544. with the <code>-de</code> switch:</p>
  545. <pre>
  546.     C:\>lwp-request -de http://localhost
  547.     Date: Wed, 03 Jun 1998 13:37:31 GMT
  548.     Accept-Ranges: bytes
  549.     Server: Microsoft-IIS/4.0
  550.     Content-Length: 4325
  551.     Content-Location: http://localhost/Default.htm
  552.     Content-Type: text/html
  553.     ETag: "0c1e58b063bd1:1237"
  554.     Last-Modified: Thu, 09 Apr 1998 12:09:28 GMT
  555.     Client-Date: Wed, 03 Jun 1998 13:37:31 GMT
  556.     Client-Peer: 127.0.0.1:0
  557. </pre>
  558. <p>This tool can be very helpful in figuring out exactly what your scripts are
  559. doing. Whatever you do, don't give up hope. It is, in fact, possible to get a
  560. Perl script running on your web server. Really.</p>
  561.  
  562. <h2><a name="This_is_all_such_a_hassle_why_c">This is all such a hassle; why
  563. can't I just put perl.exe in my CGI directory and use it in my URL?</a></h2>
  564. <p>First, the warning: DON'T DO THIS. REALLY. EVEN IF YOU DON'T UNDERSTAND WHY
  565. NOT, DON'T.</p>
  566. <p>Now the explanation: the idea here is to put <i>perl.exe</i> in your CGI
  567. directory (however you configure that on your server), and use URL syntax like
  568. the following:</p>
  569. <pre>
  570.     http://soon.to.be.a.victim.net/cgi-bin/perl.exe?myscript.pl
  571. </pre>
  572. <p>to run <i>myscript.pl</i>. This keeps you from having to figure out how to
  573. configure your server to associate extensions like <i>.pl</i> with an
  574. interpreter like <i>perl.exe</i>.</p>
  575. <p>In fact, on some early Win32-based web servers (iPlanet 1.x servers in
  576. particular), it was impossible to associate a script file with an interpreter.
  577. This method was recommended by vendors as a viable approach to running Perl
  578. scripts on your web server.</p>
  579. <p>Anyone with a devious mind and a little knowledge of Perl can see that with
  580. this configuration, hackers could start doing all kinds of horrible things on
  581. the server. All they'd have to do is send made-up URLs, using the <code>-e</code>
  582. command line switch in <i>perl.exe</i>, in order to do stuff like delete all
  583. files on a drive:</p>
  584. <pre>
  585.     http://aaaugh.that.hurts.net/cgi-bin/perl.exe?-e?'del%20c:\*.*%20/S%20/Q'
  586. </pre>
  587. <p>Of course, a true computer criminal would never do something so crude and
  588. obvious, but would instead use this as a launching point to cause irreparable
  589. harm to your organization.</p>
  590. <p>The following URL covers this issue in more depth:</p>
  591. <pre>
  592.     <a class="doc" href="http://www.cert.org/advisories/CA-1996-11.html">http://www.cert.org/advisories/CA-1996-11.html</a>
  593. </pre>
  594. <p>Tom Christiansen has also written a good discussion of the subject:</p>
  595. <pre>
  596.     <a class="doc" href="http://www.perl.com/perl/news/latro-announce.html">http://www.perl.com/perl/news/latro-announce.html</a>
  597. </pre>
  598. <p>Note that one suggested solution to this problem is wrapping your Perl script
  599. in a batch file using pl2bat or your own custom batch code. THIS IS ALSO NOT
  600. GOOD. Most of the primitive servers that won't allow file associations are also
  601. susceptible to a bug that allows a user to enter any DOS command after the bat
  602. file. </p>
  603.  
  604. <h2><a name="AUTHOR_AND_COPYRIGHT">AUTHOR AND COPYRIGHT</a></h2>
  605. <p>This FAQ was originally assembled and maintained by Evangelo Prodromou.
  606. It has been revised and updated by Brian Jepson of O'Reilly and Associates, and
  607. David Grove and David Dmytryshyn of ActiveState.</p>
  608. <p>This FAQ is in the public domain. If you use it, however, please ensure that
  609. you give credit to the original authors.</p>
  610. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  611.   <tr>
  612.     <td class="block" valign="MIDDLE" width="100%" bgcolor="#cccccc"><h3>
  613.       <p class="block"> ActivePerl FAQ - Web Server Information</p>
  614.       </h3></td>
  615.   </tr>
  616. </table>
  617.  
  618. </body>
  619.  
  620. </html>
  621.