0

I have been trying to get PHP-FPM to work with Apache 2.4, but mod_fastcgi does not work with 2.4. Is there any solution to this problem? I want to run it using an UNIX socket, but I cannot find any tutorial on this, they all use 127.0.0.1:9000

Katherine Villyard
  • 18,550
  • 4
  • 37
  • 59
CakeSneer
  • 109
  • 1
  • 1

2 Answers2

1

I installed Apache 2.2 with mod_fastcgi and it works using UNIX sockets.

Snippet of configuration from my httpd.conf is:

<IfDefine FASTCGI>
    <IfModule mod_fastcgi.c>
        Alias                   /php5.fastcgi /var/www/example.com/cgi-bin/php5.fastcgi
        FastCGIExternalServer   /var/www/example.com/cgi-bin/php5.fastcgi -flush -socket /var/www/example.com/php-fpm.sock -idle-timeout 30
        AddType                 application/x-httpd-fastphp5    .php
        Action                  application/x-httpd-fastphp5    /php5.fastcgi

        DirectoryIndex index.php index.html
    </IfModule>
</IfDefine>

PHP-FPM is listening on socket /var/www/example.com/php-fpm.sock.

PHP-FPM's configuration (inside a pool):

listen          = /var/www/$pool/php-fpm.sock
listen.owner    = apache
listen.group    = apache
listen.mode     = 0660

I did not succeed with mod_fcgi. Apache 2.4 now has mod_proxy_fcgi which I didn't tested. You need something with that can work with external FastCGI servers and don't manage the processes itself.

Aleš Krajník
  • 2,531
  • 1
  • 16
  • 11
  • 1
    I would suggest to be more restrictive on file extensions to avoid injection attacks such as **malicious.php.jpg**. Replace `AddType` with ` SetHandler application/x-httpd-fastphp5 ` – Kontrollfreak Jan 05 '14 at 00:30
  • 1
    Nevermind. There is a PHP-FPM configuration option `security.limit_extensions` that has a default value of `.php` which does exactly the same. (Well, maybe not *exactly* the same.) – Kontrollfreak Jan 07 '14 at 14:27
  • Still, it's worth checking. I will check both, thanks! – Aleš Krajník Jan 08 '14 at 09:29
1

There is a patch for mod_fastcgi that compiles against Apache 2.4: ByteInternet / libapache-mod-fastcgi (Currently, the tag byte/2.4.6-1byte6+apache24 and the branch byte include this patch.)

Before you compile the module with apxs apply the following patch:

patch --input=debian/patches/byte-compile-against-apache24.diff

Then compile / install / activate:

apxs -ciao mod_fastcgi.so *.c
Kontrollfreak
  • 406
  • 5
  • 8