Problems when compiling PHP 5.3.8 with fpm and fastcgi (php-cgi)

Written by - 0 comments

Published on - Listed in PHP Linux

I'm currently working on a benchmarking project to compare different web server configurations and PHP integrations. After having tested several Apache2+mod_php configurations, I wanted to do the same with Apache2+fastcgi+php(+fpm) but already at the compilation of PHP it failed. What happened?

According to the PHP configuration documentation, both cli and cgi versions of the php binary should be created at the end of make:

./configure --help | egrep '(cgi|cli)'
  --disable-cli           Disable building CLI version of PHP
  --disable-cgi           Disable building CGI version of PHP

This means I don't need to explicitly configure with something like '--enable-fastcgi' which
1) is mentioned on a lot of websites and
2) doesn't exist anymore (!).
So go figure, cli (php) and cgi (php-cgi) binaries should be created.
Note the word 'should'... because nothing happened.

My goal was to configure PHP with both the cgi and the new fpm binary (called php-fpm) with the following configure syntax:

./configure --prefix=/usr \
--with-libdir=lib64 \
--with-apxs2=/usr/bin/apxs2 \

But I got the following error message:

configure: error:
|                        *** ATTENTION ***                           |
|                                                                    |
| You've configured multiple SAPIs to be build. You can build only   |
| one SAPI module and CLI binary at the same time.                   |

After reading the bug report PHP #52419, it seems that '--enable-fpm' doesn't work together with '--with-apxs2' so the latter one needs to be removed from the configure command.

Once I did that, configure and make ran without problems. But then the next downer: After a quick check in sapi/cgi, I couldn't find the php-cgi binary - actually it wasn't created at all while the php cli binary (in sapi/cli) was created just fine.
After a lot of testing yesterday night and tonight I finally found out why: The php-cgi binary is not created if PHP is compiled with '--enable-fpm'. As stupid as it sounds but if you want to use PHP as FastCGI module and with the FPM daemon you must compile PHP several times until you get all the binaries you need.

- php-cgi binary is not created when PHP is compiled with '--enable-fpm'
- '--enable-fpm' doesn't work when PHP is compiled with '--with-apxs2' (configure error)

Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.