z/OS Tools & Language

Expand all | Collapse all

PHP 7 - FastCGI: incomplete headers (115 bytes) received from server

  • 1.  PHP 7 - FastCGI: incomplete headers (115 bytes) received from server

    Posted 09-20-2017 12:37

    Hi,

    I’m trying to implement PHP 7.
    I have managed to make it work in “CGI” mode, but I have an error that I can not analyze when I try to make it run in “FastCGI” mode:

    [error] [client 126.32.101.80] FastCGI: incomplete headers (115 bytes) received from server “/local/basepro/m4stats/php/php.fcgi”, referer: http://tmvs:8080/

    In the previous version PHP 5, the two modes “CGI” and “FastCGI” were working.

    Both modes are very similar: PHP is executed through a shell script that declares the necessary environment variables and calls the PHP interpreter.

    In httpd.conf I said (excerpt):

    <Location />                  
    CharsetSourceEnc IBM-1047
    CharsetDefault   ISO8859-1    
    </Location>
    AddType    application/x-httpd-php .php
    LoadModule cgi_module modules/mod_cgi.so
    LoadModule fastcgi_module modules/mod_fastcgi.so
    <IfModule mod_fastcgi.c>
    AddHandler fastcgi-script .fcgi
    FastCgiIpcDir /local/basepro/httpserv/fastcgi
    FastCgiConfig -autoUpdate -singleThreshold 100 -killInterval 300 -maxProcesses 10 -maxClassProcesses 1
    </IfModule>
    

    In my application (directory) to activate the “CGI” mode I add to the Apache configuration:

    Alias /M4Stats /local/basepro/m4stats  
    <Directory /local/basepro/m4stats>  
    DirectoryIndex index.php index.html index.html.var   
    AddHandler myphp-cgi .php             
    Action myphp-cgi /M4Stats/php/php.cgi 
    </Directory> 
    <Directory "/local/basepro/m4stats/php">  
    Options +ExecCGI   
    AllowOverride None 
    Options None       
    Order allow,deny   
    Allow from all     
    SetHandler cgi-script 
    </Directory>   
    

    The shell script “php.cgi” to run in “CGI” mode is:

    #!/bin/sh   
    export _BPXK_AUTOCVT=ON           
    export CGI_HEADER_ENCODING=EBCDIC 
    export CGI_BODY_ENCODING=EBCDIC 
    _CEE_RUNOPTS="$_CEE_RUNOPTS,HEAP(,,,FREE)"  
    export _CEE_RUNOPTS                         
    PHPRC="/local/basepro/m4stats/php"  
    export PHPRC                        
    DSNAOINI="/local/basepro/m4stats/php/DSNAOINI"  
    export DSNAOINI                                 
    exec /sysplex/produit/outdev/php/php-7.0.5/bin/php-cgi "$@" 
    

    In this configuration PHP 7 works.

    In my application (directory) to activate the “FastCGI” mode I add to the Apache configuration:

    Alias /M4Stats /local/basepro/m4stats
    <Directory /local/basepro/m4stats>  
    DirectoryIndex index.php index.html index.html.var 
    AddHandler myphp-fcgi .php             
    Action myphp-fcgi /M4Stats/php/php.fcgi
    </Directory> 
    <Directory "/local/basepro/m4stats/php">
    Options +ExecCGI    
    AllowOverride None  
    Options None        
    Order allow,deny    
    Allow from all      
    setHandler fastcgi-script 
    </Directory> 
    

    The shell script “php.fcgi” to run in “FastCGI” mode is:

    #!/bin/sh 
    export _BPXK_AUTOCVT=ON             
    export CGI_HEADER_ENCODING=EBCDIC   
    export CGI_BODY_ENCODING=EBCDIC  
    _CEE_RUNOPTS="$_CEE_RUNOPTS,HEAP(,,,FREE)"   
    export _CEE_RUNOPTS                          
    export PHP_FCGI_CHILDREN=5         
    export PHP_FCGI_MAX_REQUESTS=1000  
    export PHPRC="/local/basepro/m4stats/php" 
    export DSNAOINI="/local/basepro/m4stats/php/DSNAOINI" 
    exec /sysplex/produit/outdev/php/php-7.0.5/bin/php-cgi "$@" 
    

    In this configuration PHP 7 failes with a message in Apache error.log:

    [error] [client 126.32.101.80] FastCGI: incomplete headers (115 bytes) received from server “/local/basepro/m4stats/php/php.fcgi”

    I activated a trace of the IP frames, but it shows nothing.

    See details in the attached file.PHP_7_FastCGI.tar.gz (1,5 Mo)

    Thanks for your help.

    Denis



  • 2.  RE: PHP 7 - FastCGI: incomplete headers (115 bytes) received from server

    Posted 09-22-2017 07:16

    Hi Denis,

    Thanks for the complete information.
    The problem was recreated in our environment. We will investigate the issue.

    Thanks,
    Sergey



  • 3.  RE: PHP 7 - FastCGI: incomplete headers (115 bytes) received from server

    Posted 09-27-2017 05:12


  • 4.  RE: PHP 7 - FastCGI: incomplete headers (115 bytes) received from server

    Posted 11-06-2017 11:07

    Hi Denis,

    I’ve found and fixed the reason of this issue. In details:

    • apache + mod_fastcgi submits only EBCDIC-encoded data
    • php works only with ASCII-encoded strings
    • FastCGI doesn’t use pure textual HTTP. Instead It uses FastCGI records which are textual HTTP data wrapped with binary structure. So Enhanced ASCII support can’t be used because only textual data should be converted to EBCDIC, not binary data.

    New release with FastCGI support will be available soon.