You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Harry Wykes <ha...@enduser.co.uk> on 1998/09/30 10:43:33 UTC

os-windows/3104: Making PERL work with Apache on Win32 systems

>Number:         3104
>Category:       os-windows
>Synopsis:       Making PERL work with Apache on Win32 systems
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          support
>Submitter-Id:   apache
>Arrival-Date:   Wed Sep 30 01:50:00 PDT 1998
>Last-Modified:
>Originator:     harry@enduser.co.uk
>Organization:
apache
>Release:        1.3.1, 1.3.2
>Environment:
Windows NT 4/ Windows 95
>Description:
This describes how to install PERL so that it will work with Apache 
on Windows platforms.

It has been tested on Windows NT and Windows 95.
>How-To-Repeat:

>Fix:
These instructions assume that you have successfully installed Apache and have accessed the It Worked! Page. 

   1.Install your favourite version of PERL for Win32. Add the location of the PERL 'bin' directory to your Win95/WinNT
     PATH. Make sure PERL works from the command line prompt by running a small "Hello World" script or by invoking
     PERL with the -v parameter to display the version number. 

   2.Unlike IIS, Apache uses the hash-bang (#!) at the top of your PERL script to locate the PERL binary executable.
     Unless you want to be forever changing the hash-bang, whenever you upload a script to Unix, you should copy the
     PERL binary executable (perl.exe) to an appropriately named directory path, to mirror the location of the PERL
     executable on your favourite Unix box(es). For example I have created a directory \usr\bin and have copied perl.exe
     from my PERL 'bin' directory to \usr\bin. The hash-bang at the top of my PERL scripts is 

     #!/usr/bin/perl 

   3.If you have installed Apache into the default directory, it will reside in the directory
     \Program Files\Apache Group\Apache on whichever drive you selected. This causes a problem for PERL, because
     the path to the script directory \Program Files\Apache Group\Apache\cgi-bin contains not just one, but 2 spaces.
     When Apache invokes your script, the path to the script directory is prepended to the script name. If your script name
     is fred.pl, then this is what will be passed to the command processor by Apache:- 

       \usr\bin\perl \Program Files\Apache Group\Apache\cgi-bin\fred.pl 

     Look carefully, instead of the name of your script being passed as the first argument to PERL, three arguments are
     passed:- 

     \Program 
     Files\Apache 
     Group\Apache\cgi-bin\fred.pl  

     Not exactly what is intended, or required. 

     The best solution is to create a subdirectory of the root directory of an appropriate drive, called for example wwwroot,
     or if you want to mirror the Unix world more closely, you can mimic the directory structure of your favourite Unix box,
     eg., /export/home/fredbloggs. Create two directories within the new directory, one for your html documents and one
     for your cgi scripts. You might want to use the same names that Apache uses, eg., htdocs and cgi-bin. Place your html
     documents in the htdocs directory. In the cgi-bin directory create a simple "Hello World" CGI script, called hello.pl,
     containing the following 2 lines:- 

     #!/usr/bin/perl
     print "Content-type: text/plain\n\nHello World!\n"; 

   4.Having moved the location of the two directories, it is necessary to inform Apache of the change, by changing the
     ScriptAlias and DocumentRoot settings in the srm.conf file in the Apache conf directory and any Directory settings
     in access.conf which reference the old path to the cgi-bin or htdocs directories.

Now start (or re-start) Apache and enter the URL 

http://127.0.0.1/cgi-bin/hello.pl 

If you see the "Hello World" message you are laughing and scratching. If not stop Apache and check the error.log file in the
Apache logs directory. 

  
>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, ]
[you need to include <ap...@Apache.Org> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]
[If you do not include this Cc, your reply may be ig-   ]
[nored unless you are responding to an explicit request ]
[from a developer.                                      ]
[Reply only with text; DO NOT SEND ATTACHMENTS!         ]