Difference between revisions of "Setup Perl and Apache"

From MidrangeWiki
Jump to: navigation, search
m (Configure Apache)
(+wikilink to 5799-PTL)
 
Line 1: Line 1:
 
[[Category:Configuration FAQ]]
 
[[Category:Configuration FAQ]]
 
[[Category:Perl]]
 
[[Category:Perl]]
 +
 +
There are two versions of Perl available for IBM i.  The documentation here describes an old CPAN port of Perl.  There is a newer version available as part of PRPQ [[5799-PTL]].
 +
 +
==CPAN Perl for IBM i==
 +
 
All iSeries steps are performed with a user that has [[*SECOFR]] authority.
 
All iSeries steps are performed with a user that has [[*SECOFR]] authority.
  

Latest revision as of 16:22, 15 February 2011


There are two versions of Perl available for IBM i. The documentation here describes an old CPAN port of Perl. There is a newer version available as part of PRPQ 5799-PTL.

CPAN Perl for IBM i

All iSeries steps are performed with a user that has *SECOFR authority.

This was done on V5R2 with all the latest PTFs as of 1/2004.

1. Download the Perl 5.8.0 iSeries PASE binaries from CPAN website at http://www.cpan.org/ports/os400/

2. Uncompress the zipped tarball. (I used Winzip for Windows and it produced perlpkg/perl-5.8.0@18380-os400.tgz)

3. Create the folder perlpkg in the QOpenSys file system. Remember that in QOpenSys file names are case sensitive.

4. Copy the uncompressed tarball to the new folder. (I used iSeries Navigator to create the folder and copy the uncompressed tarball but FTP will work if you use binary mode)

5. Start a PASE terminal session by entering CALL QP2TERM in your 5250 terminal session

6. Enter command: cd /QOpenSys

8. Enter command: tar -xvf perlpkg/perl-5.8.0@18380-os400.tgz (this will install Perl in /QOpenSys/perl)

9. Enter command: ln -fs /QOpenSys/perl/bin/* /QOpenSys/usr/bin (This will create symbolic links to the Perl binaries in the /QOpenSys/usr/bin folder which is part of the standard PATH environment variable.)

10. If you want to see what your PATH environment variable contains enter the command: env PATH

11. To make sure Perl installed correctly enter command: perl -v

 The command should return:
 This is perl, v5.8.0 built for aix
 (with 1 registered patch, see perl -V for more detail)
 Copyright 1987-2002, Larry Wall
 etc... 

Configure Apache

7. If the *ADMIN instance isn't started enter the command: STRTCPSVR *HTTP *ADMIN

8. In a browser enter: http://yourserver:2001

9. Provide an iSeries profile and password that has *SECOFR security.

10. Select IBM HTTP Server for iSeries

11. Set the Server to your Apache server instance.

12. Set Server area: "Global Configuration"

13. Left hand Menu item: "URL Mapping"

14. Tab: "Aliases"

15. Add a "Script Alias" with "URL path" of "/perl-bin/"

16. and Host Directory "/QOpenSys/perl/webwrap/"

17. Left hand Menu: "Container Management"

18. Tab: "Directories"

19. Add a directory "/QOpenSys/perl/webwrap"

20. Left hand Menu: "Content Settings"

21. Tab: "Mime"

22. Add a "File extension" of ".pl"

23. with "Action" of "Add"

24. and "Type" of "Content-Type"

25. and "Value" of "application/x-httpd-perl"

26. Left hand Menu: "Request Processing"

27. Tab: "Handlers"

28. Section: :Automatically run CGI programs for MIME-types:"

29. Add a "CGI program" of "/perl-bin/paseweb"

30. and "MIME-type or handler" of "application/x-httpd-perl"

31. Server area: "/QOpenSys/perl/webwrap"

32. Left hand Menu: "Dynamic Content and CGI"

33. Tab: "General Settings"

34. Set "Allow CGI programs to be run" to "enabled"

35. Left hand Menu: "Security"

36. Tab: "Control Access"

37. Set "Order for evaluating access" to "Allow then Deny"

38. Check "Allow access to all, except the following:"

39. Restart the server


Steps 8 - 39 will add the following to httpd.conf

***************
    ScriptAlias /perl-bin/ /QOpenSys/perl/webwrap/
    AddType application/x-httpd-perl .pl
    Action application/x-httpd-perl /perl-bin/paseweb
    <Directory /QOpenSys/perl/webwrap>
    Options +ExecCGI
    order allow,deny
    allow from all
    </Directory>
***************

40. Create a folder "webwrap" under "/QOpenSys/perl"

41. Enter command: CHGAUT '/QOpenSys/perl/webwrap' QTMHHTTP *RX

42. Enter command: CHGAUT '/QOpenSys/perl/webwrap' QTMHHTP1 *RX

43. In "/QOpenSys/perl/webwrap" create a file "paseweb.tmp" that contains:

       #!/QOpenSys/perl/bin/perl
       exec $ENV{PATH_TRANSLATED};
       print "Content-Type: text/html;\r\n\r\n";
       print "Error running CGI";
**************
The last two print lines would print only if the exec() failed for some
reason, like if you requested /asdfj.pl and it didn't exist. The paseweb
could actually be a more complex program that does logging and some
security checks, but this simple one should work. -- Byran Logan
***************

44. Start a PASE terminal session by entering CALL QP2TERM in your 5250 terminal session

45. Enter command: cd /QOpenSys/perl/webwrap

46. Enter command: tr -d '\015' < paseweb.tmp > paseweb

***************
    This converts the end of lines to a single carriage return.
    If you use the EDTF command it should not be needed and you can directly
    create paseweb.
    This needs to be done on all perl scripts as advised by Bryan Logan.
***************

47. Exit the PASE session.

48. Enter command: CHGAUT '/QOpenSys/perl/webwrap/paseweb' QTMHHTTP *RX

49. Enter command: CHGAUT '/QOpenSys/perl/webwrap/paseweb' QTMHHTP1 *RX

50. Enter command: CHGAUT '/tmp' QTMHHTTP *RWX

51. Enter command: CHGAUT '/tmp' QTMHHTP1 *RWX

52. I also used the IBM IFS TOOLS "call chgautall" to grant QTMHHTP1 *RX to everything in /QOpenSys/perl. I downloaded them from ftp://testcase.boulder.ibm.com/as400/fromibm/ApiSamples/ifstool.savf.

With this setup I used #!/usr/bin/perl as the first line of the scripts to set the proper path.

I found that the default folder for file operations varies by OS/Server and that for OS/400 you need to specify fully qualified file names. When I tried the unicounter.pl script it failed because it used the default path and wherever that was it couldn't write the file.

The folder that contains your scripts and the script files also need to have QTMHHTTP and QTMHHTP1 authorized with *RX permissions.

The user profile QTMHHTTP is the normal profile that the APACHE server runs under.

The user profile QTMHHTP1 is the normal profile that the APACHE server runs CGI programs under.

Getting and installing Perl was mostly from "PHP on IBM iSeries" by Rob Ward at http://www.mcind.com/php/

Configuring Apache was mostly from Byran Logan of IBM.