Installing Perl and Perl Modules

Installing Perl and Perl Modules

APPENDIX D INSTALLING PERL AND PERL MODULES D.1 Installing Perl on UNIX/Linux Systems Perl typically comes already installed on UNIX-type operating systems (UNIX, Linux, Solaris, MacOS X). One important piece of information is the location of the Perl interpreter, because we need that on the first line of our Perl scripts. In UNIX, you can use the following UNIX command which perl to determine the path to Perl. If Perl is not already installed, or if a newer version is desired, go to www.perl.org to find the latest version. You need to make sure your Web server software allows execution of scripts. Sometimes CGI execution for files ending in .cgi is already turned on in Apache; you can easily test this with a test script such as hello.cgi. If it turns out that CGI execution is not enabled, then you need to enable it. If you can use a system admin GUI, that would be the easiest. For example, you can start up the Apache Configuration program on a Red Hat Linux server console, as shown in Figure D.1, and navigate to the menus that control CGI execution. Figure D.1 Red Hat Linux Apache Configuration program. For Apache you can also manually edit the configuration file httpd.conf. The following directive, AddHandler cgi-script cgi pl tells the server to treat all files with the .cgi or .pl extension as CGI programs. Warning: if you use the Linux GUI to configure Apache, then you should not mess with the httpd.conf file manually. © 2005 John Wiley & Sons, Inc 791 792 APPENDIX D INSTALLING PERL AND PERL MODULES D.2 Installing Perl on Windows Systems Web Server Software First, make sure a Web server is already installed. In most modern cases, IIS should be installed. For a server, IIS would be installed. For a personal (nonserver) computer, you will need to install IIS or PWS, depending on which Windows operating system you are running. For Windows 2000 or XP, you will need to install IIS; you might need at least the "Professional" edition of these Windows operating systems. For the older Windows 95, 98, or NT you will probably want to install PWS (Personal Web Server). See Microsoft's Web site, www.microsoft.com, for exact requirements to run the appropriate Web server software (IIS or PWS) on a personal computer. On a personal computer, to install PWS on Windows 98 or NT, you will need either the operating system installation CD, such as Windows NT or Windows 98 Second Edition or later; or you can go to Microsoft's Web site and download the PWS installer. Once you have the installer, the installation of PWS is straightforward. Just follow the installation wizard. The default home directory is usually \Inetpub\wwwroot\. On a personal computer, to install IIS on Windows 2000 or XP, assuming you have the required edition operating system (or else it would not have the functionality to run Web services), just run the installation from the CD. Installing Active State Perl on Windows Because the language Perl continues to be improved, the Web site that holds the Perl downloads will also evolve. The instructions here do not have ultraspecific links, because such links will likely change over time. Note that any screen shots and menus might vary depending on your specific operating system and the current version of the Perl installer. Here are the overall steps. 1. Go to www.perl.org. 2. Look for the link to Perl for Win32/NT and click on it. This takes you to www.activestate.com (to which you could also go directly). 3. Clink on the link to download the latest version of ActivePerl. You should get a window resembling the screenshot in Figure D.2. (Disclaimer: The look of any Web site may change over time of course!) Figure D.2 Downloading ActivePerl. 4. (Step 1 of download) Verify requirements: Make sure that your system satisfies the requirements listed on the Web page. For example, for Windows 95, 98, or ME you might need the Windows 2.0 installer. Note that this does not yet download the actual ActivePerl installer; that is done in the next step. This step only downloads a program to update your installation software. It is possible that you may not need to download anything from this page. Then proceed to the next download page by clicking on "Next" near the bottom of this Web page (or possibly by some other means). © 2005 John Wiley & Sons, Inc D.2 INSTALLING PERL ON WINDOWS SYSTEMS 793 5. (Step 2 of download) Download the ActivePerl installer: Choose the appropriate version of ActivePerl. Read the instructions and pick the best version for your operating system. At the time this book was written, that version for Windows is MSI. Click the link. The ActivePerl installer will be downloaded to your hard drive; save it somewhere appropriate. 6. Run the ActivePerl installer (with some file name ending in .exe) from where you saved it (during Step 2 of download). You will be guided through a series of menus. In most cases, you will simply click Next. 7. Here are some notes on what you might encounter in these menus. On the first screen, you will first have to choose "Yes, I agree …" to accept the licensing agreement. On one of the screens, be sure to choose the option to save the ppm settings (this is the default choice). The ppm is the Perl Package Manager, which will be extremely useful when you want to install Perl packages (see Section D.4). Notice that one of the screens says that it will "Create script mapping for Perl". This is what enables a file that ends in .pl to be executed as a program by the Perl interpreter! (This answers the question of how the Web server knows that it should execute the .pl file as a Perl program.) The script mapping registry is also what needs to be modified if you want files ending in .cgi to be executed as Perl programs when called through the Web. The script mapping registry is different from the file association registry, which registers what program should open a file when the file icon is double- clicked. Note that the default will be that file extensions need to be .pl. 8. Write and put a short Perl program, say hello.pl, in the Web document tree (for example, in \Inetpub\wwwroot\hello.pl). Open a browser and access the URL //localhost/hello.pl. If you get the result of the Perl script (as opposed to the source text file), then apparently everything works, and you are done. 9. This following step is necessary only if your Perl test program did not work. If you get an “insufficient permission” error message, then you may need to enable executables in the Web server. • For IIS: • Open the IIS manager program as shown in Figure D.3 (usually found in Programs →Administrative Tools). Figure D.3 CGI permissions on IIS. • Find the "Default Web site" object in the tree, and right-click on it, selecting Properties. This brings up a large menu. Or, if you wish to give CGI execution permission only to specific subdirectories, then you should instead click on a subfolder of the "Web site" object. • Select Home Directory or Directory. • There are many items you can configure here. Under Execute Permissions, select Scripts and Executables. Click OK. • For PWS: • Open up the PWS manager (usually found under Programs → Accessories → Internet Tools), © 2005 John Wiley & Sons, Inc 794 APPENDIX D INSTALLING PERL AND PERL MODULES • Click on Advanced. • Highlight either the Home directory or a subfolder, and click on Edit Properties. • In the pop-up window, be sure "Execute" is checked in addition to "Read" and "Scripts". Click OK. 10. This following step is necessary only if your Perl test program did not work. If you get the source file returned, then the source was never executed as a Perl program. This is because the script mapping never occurred. (This is a common problem if ActivePerl is installed before the installation of PWS, or if an older version of PWS is installed.) You will have to edit the script mapping registry manually. • For IIS: • Open the IIS manager program (usually found in Programs → Administrative Tools). • Find the "Web site" object in the tree, and right-click on it, selecting Properties. This brings up a large menu. • Select Home Directory. • Click on Configuration…. • Click on Add. Figure D.4 Extension Mapping on IIS. • Edit as depicted in Figure D.4, using the appropriate location of the Perl interpreter. • For PWS: • You will need to run the regedit program. You can run this manually by going to the Windows menu Start → Run and typing the regedit command. • Navigate (by double clicking) HKEY_LOCAL_MACHINE → System → CurrentControlSet → Services → W3SVC → Parameters → Script Map. • Select menu option: Edit → New → String Value. Figure D.5 Using the Registry Editor. • Edit the new entry as depicted in Figure D.5, using the path to the Perl interpreter in the Data. © 2005 John Wiley & Sons, Inc D.4 EASY INSTALLATION OF PERL MODULES ON WINDOWS AND UNIX/LINUX 795 The default configuration of ActivePerl is that you will need a .pl extension for a source file to be executed as a Perl program. If you desire the .cgi extension, you can edit the registry as outlined in step 10 of the foregoing list, with .cgi instead of .pl. You can also make both entries! To make a directory accessible from the Web, right-click on the folder and select Properties.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us