On February 28, 2012 18:57 , Daniel <danco...@gmail.com> wrote:
What is the correct way for configuring mod_proxy_fcgi and PHP-FPM?

This is what I have:
ProxyPass /www/ fcgi://127.0.0.1:9000/www/ <http://127.0.0.1:9000/www/>

What you have is correct. You can also put it in a <Location> block, like this:

<Location /www/>
    ProxyPass fcgi://127.0.0.1:9000/www/ <http://127.0.0.1:9000/www/>
</Location>

Or you can use a RewriteRule, like this:

RewriteRule ^/www/(.*)$ fcgi://127.0.0.1:4000/www/$1 [P]

All of the above are equivalent.


All domains are setup under /www/domain.com <http://domain.com>

When I try to access domain.com/info.php <http://domain.com/info.php> however, it just shows the file as text. (<?php info(); ?>) There are no errors in apache's error_log or PHP-FPM's. Both are set to debug.

For the ProxyPass directive you have above, http://domain.com/info.php is not correct, and it SHOULD show you the info.php file as text. The correct URL for the ProxyPass directive you gave is http://domain.com/www/info.php This is because the ProxyPass directive you gave will only proxy requests for URI paths that begin with "/www/" (this is what the first argument to the ProxyPass directive -- or the enclosing Location block -- controls).

If using the correct URL doesn't work, here are some more things to look at:

Make sure PHP-FPM is correctly configured to server URI paths that all begin with "/www/". You may need to change your directory structure for your PHP-FPM / PHP document root (which is separate from the Apache HTTP Server document root), or change the PHP document_root config setting in order to get the results you want.

Make sure you have PHP-FPM error logging turned on via the error_log config item in php-fpm.conf and that you are seeing SOMETHING getting logged there (for example, startup messages).


Test PHP-FPM independently of Apache HTTP Server to make sure that it is working. If it is, then you know that the problem is with Apache. If it isn't, then no amount of troubleshooting Apache will help. I recommend setting up a script that you can manually run on your web server machine that will send an FCGI request to PHP-FPM and display the results:

If you want to use PHP for the script, try: https://github.com/adoy/PHP-FastCGI-Client

If you want to use Perl (which is what I personally prefer) for the script, try: http://search.cpan.org/~tokuhirom/FCGI-Client-0.08/lib/FCGI/Client.pm

You should also be able to find scripts for Python or other languages by googling "python fastcgi client" or "python fcgi client"


If you are using Apache 2.4.x (or 2.3.x) try turning up the LogLevel for proxying to "trace" (which is more detailed than "debug") and see if that provides any additional information as to what is -- or is not -- happening. For example, when debugging PHP-FPM issues, I use:

LogLevel  info ssl:notice rewrite:trace8 proxy:trace8 proxy_fcgi:trace8


Good luck!  I hope this helps.

--
  Mark Montague
  m...@catseye.org

Reply via email to