Patching php 5.2.12 for php-fpm confusion

38 views
Skip to first unread message

agentc0re

unread,
Mar 27, 2010, 1:41:34 AM3/27/10
to highload-php-en
I am a little confused as to which patch i should be applying to php
5.2.12.
http://php-fpm.org/downloads/php-5.2.12-fpm-0.5.13.diff.gz
OR
http://php-fpm.org/downloads/0.6/php-fpm-0.6~5.2.patch
?

Both seems to do two totally different things as both patches, i've
found out, can be applied to the php source. That is what i have
currently been doing.

I have two options as well, --enable-fpm and --with-fpm.

--enable-fpm i think comes from the first patch. When i pass just
this with, --enable-fastcgi and --with-libevent=shared, i get a php-
fpm.conf and a php-fpm script but no binary.

If i add --with-fpm with --enable-fpm, same result. However, if i
remove --enable-fpm, i get ONLY the binary.

I also noticed that when the binary is made, the php-cgi binary is
not. Is this suppose to happen?

Any clarification would be much appreciated. Thanks! :D

Michael Shadle

unread,
Mar 27, 2010, 1:56:28 AM3/27/10
to highloa...@googlegroups.com
This one:
http://php-fpm.org/downloads/php-5.2.12-fpm-0.5.13.diff.gz

This is my build script, works like a charm. Rock solid including suhosin!

#!/bin/bash
BD=`pwd`

VER="5.2.13"
FPMVER="0.5.13"
SUHVER="0.9.7"

rm -rf php-${VER}
wget -c http://us3.php.net/get/php-${VER}.tar.gz/from/this/mirror
tar xvfz php-${VER}.tar.gz
cd php-${VER}

# php-fpm
wget -c http://php-fpm.org/downloads/php-${VER}-fpm-${FPMVER}.diff.gz
gunzip php-${VER}-fpm-${FPMVER}.diff.gz
patch -p1 < php-${VER}-fpm-${FPMVER}.diff

# suhosin
wget -c http://download.suhosin.org/suhosin-patch-${VER}-${SUHVER}.patch.gz
gunzip suhosin-patch-${VER}-${SUHVER}.patch.gz
patch -p1 < suhosin-patch-${VER}-${SUHVER}.patch

./configure \
--enable-fastcgi \
--enable-discard-path \
--enable-force-cgi-redirect \
--enable-fpm \
--with-fpm-pid=/var/run/php-fpm.pid \
--with-fpm-log=/var/log/php-fpm.log \
--with-fpm-conf=/etc/php-fpm.conf \
--enable-cli \

...etc...

agentc0re

unread,
Mar 28, 2010, 5:19:41 AM3/28/10
to highload-php-en

On Mar 26, 11:56 pm, Michael Shadle <mike...@gmail.com> wrote:
> This one:http://php-fpm.org/downloads/php-5.2.12-fpm-0.5.13.diff.gz

Awesome. Thank you very much for pointing me in the right direction,
I appreciate it.

Now, the other part I'm having a hard time with is getting apache to
use php-fpm. I've searched through the forums, and found more
questions about how to do it, than answers. I'll try to be very
specific, so in hopes you don't know it someone that might come across
it will. I know you've said before in a prior post you didn't want to
take the time to learn fastcgi. :P

$cat mod_fastcgi.conf
---------------------
# FastCgi Configuration

LoadModule fastcgi_module /usr/lib/httpd/modules/mod_fastcgi.so

AddHandler fastcgi-script .fcgi .fcg .fpl
FastCgiConfig -idle-timeout 20 -maxClassProcesses 1
FastCgiWrapper /usr/sbin/suexec

<Location "/fcgi-bin/php-fastcgi.fcgi">
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
Options +ExecCGI +FollowSymLInks +SymLinksIfOwnerMatch
SetHandler fastcgi-script
</Location>

I include this in my main httpd.conf as such:
--------------------------------------------
Include /etc/httpd/mod_fastcgi.conf

a snippit of my httpd-vhosts.conf:
----------------------------------
SuexecUserGroup learnix learnix
ScriptAlias /fcgi-bin "/home/learnix/public_html/cgi-bin/php-
fastcgi.fcgi"


Alias /learnix /home/learnix/public_html
FastCgiExternalServer /learnix -host 127.0.0.1:9000 -user learnix -
group learnix

#FastCgiExternalServer /home/learnix/public_html -host 127.0.0.1:9000 -
user learnix -group learnix

#AddType application/x-httpd-fastphp .php
#Action application/x-httpd-fastphp /learnix
AddHandler php-fastcgi .php
Action php-fastcgi /fcgi-bin

and lastly, my php-fastcgi.fcgi:
~$ cat public_html/cgi-bin/php-fastcgi.fcgi
#!/bin/sh
# Set desired PHP_FCGI_* environment variables.
# Example:
# PHP FastCGI processes exit after 500 requests by default.
export PHPRC=/home/learnix
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN

PHP_FCGI_MAX_REQUESTS=500
export PHP_FCGI_MAX_REQUESTS

# Replace with the path to your FastCGI-enabled PHP executable
umask 0022
#exec /usr/bin/php-cgi --fpm --fpm-config /etc/httpd/php-fpm.conf
exec /usr/bin/php-cgi
#exec /usr/bin/php-cgi -d apc.shm_size=25


Okay, as you can see there i left some of my commented items out
because i just wanted to illustrate what i've tried. Now the above is
obviously a wrapper script. This does not get php-fpm working, it
just gets php-cgi +fastcgi working. In my vhost i do have the fastcgi
external server directive, but when pointing it to my root, it doesn't
work. I also wouldn't think that i would point that to a file for a
wrapper because the wrapper would just execute an instance of php-cgi
which defeats the purpose of running the php-fpm init script to start
the daemon, correct?

Any help is much appreciated in trying to figure how to get fastcgi to
go to the already create php-cgi proccesses by php-fpm instead of
creating new ones.

Thank you! :D

agentc0re

unread,
Mar 28, 2010, 3:16:23 PM3/28/10
to highload-php-en
Woot!! I figured it out! Okay, here's the magic.

Below is what i have in my vhost conf. You must create a "virtual"
directory and in there symlink your server root. so in my case, i
created "virtual_html" and then symlinked "/home/learnix/public_html"
in there.

This makes it possible to server all your none php content through
apache while sending all your .php content to php-fpm.

I plan on writing up a How To on my site, explaining everything i
learned in more detail so in hopes it will help others because i still
have yet to find a guide or anything explaining how to get php-fpm to
work in apache. Tons of Nginx guides but no apache ones.

my site is http://learnix.net and since i haven't starting writing it
yet, there is no direct link. Just check there in a week or so from
the date of this post. :D

SuexecUserGroup learnix learnix

FastCgiExternalServer /home/learnix/virtual_html/public_html -host


127.0.0.1:9000 -user learnix -group learnix

AddHandler php-fastcgi .php
Action php-fastcgi /virtualhtml
Alias /virtualhtml /home/learnix/virtual_html/public_html/

<Directory "/home/learnix/virtual_html">
Options +ExecCGI +FollowSymLInks +SymLinksIfOwnerMatch
AllowOverride all
Order allow,deny
Allow from all
</Directory>

Reply all
Reply to author
Forward
0 new messages