|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-06-25 11:37 UTC] john dot walsh at mini-net dot co dot uk
[2008-06-25 12:16 UTC] laurent_baillif at hotmail dot com
[2008-07-14 21:37 UTC] jani@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 22 22:00:02 2025 UTC |
Description: ------------ Hello, I have an issue with STDOUT/OUTPUT of PHP. I?m about to use a PHP script for a RewriteMap directive inside APACHE. And I have identified that APACHE never receive the output from my PHP script and this after trying several way to send the output and also on several platform (winXP/apache2/PHP5 & OPENSUSE/apache2/PHP5.2.5) Thank?s for your feedback Regards, Reproduce code: --------------- I have this configuration in a virtual host of APACHE (Works fine if I put a Perl script instead of PHP) <VirtualHost *:80> ServerAdmin mymail@mail.com DocumentRoot "/home/mywork/web/partenaire" ServerName mytest.mydomain.com DirectoryIndex index.php ErrorLog /home/mywork/log/apache/error.log LogLevel debug RewriteLog /home/mywork/log/apache/rewrite.log RewriteLogLevel 9 RewriteEngine on #RewriteLock /home/mywork/web/partenaire/test/rewrite.lock #RewriteMap rewritemap prg:/home/mywork/web/partenaire/test/rewritemap.perl RewriteMap rewritemap prg:/home/mywork/web/partenaire/test/rewritemap.php RewriteOptions Inherit RewriteRule ^/test/(.*)$ ${rewritemap:%{REQUEST_URI}} [L] <Directory "/home/mywork/web/partenaire"> Options FollowSymLinks AllowOverride all Order allow, deny Allow from all </Directory> </VirtualHost> I can confirm my PHP script is working fine from the console (read STDIN and write STDOUT) and when it is start with apache, he receive correctly the STDIN but never send back the STDOUT. I have tried several configurations in my script and APACHE never get the STDOUT and just hang or return a blank URL. My rewritemap.php script looks like this: #!/usr/bin/php <?php //Flag to verify the script is starting //$handle = fopen ("home/stat.txt", 'a+'); //fwrite($handle, date("H")."h".date("i")."m".date("s").": start of the script\r\n"); //fclose($handle); $stdin = fopen ('php://stdin', 'r'); $output = fopen('php://output', 'w'); ob_implicit_flush (true); // Use unbuffered output while ($line = fgets ($stdin)) { $line = trim($line); //Flag to verify the script is receinving STDIN //$handle = fopen ("home/stat.txt", 'a+'); //fwrite($handle, date("H")."h".date("i")."m".date("s").": Just receive: $line \r\n"); //fclose($handle); fwrite(STDOUT,"mynewURL?".$line); //try this one and didn?t work with apache fwrite($output,"mynewURL?".$line); //try this with OUTPUT and didn?t work with neither echo "mynewURL?".$line //try this one also but only works with the console } ?> Expected result: ---------------- I can confirm my PHP script is working fine from the console (read STDIN and write STDOUT) and when it is start with apache, he receive correctly the STDIN but never send back the STDOUT. With the same configuration a perl script is working fine for apache. I have tried several configurations in my php script and APACHE never get the STDOUT and just hang or return a blank URL. Actual result: -------------- Blank url or apache hang.