PASECGI

Here is a more detailed version of PASE CGI setup (perl), it may help if you have trouble with the short version that follows.

=========================
setup your Apache web site
(ILE Apache to PASE sh)
=========================
To run when done:
http://myi5:89/sh-htdocs/helloworld.sh

Files when done:
> ls /QOpenSys/sh-bin/*
/QOpenSys/sh-bin/sh-cgi
/QOpenSys/sh-bin/sh-htdocs:
helloworld.sh
> 

bill of materials / programs (/QOpenSys/...):
1) /www/instance/conf/httpd.conf - ILE Apache configuration
2) /QOpenSys/sh-bin/sh-cgi - sh wrapper for sh cgi that will exec $PATH_TRANSLATED
3) /QOpenSys/sh-bin/sh-htdocs - directory for sh scripts
*) /QOpenSys/sh-bin/sh-htdocs/helloworld.sh - sample "hello world" sh script
4) /QOpenSys/usr/bin/sh - symbolic link to my sh installation

1) http.conf adds for sh-cgi (conf):
Trick: PASE stuff in PASE IFS directory (/QOpenSys not /www)
File: /www/instance/conf/httpd.conf
# sh cgi wrapper program
ScriptAlias /sh-bin/ /QOpenSys/sh-bin/
AddType application/x-httpd-sh .sh
Action application/x-httpd-sh /sh-bin/sh-cgi
<Directory /QOpenSys/sh-bin>
Options +ExecCGI
order allow,deny
allow from all
</Directory>
# sh applications (.sh)
Alias /sh-htdocs /QOpenSys/sh-bin/sh-htdocs
<Location /sh-htdocs>
Order deny,allow
Allow from all
</Location>

2) /QOpenSys/sh-bin/sh-cgi (wrapper):
Note: if ok exec will transfer to new program $PATH_TRANSLATED, 
so none of the "debug" CGI env will display.
File: /QOpenSys/sh-bin/sh-cgi
#!/QOpenSys/usr/bin/sh
exec $PATH_TRANSLATED
echo 'Content-Type: text/html'
echo ''
echo ''
echo '<html>'
echo ' <head>'
echo ' <title>View CGI Environment Variables</title>'
echo ' </head>'
echo ' <body bgcolor=white>'
echo ' <h1>'
echo $PATH_TRANSLATED
echo ' </h1>'
echo ' <h2><font face=helv color=cc9900>CGI Environment Variables</font></h2>'
echo ' <table cellpadding=3 cellspacing=0 border=1>'
echo '<tr><td><pre>'
env
echo '</pre></td></tr>'
echo ' </table>'
echo ' </body>'
echo '</html>'

3) sh scripts - /QOpenSys/sh-bin/sh-htdocs (applications/scripts):
Trick: PASE stuff in PASE IFS directory (/QOpenSys not /www)
File:  /QOpenSys/sh-bin/sh-htdocs/helloworld.sh
#!/QOpenSys/usr/bin/sh
echo "Content-Type: text/html;"
echo ""
echo ""
echo "Hello, world from sh!"
=========================
setup your Apache web site
(ILE Apache to perl)
=========================
To run when done:
http://myi5:89/perl-htdocs/helloworld.pl

Files when done:
> ls /QOpenSys/perl-bin/*
/QOpenSys/perl-bin/perl-cgi
/QOpenSys/perl-bin/perl-htdocs:
helloworld.pl
>

bill of materials / programs (/QOpenSys/...):
1) /www/instance/conf/httpd.conf - ILE Apache configuration
2) /QOpenSys/perl-bin/perl-cgi - perl wrapper for perl cgi that will exec $ENV{PATH_TRANSLATED};
3) /QOpenSys/perl-bin/perl-htdocs - directory for perl scripts
*) /QOpenSys/perl-bin/perl-htdocs/helloworld.pl - sample "hello world" perl script
4) /QOpenSys/usr/bin/perl - symbolic link to my perl installation directory

1) http.conf adds for perl-cgi (conf):
Trick: PASE stuff in PASE IFS directory (/QOpenSys not /www)
File: /www/instance/conf/httpd.conf
# perl cgi wrapper program
ScriptAlias /perl-bin/ /QOpenSys/perl-bin/
AddType application/x-httpd-perl .pl
Action application/x-httpd-perl /perl-bin/perl-cgi
<Directory /QOpenSys/perl-bin>
Options +ExecCGI
order allow,deny
allow from all
</Directory>
# perl applications (.pl)
Alias /perl-htdocs /QOpenSys/perl-bin/perl-htdocs
<Location /perl-htdocs>
Order deny,allow
Allow from all
</Location>

2) /QOpenSys/perl-bin/perl-cgi (wrapper):
Note: if ok exec will transfer to new program $ENV{PATH_TRANSLATED}, 
so none of the "debug" CGI env will display.
File: /QOpenSys/perl-bin/perl-cgi
#!/QOpenSys/usr/bin/perl
exec $ENV{PATH_TRANSLATED};
print "Content-Type: text/html;\r\n\r\n";
print "<html>\n";
print " <head>\n";
print " <title>View CGI Environment Variables</title>\n";
print " </head>\n";
print " <body bgcolor=white>\n";
print " <h1>$ENV{PATH_TRANSLATED}</h1>";
print " <h2><font face=helv color=cc9900>CGI Environment 
Variables</font></h2>\n";
print " <table cellpadding=3 cellspacing=0 border=1>\n";
foreach $key (sort(keys %ENV))
{
print " <tr><td align=right>$key:</td><td>&nbsp;$ENV{$key}</td></tr>\n";
}
print " </table>\n";
print " </body>\n";
print "</html>\n";
exit(0);

3) perl scripts - /QOpenSys/perl-bin/perl-htdocs (applications/scripts):
Trick: PASE stuff in PASE IFS directory (/QOpenSys not /www)
File: /QOpenSys/perl-bin/perl-htdocs/helloworld.pl:
#!/QOpenSys/usr/bin/perl
print "Content-Type: text/html;\r\n\r\n";
print "Hello, world!\n";

Author(s)

Tony “Ranger” Cairns - IBM i PHP / PASE