Products Resources Support About Us

Customization server apache and php (Z/os V2r2)

HI
I am working on a operating system Z/OS v2r2
Http server is installed and is correct on my lpar.

/etc/webap1/bin/apachectl -v

Server
version: IBM_HTTP_Server/9.0.0.0-PI54808 (Unix) Server
built: Jan 20 2016 17:19:40

Php is the tool of Rocket and is installed in :
/PRODUITS/ROCK/php
EUID=0
/PRODUITS/ROCK/php/
Type Filename
_,Dir
,.
_,Dir
,…
_,Dir ,bin
_,Syml ,CHANGES.ZOS
_,File ,fichier.php544.tar
_,Dir ,include
_,Dir ,lib
_,Dir ,man
_,File ,README
_,Syml ,README.ZOS
_,Dir ,share
_,Syml ,VERSION.ZOS

/PRODUITS/ROCK/php/bin/php -v
PHP 5.4.4 (cli) (built: Nov 21 2016 03:25:49)
Copyright © 1997-2012 The PHP Group
Zend Engine v2.4.0,
Copyright © 1998-2012 Zend Technologies

I made the export in the .profile of the user of the stc. (start server Apache)

export PATH=$PATH:/PRODUITS/ROCK/php/bin
export MANPATH=$MANPATH:/PRODUITS/ROCK/php/man/

When I want to see my page html, the command (php) are not interpreted.

Html page :

Standard HTML Page with PHP HelloWorld <?PHP print "Hello World"; print "
Generated with PHP"; ?>

Browser result :

Generated with PHP"; ?>.

I am looking for a installation guide and customization : Apache server z/OS and php ?
Can you help me ?
Best regards

Hi

The common configuration:
/path/to/php/ - the path at PHP directory
Change this path below on your.

Add the following lines to httpd.conf:

ScriptAlias /php/ "/path/to/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php “/php/bin/php-cgi”

Open php.ini and change cgi.fix_pathinfo to zero:

cgi.fix_pathinfo=0

The path to load php.ini in .bashrc:

export PHPRC=_/path/to/php/_bin
(Probably, better to put php.ini in _/path/to/php/_bin/)

If you have not only PHP files include HTML text, you have the files with another extension (’.html’, for example) that includes PHP, you may also add this extension at the following directive:

AddType application/x-httpd-php .php .html

Please, let me know if you have additional questions.

Thanks,
Sergey

Serge Jaulent
CNPTI / FRANCE
HI
Thank’s a lot for your help and your parameters.
My configuration
Apache installed in the USS from Z/OS v2r2 :
/etc/webap1/
Dir ,.
Dir ,…
Syml ,.31bit
Dir ,bin
Dir ,build
Dir ,cgi-bin
Dir ,conf
Dir ,error
Syml ,example_module
Syml ,HAPCE001.sh
Dir ,htdocs
Syml ,IBM
Dir ,icons
Dir ,include
Dir ,lib
Dir ,logs
Syml ,man
Dir ,modules
Syml ,notices
Dir ,properties
Syml ,readme
Syml ,readme.txt
Syml ,share
File ,version.signature
Dir ,www

My pages :
/CNPS/etc/webap1/www/
Dir ,.
Dir ,…
File ,about.html
Dir ,css
File ,entete.php
File ,hello.php
File ,hellophp.sav
Dir ,images
File ,index.html
File ,index.php
File ,test.php

Parameters from etc/webap1/conf/httpd.conf :
ServerRoot "/etc/webap1"
Listen 8090
DocumentRoot "/etc/webap1/www

Hi,

We have run PHP with IBM HTTP Server 8.5, CGI mode and FastCGI mode, using a “wrapper” script to manage different configurations.

All modes

httpd.conf

AddType application/x-httpd-php .php

CGI mode

httd.conf

LoadModule cgi_module modules/mod_cgi.so 

<Directory /path_of_my_application>
AddHandler myphp-cgi .php             
Action myphp-cgi url_to_my_wrapper.cgi
</Directory>

<Directory /path_to_folder_of_my_wrapper.cgi>
Options +ExecCGI            
SetHandler cgi-script      
AllowOverride None          
Options None                
Order allow,deny            
Allow from all              
</Directory>

