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