Running through CGI php

Hi all!


Just installed latest Mysource Matrix, worked fine, activated the Aliases and wanted to start using it.



But I only received errors, mostly: "No input file specified."



PHP4 is used as a CGI on this server, because mainly I'm using mod_php5, needed and managed to get PHP4 running as a CGI for this virtual host.


       
      RemoveHandler .php
      ScriptAlias /cgi-dir/ /var/www/matrix.local/cgi-php/
      AddType application/x-httpd-php4 .php
      Action application/x-httpd-php4 "/cgi-dir/php.cgi"
      
        AllowOverride All
        Options ExecCGI
        
          Order allow,deny
          Allow from all
        
      


I tracked the errors to the calling-method of matrix, I think it uses (through the aliases) a scheme like this, am I right?

http://matrix.local/core/web/index.php/_admin/or/whatever

But THIS doesn't seem to work with the CGI-version.

Any thoughts anyone?

Bye, Stephan

Nope, you'll never get a url with /core/web/index.php in it. All requests are aliased directly to the index.php file instead.


Does apache's error log having anything in it?

Yea, that's what I meant with "through the aliases", the alias sets the root-path to /core/web/index.php and everything else like _admin is added, so you get a real path of "/core/web/index.php/_admin". And this doesn't seem to work with the CGI.


Apache-log doesn't say anything, because he doesn't even recognize this as a call to php… he tries to deliver the above mentioned URL which (of course) isn't found.



Maybe something is wrong with my Configuration, has someone got this working with a CGI-PHP?

Looking at my configurition and matrix' aliases again I think that my problems might be caused by all the aliases? CGI-PHP is called through a script-aliases, and / is another aliases, maybe this doesn't work out together?

Ok, I found the solution for this one - quoting from PHP Manual - Chapter 24. Installed as CGI binary:

[quote]By enabling 'force-cgiredirects', you must:

  1. set 'cgi.fix_pathinfo=1' in php.ini
  2. leave doc_root commented out (php.ini also)



    If you miss item 1, the apache logs will show 'unexpected T_STRING' in the php binary.

    If you miss item 2, you'll only see 'No input file specified.', instead of the expected output.[/quote]



    Afterwards this works fine - but results in the next set of errors, hehe…


    File: [SYSTEM_ROOT]/core/include/mysource.inc Line: 314 
    Message: URL "matrix.dev.im-online.dece_matrix_3-4-1/core/web/index.php" not found


Looks like current_url() doesn't produce the right path, I tracked it down to $_SERVER['PHP_SELF'], it should look like this:

    [PHP_SELF] => /_admin/


but with the CGI it looks like this:

    [PHP_SELF] => ce_matrix_3-4-1/core/web/index.php


I'll try to compile the CGI with force-cgi-redirect and will report what's happening.

Maybe you should test Matrix with a CGI on your side? Guess I'm not the only one using it with a CGI...

Stephan

This is getting a monologue :wink:


Comparing the contents of $_SERVER with CGI-PHP4 and MOD_PHP5 (it throws a lot of errors but it's reaching the lines I need to get output) I found these differences:



MOD:

    [REQUEST_URI] => /matrix/_admin/ 
    [SCRIPT_NAME] => /matrix 
    [PATH_INFO] => /_admin/ 
    [PHP_SELF] => /matrix/_admin/


CGI:
    [REQUEST_URI] => /matrix/_admin/ 
    [SCRIPT_NAME] => ce_matrix_3-4-1/core/web/index.php 
    [PATH_INFO] => /_admin/ 
    [PHP_SELF] => ce_matrix_3-4-1/core/web/index.php


btw, don't ask me why he cuts down SCRIPT_NAME and PHP_SELF with the CGI, it should read something like "/mysource_matrix_3-4-1/..."

You're using PHP_SELF in current_url(), maybe you can use the REQUEST_URI and strip out unneeded stuff?

Stephan