my_wrapper.cgi

#!/bin/sh                                                   
# Language Environment                                      
_CEE_RUNOPTS="$_CEE_RUNOPTS,HEAP(,,,FREE)"                  
export _CEE_RUNOPTS                                         
# PHP                                                       
PHPRC="/path_to_folder_of_php.ini"                          
export PHPRC                                                
# DB2 ODBC                                                  
DSNAOINI="path_to_DSNAOINI"              
export DSNAOINI                                             
exec /path_to_php_bin_folder/php-cgi "$@"                  

FastCGI mode

httpd.conf

LoadModule fastcgi_module modules/mod_fastcgi.so
AddHandler fastcgi-script .fcgi     
FastCgiIpcDir /path_to_work_folder_for_fastcgi   
FastCgiConfig -autoUpdate -singleThreshold 100 -killInterval 300 -maxProcesses 10 -maxClassProcesses 1 

<Directory /path_of_my_application>
AddHandler myphp-fcgi .php             
Action myphp-cgi url_to_my_wrapper.fcgi
</Directory>

<Directory /path_to_folder_of_my_wrapper>  
Options +ExecCGI            
SetHandler fastcgi-script      
AllowOverride None          
Options None                
Order allow,deny            
Allow from all              
</Directory>  

my_wrapper.fcgi

#!/bin/sh                                                 
# Language Environment                                    
_CEE_RUNOPTS="$_CEE_RUNOPTS,HEAP(,,,FREE)"                
export _CEE_RUNOPTS                                       
# FastCGI                                                 
PHP_FCGI_CHILDREN=5                                       
export PHP_FCGI_CHILDREN                                  
PHP_FCGI_MAX_REQUESTS=1000                                
export PHP_FCGI_MAX_REQUESTS                              
# PHP                                                     
PHPRC="/path_to_folder_of_php.ini"                         
export PHPRC                                              
# DB2 ODBC                                                
DSNAOINI="path_to_DSNAOINI"          
export DSNAOINI                                           
exec /path_to_php_bin_folder/php-cgi "$@"                

Regards,

Denis

Hello
I also have some difficulty to get php running on z/OS.
I’ve installed php on a different PATH as Default -> /php
I’ve just ran following command on my OMVS:
/php/bin/php-cgi --php-ini /etc/ihsapach/cgi-bin/php/php.ini /etc/ihsapach/cgi-bin/php/myphp.php
Status: 404 Not Found
X-Powered-By: PHP/5.4.4
Content-type: text/html

No input file specified.

I’ve set cgi.fix_pathinfo=0 within php.ini and myphp.php looks very simple:

My first PHP page

<?php echo "Hello World!"; ?>

I see within /php/bin/php-config the default paths and I’m not sure if this could influence my problem?

Any help is highly appreciated.

thx, Patrik

Hi,

“PHP-CGI” is for WEB Server in “CGI” or “Fast CGI” mode.
To run from OMVS (or JCL) try “PHP”.

//J000000T JOB ,'PHP',CLASS=W,MSGCLASS=H,NOTIFY=&SYSUID            
//*                                                                
//* run php script                                                 
//*                                                                
//PHPPGM   SET PHPPGM='/sysplex/produit/php/bin/php' * PHP "CLI"   
//PHPINI   SET PHPINI='/local/basepro/php'           * php.ini path
//*                                                                
//PHP      EXEC PGM=BPXBATCH,                                      
//  PARM='sh &PHPPGM -c &PHPINI --help'                            
//STDOUT   DD SYSOUT=*                                             
//STDERR   DD SYSOUT=*                                             
//STDIN    DD DUMMY                                                
//STDPARM  DD DUMMY                                                

PHP-HELP.pdf (27,0 Ko)

