Jump to content

PHP5 running as cgi problems...


karamorf

Recommended Posts

So I'm probably do something retarded but i can no longer find any useful information to try and solve the problem i'm having ... The powers at be asked me to figure out how to setup PHP4 and PHP5 as on the same Apache 1.3 server (i know, kind of silly but that's what they want). Anywise, after much trouble i figured out they both cant be installed as modules (which makes sense ...) and the way to do it was to have one of them setup as a cgi executable. So I've got PHP4 setup and working as the module (because that's what the current servers have there setup as) and I'm trying to add PHP5 as cgi to the server, except i seem incapable of getting it to work. So i've got the php cgi binary at:

 

/usr/local/etc/cgi-php5/bin/php-cgi

 

And if i pass it a php5 file at the command line it spits out a bunch of php code. The problem is i cant figure out how to tell Apache to do this (basically I'm a complete linux noob but im learning...). Ive got the .htaccess file in the folder i want to execute the php files with this setup:

 

Options +ExecCGI +FollowSymLinks

Action php-script "/usr/local/etc/cgi-php5/bin/php-cgi"

AddHandler php-script .php5

 

and what happens when i browse to something to be executed as PHP5 i get a file not found error with the page its trying to find as:

 

The requested URL /usr/local/etc/cgi-php5/bin/php-cgi/test/test.php5 was not found on this server.

 

So this looks all wrong to me, but ive got no idea where my setup is incorrect (And there seems to be a lack of easy to follow guides that actually explain what the commands in the .htaccess file do, how to setup PHP5 as cgi, beyond just compiling it, and how to get the .file to be executed by the cgi binary at location x). To me it looks like it doesnt realize to send the php file to /usr/local/cgi-php5/bin/php-cgi and instead tries to browse to that path, but i cant seem to find any useful information on how to resolve this issue.

 

basically i feel somewhat retarded because this shouldn't be that hard, but for some reason it seems to be... maybe it has more to do with trying to get different version of PHP to run on the same server is just silly but thats what i have to figure out how to do and i seem to have hit a brick wall ...

Link to comment
Share on other sites

Also just tried adding code into the httpd.conf to get the cgi to execute ...

 

ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"

 

<Directory "/usr/local/apache/cgi-bin/">

Options ExecCGI

AddHandler cgi-script  .cgi  .pl

</Directory>

 

Added something like that (though with all the paths different, i copied that from the guide and didnt really feel like editing it) and it did the samething that the .htaccess files are doing, add the path to url instead of having the cgi binary at path execute the page... rather annoying...

Link to comment
Share on other sites

played around a bit more with the httpd.conf file, now i have this configure in it:

ScriptAlias Path_To_CGI_PHP.php5 PathToCGIBinary

 

<Directory "PathToHtmlRoot">

    Options Indexes FollowSymLinks MultiViews ExecCGI

 

    AddHandler cgi-script .php5

    Action cgi-script  Path_To_CGI_PHP

    AllowOverride All

     .

     .

     .

</Directory>

 

and that gives me this error in the log file:

 

[Fri Aug 22 10:21:49 2008] [error] (8)Exec format error: exec of Path_To_CGI_PHP/test/test.php5 failed

[Fri Aug 22 10:21:49 2008] [error] [client 10.0.22.1] Premature end of script headers: Path_To_CGI_PHP/test.php5

 

which seems like a step in the right direction, however still cant find very much useful information to this error...

finding this error in perl-cgi usually meant you tried to print something before declaring the character type, but i havent read anywhere about having to use a char type with php...

Link to comment
Share on other sites

well i guess i really wasnt as stuck as i though i was because i got it to work. anywise, the problem with those errors was what i thought it was, the char set wasnt being set... in roder to use php as cgi you have to compile it with the flag --enable-discard-path and then in the php5 file it has to have #!PathTo_CGI_PHP_Exec_binary as the first line.

Link to comment
Share on other sites

  • 3 months later...

Hi karamorf.

 

Could you please show your configuration with real path's? I ran into the same problem like you did, unfortunately I could not solve it like you with the steps taken in your third post, I still get this strange error:

 

"The requested URL /usr/local/bin/php/phpinfo.php5 was not found on this server."

 

when trying to access http://server-root/phpinfo.php5

 

cheers

danielito

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.