cleancut-fluent

(Answer) (Category) iSeries / AS400 FAQ : (Category) Operations : (Category) Configuration :
Setup Perl and Apache to use it on iSeries
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.

Step 52 can be achieved by running the following:
QSH CMD('find /QOpenSys/perl/* -exec system "CHGAUT OBJ(''"{}"'') USER(QTMHHTP1) DTAAUT(*RX) OBJAUT(*OBJREF)" \;')
What is the function of 'paseweb' in directory /QOpenSys/perl/webwrap?
When trying to link to my "Hello World' webpage I get the following:
                   The page cannot be displayed.
The following appears in the joblog:
00 08/09/06 07:48:02.787792 QWTPIIPP QSYS 05D4 *EXT *N
  Message . . . . :   Job 904410/QTMHHTTP/QRYSERVER started on 08/09/06 at
    07:48:02 in subsystem QHTTPSVR in QHTTPSVR. Job entered system on 08/09/06
    at 07:48:02.
00 08/09/06 07:48:03.298032 QZSRCGI QHTTPSVR *STMT QZSRCGI QHTTPSVR *STM
  From module . . . . . . . . :   ZSRVHJOB
  From procedure  . . . . . . :   sendMessage
  Statement . . . . . . . . . :   3
  To module . . . . . . . . . :   ZSRVHJOB
  To procedure  . . . . . . . :   sendMessage
  Statement . . . . . . . . . :   3
  Message . . . . :   This is a CGI job for IBM HTTP Server instance QRYSERVER.
  Technical description . . . . . . . . :   All Common Gateway Interface (CGI)
    programs for the IBM HTTP Server run in separate jobs from the server job.
    This job is reused for other CGI programs.
30 08/09/06 07:48:04.416112 QP2USER QSYS *STMT QZSRCGI QHTTPSVR *STM
  From module . . . . . . . . :   QP2EXERR
  From procedure  . . . . . . :   sendmsg__FPCcN21e
  Statement . . . . . . . . . :   188
  To module . . . . . . . . . :   ZSRVCGI
  To procedure  . . . . . . . :   CGICall
  Statement . . . . . . . . . :   249
  Message . . . . :   Cannot load OS/400 PASE module
    /QOpenSys/perl/webwrap/paseweb.
  Cause . . . . . :   The stream file for OS/400 PASE module
    /QOpenSys/perl/webwrap/paseweb may not exist, or you may not have sufficient
    authority to load from it. You must have read authority to load an OS/400
    PASE shared object, or read and execute authority to load an OS/400 PASE
    program. The error occurred attempting to load OS/400 PASE program
    /QOpenSys/perl/webwrap/paseweb. Recovery  . . . :   Correct the error and
    then try the request again.

ans-ins-part
Append to This Answer
rv-lists, colin.williams, george.morey
Previous: (Answer) How to IPL with Client Access over a emulation Card.
Next: (Answer) Configure Network Printers using HPT so COR matches PC's Landscape Printing.
This document is: http://faq.midrange.com/index.pl?file=379
[Search] [Appearance]
This is a Faq-O-Matic 2.721.