//J000000T JOB ,'PHP',CLASS=W,MSGCLASS=H,NOTIFY=&SYSUID                 
//*                                                                     
//* run php script                                                      
//*                                                                     
//SYMBOLS  EXPORT SYMLIST=(PHPPGM,PHPINI,SCRIPT)                        
//*                                                                     
//PHPPGM   SET PHPPGM='/sysplex/produit/php/bin/php' * PHP "CLI"        
//PHPINI   SET PHPINI='/local/basepro/php'           * php.ini folder   
//SCRIPT   SET SCRIPT='/local/basepro/m4stats/phpinfo.php'              
//*                                                                     
//PHP      EXEC PGM=BPXBATCH                                            
//STDOUT   DD SYSOUT=*                                                  
//STDERR   DD SYSOUT=*                                                  
//STDIN    DD DUMMY                                                     
//STDPARM  DD *,SYMBOLS=(JCLONLY)                                       
sh &PHPPGM                                                              
-c &PHPINI                                                              
-i -m -v                                                                
&SCRIPT                                                                 
/*                                                                       

PHPINFO.pdf (101,6 Ko)

VIEW       /local/basepro/m4stats/phpinfo.php   
Command ===>                                    
****** *****************************************
000001 <?php                                    
000002 phpinfo();                               
000003 ?>                                       
****** *****************************************

Regards,

Denis

Hi Denis

I’ve performed these Jobs:
//*
//* RUN PHP SCRIPT
//*
//PHPPGM SET PHPPGM=’/php/bin/php’ * PHP “CLI”
//PHPINI SET PHPINI=’/php’ * PHP.INI PATH
//*
//PHP EXEC PGM=BPXBATCH,
// PARM=‘SH &PHPPGM -c &PHPINI --help’
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDIN DD DUMMY
//STDPARM DD DUMMY
-> output looks same as your ones

As well the second one with your phpinfo.php:
//*
//* RUN PHP SCRIPT
//*
//PHPPGM SET PHPPGM=’/php/bin/php’ * PHP “CLI”
//PHPINI SET PHPINI=’/php’ * PHP.INI PATH
//SCRIPT SET PHPINI=’/etc/ihsapach/cgi-bin/php/phpinfo.php’
//*
//SYMBOLS EXPORT SYMLIST=(PHPPGM,PHPINI,SCRIPT)
//

//PHP EXEC PGM=BPXBATCH,
// PARM=‘SH &PHPPGM -c &PHPINI -i -m -v &SCRIPT’
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDIN DD DUMMY
//STDPARM DD DUMMY
PHPINFO.pdf (36.9 KB)

But I get RC 3840

As well if I call phpinfo.php within Apache
http://141.171.36.169/php/phpinfo.php
I get -> No input file specified.

So somewhere I’ve missed a customizing step. I see a lot of inst. docs for different platform but not for z/OS.

Thx, Patrik

Hi

I did not manage to run PHP by direct call under IHS-Apache (I was there with IHS-GoDomino).
I was forced to set up “wrappers” to encapsulate the call to PHP in a bash script.
The bash script declares the environment variables (including PHPRC for the path to php.ini and DSNAOINI for the DB2 system).
The use of bash scripts also allows me to have different contexts (php.ini) by “Application”.
I have run two different implementations “CGI” and “FastCGI”. The simplest to implement is “CGI”:

  • AddType directive to associate the .php extension with the “application/x-httpd-php” type
  • AddHandler directive to associate the .php extension with a handler
  • Action directive to associate the manager with a bash script that must have the .cgi extension to be processed by the Apache module “mod_cgi.so”
  • the folder containing the bash script must be authorized at the CGI level
    The implementation details and sample bash script are given a bit higher in this conversation.

PHP configuration.pdf (52,1 Ko)
PHP FastCGI.pdf (628,2 Ko)
PHP CGI.pdf (615,0 Ko)

Denis

Hi Patrik,

The following command must be working even without HTTP server, if you are using php-cgi interpreter in the command line:

/php/bin/php-cgi /etc/ihsapach/cgi-bin/php/myphp.php

The one of the reason of the error ‘No input file specified.’ - an incorrect path to the file.
And another probably reason - the incorrect permission on directory with executed file. Try to set the execute permission not only for files, but for directory with the files too.

Default directory for web files - /your/httpserver/htdocs.
If you are running php files by Apache from another directory, you may also specify an additional setting - change DocumentRoot directive in httpd.conf (as a path to the directory with *.php files), for example:

DocumentRoot “/etc/ihsapach/cgi-bin/php”

And then run the script by Apache:

http://141.171.36.169/phpinfo.php

Thanks,
Sergey