Merge lp:~grant-delaney/ius/php53 into lp:~ius-coredev/ius/php53u

Proposed by Grant Delaney
Status: Merged
Merge reported by: BJ Dierkes
Merged at revision: not available
Proposed branch: lp:~grant-delaney/ius/php53
Merge into: lp:~ius-coredev/ius/php53u
Diff against target: 593 lines (+486/-3)
3 files modified
SOURCES/php-fpm.conf (+273/-0)
SOURCES/php-fpm.initd (+140/-0)
SPECS/php53.spec (+73/-3)
To merge this branch: bzr merge lp:~grant-delaney/ius/php53
Reviewer Review Type Date Requested Status
BJ Dierkes Pending
Review via email: mp+29926@code.launchpad.net

This proposal supersedes a proposal from 2010-07-08.

Description of the change

Adding support for php-fpm

To post a comment you must log in.
Revision history for this message
BJ Dierkes (derks) wrote : Posted in a previous version of this proposal

This looks really good... and from what I can tell, FPM is only built into the php-fpm binary which would be required as to not mess with core php. A couple issues and thoughts:

 - Wrap a '_with_fpm' condition in there (similar to _with_zts, _with_psa, etc). So everything added for 'fpm' should be within a '%if 0%{?_with_fpm}' condition. I think I would prefer to put this in there optionally (meaning users can rebuild from the srpm if they want fpm)... until I am comfortable adding it by default.

 - "Requires: %{name}-%{version}" ... should be "Requires: %{name} = %{version}-%{release}" under %package fpm

 - "Provides: php-fpm" should be "Provides: %{real_name}-fpm = %{version}-%{release}

 - Under '%install' sometimes you reference %{_sysconfdir} and others raw '/etc'... should use the macro consistently.

 - %defattr missing from %files fpm

 - Any README, LICENSE, COPYING, from the fpm source need to be included under a %doc under %files fpm

review: Needs Fixing
lp:~grant-delaney/ius/php53 updated
29. By grant.delaney <email address hidden>

added the fpm post/preun chkconfig

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'SOURCES/fpm_svn_r300604.tar.gz'
2Binary files SOURCES/fpm_svn_r300604.tar.gz 1970-01-01 00:00:00 +0000 and SOURCES/fpm_svn_r300604.tar.gz 2010-07-15 11:09:43 +0000 differ
3=== added file 'SOURCES/php-fpm.conf'
4--- SOURCES/php-fpm.conf 1970-01-01 00:00:00 +0000
5+++ SOURCES/php-fpm.conf 2010-07-15 11:09:43 +0000
6@@ -0,0 +1,273 @@
7+;;;;;;;;;;;;;;;;;;;;;
8+; FPM Configuration ;
9+;;;;;;;;;;;;;;;;;;;;;
10+
11+; All relative paths in this configuration file are relative to PHP's install
12+; prefix.
13+
14+; Include one or more files. If glob(3) exists, it is used to include a bunch of
15+; files from a glob(3) pattern. This directive can be used everywhere in the
16+; file.
17+;include=/etc/fpm.d/*.conf
18+
19+;;;;;;;;;;;;;;;;;;
20+; Global Options ;
21+;;;;;;;;;;;;;;;;;;
22+
23+[global]
24+; Pid file
25+; Default Value: none
26+;pid = /var/run/php-fpm.pid
27+
28+; Error log file
29+; Default Value: /var/log/php-fpm.log
30+;error_log = /var/log/php-fpm.log
31+
32+; Log level
33+; Possible Values: alert, error, warning, notice, debug
34+; Default Value: notice
35+;log_level = notice
36+
37+; If this number of child processes exit with SIGSEGV or SIGBUS within the time
38+; interval set by emergency_restart_interval then FPM will restart. A value
39+; of '0' means 'Off'.
40+; Default Value: 0
41+;emergency_restart_threshold = 0
42+
43+; Interval of time used by emergency_restart_interval to determine when
44+; a graceful restart will be initiated. This can be useful to work around
45+; accidental corruptions in an accelerator's shared memory.
46+; Available Units: s(econds), m(inutes), h(ours), or d(ays)
47+; Default Unit: seconds
48+; Default Value: 0
49+;emergency_restart_interval = 0
50+
51+; Time limit for child processes to wait for a reaction on signals from master.
52+; Available units: s(econds), m(inutes), h(ours), or d(ays)
53+; Default Unit: seconds
54+; Default Value: 0
55+;process_control_timeout = 0
56+
57+; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
58+; Default Value: yes
59+;daemonize = yes
60+
61+;;;;;;;;;;;;;;;;;;;;
62+; Pool Definitions ;
63+;;;;;;;;;;;;;;;;;;;;
64+
65+; Multiple pools of child processes may be started with different listening
66+; ports and different management options. The name of the pool will be
67+; used in logs and stats. There is no limitation on the number of pools which
68+; FPM can handle. Your system will tell you anyway :)
69+
70+; Start a new pool named 'www'.
71+[www]
72+
73+; The address on which to accept FastCGI requests.
74+; Valid syntaxes are:
75+; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
76+; a specific port;
77+; 'port' - to listen on a TCP socket to all addresses on a
78+; specific port;
79+; '/path/to/unix/socket' - to listen on a unix socket.
80+; Note: This value is mandatory.
81+listen = 127.0.0.1:9000
82+
83+; Set listen(2) backlog. A value of '-1' means unlimited.
84+; Default Value: -1
85+;listen.backlog = -1
86+
87+; List of ipv4 addresses of FastCGI clients which are allowed to connect.
88+; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
89+; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
90+; must be separated by a comma. If this value is left blank, connections will be
91+; accepted from any ip address.
92+; Default Value: any
93+;listen.allowed_clients = 127.0.0.1
94+
95+; Set permissions for unix socket, if one is used. In Linux, read/write
96+; permissions must be set in order to allow connections from a web server. Many
97+; BSD-derived systems allow connections regardless of permissions.
98+; Default Values: user and group are set as the running user
99+; mode is set to 0666
100+;listen.owner = nobody
101+;listen.group = nobody
102+;listen.mode = 0666
103+
104+; Unix user/group of processes
105+; Note: The user is mandatory. If the group is not set, the default user's group
106+; will be used.
107+user = nobody
108+group = nobody
109+
110+; Choose how the process manager will control the number of child processes.
111+; Possible Values:
112+; static - a fixed number (pm.max_children) of child processes;
113+; dynamic - the number of child processes are set dynamically based on the
114+; following directives:
115+; pm.max_children - the maximum number of children that can
116+; be alive at the same time.
117+; pm.start_servers - the number of children created on startup.
118+; pm.min_spare_servers - the minimum number of children in 'idle'
119+; state (waiting to process). If the number
120+; of 'idle' processes is less than this
121+; number then some children will be created.
122+; pm.max_spare_servers - the maximum number of children in 'idle'
123+; state (waiting to process). If the number
124+; of 'idle' processes is greater than this
125+; number then some children will be killed.
126+; Note: This value is mandatory.
127+pm = dynamic
128+
129+; The number of child processes to be created when pm is set to 'static' and the
130+; maximum number of child processes to be created when pm is set to 'dynamic'.
131+; This value sets the limit on the number of simultaneous requests that will be
132+; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
133+; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
134+; CGI.
135+; Note: Used when pm is set to either 'static' or 'dynamic'
136+; Note: This value is mandatory.
137+pm.max_children = 50
138+
139+; The number of child processes created on startup.
140+; Note: Used only when pm is set to 'dynamic'
141+; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
142+;pm.start_servers = 20
143+
144+; The desired minimum number of idle server processes.
145+; Note: Used only when pm is set to 'dynamic'
146+; Note: Mandatory when pm is set to 'dynamic'
147+;pm.min_spare_servers = 5
148+
149+; The desired maximum number of idle server processes.
150+; Note: Used only when pm is set to 'dynamic'
151+; Note: Mandatory when pm is set to 'dynamic'
152+;pm.max_spare_servers = 35
153+
154+; The number of requests each child process should execute before respawning.
155+; This can be useful to work around memory leaks in 3rd party libraries. For
156+; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
157+; Default Value: 0
158+;pm.max_requests = 500
159+
160+; The URI to view the FPM status page. If this value is not set, no URI will be
161+; recognized as a status page. By default, the status page shows the following
162+; information:
163+; accepted conn - the number of request accepted by the pool;
164+; pool - the name of the pool;
165+; process manager - static or dynamic;
166+; idle processes - the number of idle processes;
167+; active processes - the number of active processes;
168+; total processes - the number of idle + active processes.
169+; The values of 'idle processes', 'active processes' and 'total processes' are
170+; updated each second. The value of 'accepted conn' is updated in real time.
171+; Example output:
172+; accepted conn: 12073
173+; pool: www
174+; process manager: static
175+; idle processes: 35
176+; active processes: 65
177+; total processes: 100
178+; By default the status page output is formatted as text/plain. Passing either
179+; 'html' or 'json' as a query string will return the corresponding output
180+; syntax. Example:
181+; http://www.foo.bar/status
182+; http://www.foo.bar/status?json
183+; http://www.foo.bar/status?html
184+; Note: The value must start with a leading slash (/). The value can be
185+; anything, but it may not be a good idea to use the .php extension or it
186+; may conflict with a real PHP file.
187+; Default Value: not set
188+;pm.status_path = /status
189+
190+; The ping URI to call the monitoring page of FPM. If this value is not set, no
191+; URI will be recognized as a ping page. This could be used to test from outside
192+; that FPM is alive and responding, or to
193+; - create a graph of FPM availability (rrd or such);
194+; - remove a server from a group if it is not responding (load balancing);
195+; - trigger alerts for the operating team (24/7).
196+; Note: The value must start with a leading slash (/). The value can be
197+; anything, but it may not be a good idea to use the .php extension or it
198+; may conflict with a real PHP file.
199+; Default Value: not set
200+;ping.path = /ping
201+
202+; This directive may be used to customize the response of a ping request. The
203+; response is formatted as text/plain with a 200 response code.
204+; Default Value: pong
205+;ping.response = pong
206+
207+; The timeout for serving a single request after which the worker process will
208+; be killed. This option should be used when the 'max_execution_time' ini option
209+; does not stop script execution for some reason. A value of '0' means 'off'.
210+; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
211+; Default Value: 0
212+;request_terminate_timeout = 0
213+
214+; The timeout for serving a single request after which a PHP backtrace will be
215+; dumped to the 'slowlog' file. A value of '0s' means 'off'.
216+; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
217+; Default Value: 0
218+;request_slowlog_timeout = 0
219+
220+; The log file for slow requests
221+; Default Value: /var/log/php-fpm.log.slow
222+;slowlog = /var/log/php-fpm.log.slow
223+
224+; Set open file descriptor rlimit.
225+; Default Value: system defined value
226+;rlimit_files = 1024
227+
228+; Set max core size rlimit.
229+; Possible Values: 'unlimited' or an integer greater or equal to 0
230+; Default Value: system defined value
231+;rlimit_core = 0
232+
233+; Chroot to this directory at the start. This value must be defined as an
234+; absolute path. When this value is not set, chroot is not used.
235+; Note: chrooting is a great security feature and should be used whenever
236+; possible. However, all PHP paths will be relative to the chroot
237+; (error_log, sessions.save_path, ...).
238+; Default Value: not set
239+;chroot =
240+
241+; Chdir to this directory at the start. This value must be an absolute path.
242+; Default Value: current directory or / when chroot
243+;chdir = /var/www
244+
245+; Redirect worker stdout and stderr into main error log. If not set, stdout and
246+; stderr will be redirected to /dev/null according to FastCGI specs.
247+; Default Value: no
248+;catch_workers_output = yes
249+
250+; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
251+; the current environment.
252+; Default Value: clean env
253+;env[HOSTNAME] = $HOSTNAME
254+;env[PATH] = /usr/local/bin:/usr/bin:/bin
255+;env[TMP] = /tmp
256+;env[TMPDIR] = /tmp
257+;env[TEMP] = /tmp
258+
259+; Additional php.ini defines, specific to this pool of workers. These settings
260+; overwrite the values previously defined in the php.ini. The directives are the
261+; same as the PHP SAPI:
262+; php_value/php_flag - you can set classic ini defines which can
263+; be overwritten from PHP call 'ini_set'.
264+; php_admin_value/php_admin_flag - these directives won't be overwritten by
265+; PHP call 'ini_set'
266+; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
267+
268+; Defining 'extension' will load the corresponding shared extension from
269+; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
270+; overwrite previously defined php.ini values, but will append the new value
271+; instead.
272+
273+; Default Value: nothing is defined by default except the values in php.ini and
274+; specified at startup with the -d argument
275+;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
276+;php_flag[display_errors] = off
277+;php_admin_value[error_log] = /var/log/fpm-php.www.log
278+;php_admin_flag[log_errors] = on
279+;php_admin_value[memory_limit] = 32M
280
281=== added file 'SOURCES/php-fpm.initd'
282--- SOURCES/php-fpm.initd 1970-01-01 00:00:00 +0000
283+++ SOURCES/php-fpm.initd 2010-07-15 11:09:43 +0000
284@@ -0,0 +1,140 @@
285+#! /bin/sh
286+
287+### BEGIN INIT INFO
288+# Provides: php-fpm
289+# Required-Start: $local_fs $remote_fs $network $named
290+# Required-Stop: $local_fs $remote_fs $network
291+# Required-Start: $all
292+# Required-Stop: $all
293+# Default-Start: 3 5
294+# Default-Stop: 0 1 6
295+# Short-Description: starts php-fpm
296+# Description: starts the PHP FastCGI Process Manager daemon
297+### END INIT INFO
298+
299+prefix=/usr
300+exec_prefix=/usr
301+
302+php_fpm_BIN=/usr/sbin/php-fpm
303+php_fpm_CONF=/etc/php-fpm.conf
304+php_fpm_PID=/var/run/php-fpm.pid
305+
306+
307+php_opts="--fpm-config $php_fpm_CONF"
308+
309+
310+wait_for_pid () {
311+ try=0
312+
313+ while test $try -lt 35 ; do
314+
315+ case "$1" in
316+ 'created')
317+ if [ -f "$2" ] ; then
318+ try=''
319+ break
320+ fi
321+ ;;
322+
323+ 'removed')
324+ if [ ! -f "$2" ] ; then
325+ try=''
326+ break
327+ fi
328+ ;;
329+ esac
330+
331+ echo -n .
332+ try=`expr $try + 1`
333+ sleep 1
334+
335+ done
336+
337+}
338+
339+case "$1" in
340+ start)
341+ echo -n "Starting php-fpm "
342+
343+ $php_fpm_BIN $php_opts
344+
345+ if [ "$?" != 0 ] ; then
346+ echo " failed"
347+ exit 1
348+ fi
349+
350+ wait_for_pid created $php_fpm_PID
351+
352+ if [ -n "$try" ] ; then
353+ echo " failed"
354+ exit 1
355+ else
356+ echo " done"
357+ fi
358+ ;;
359+
360+ stop)
361+ echo -n "Gracefully shutting down php-fpm "
362+
363+ if [ ! -r $php_fpm_PID ] ; then
364+ echo "warning, no pid file found - php-fpm is not running ?"
365+ exit 1
366+ fi
367+
368+ kill -QUIT `cat $php_fpm_PID`
369+
370+ wait_for_pid removed $php_fpm_PID
371+
372+ if [ -n "$try" ] ; then
373+ echo " failed. Use force-exit"
374+ exit 1
375+ else
376+ echo " done"
377+ fi
378+ ;;
379+
380+ force-quit)
381+ echo -n "Terminating php-fpm "
382+
383+ if [ ! -r $php_fpm_PID ] ; then
384+ echo "warning, no pid file found - php-fpm is not running ?"
385+ exit 1
386+ fi
387+
388+ kill -TERM `cat $php_fpm_PID`
389+
390+ wait_for_pid removed $php_fpm_PID
391+
392+ if [ -n "$try" ] ; then
393+ echo " failed"
394+ exit 1
395+ else
396+ echo " done"
397+ fi
398+ ;;
399+
400+ restart)
401+ $0 stop
402+ $0 start
403+ ;;
404+
405+ reload)
406+
407+ echo -n "Reload service php-fpm "
408+
409+ if [ ! -r $php_fpm_PID ] ; then
410+ echo "warning, no pid file found - php-fpm is not running ?"
411+ exit 1
412+ fi
413+
414+ kill -USR2 `cat $php_fpm_PID`
415+
416+ echo " done"
417+ ;;
418+
419+ *)
420+ echo "Usage: $0 {start|stop|force-quit|restart|reload}"
421+ exit 1
422+ ;;
423+
424+esac
425
426=== modified file 'SPECS/php53.spec'
427--- SPECS/php53.spec 2010-06-15 10:22:24 +0000
428+++ SPECS/php53.spec 2010-07-15 11:09:43 +0000
429@@ -36,7 +36,7 @@
430 Summary: The PHP HTML-embedded scripting language. (PHP: Hypertext Preprocessor)
431 Name: %{name}
432 Version: 5.3.2
433-Release: 6.ius%{?dist}
434+Release: 7.ius%{?dist}
435 License: The PHP License v3.01
436 Group: Development/Languages
437 Vendor: IUS Community Project
438@@ -48,6 +48,9 @@
439 Source3: macros.php
440 Source4: macros.pear
441 Source5: README.psa-compat
442+Source6: fpm_svn_r300604.tar.gz
443+Source7: php-fpm.conf
444+Source8: php-fpm.initd
445
446 Patch1: php-5.2.4-gnusrc.patch
447 Patch2: php-5.3.2-install.patch
448@@ -72,7 +75,6 @@
449 BuildRequires: apr-devel, elfutils-libelf-devel, apr-util-devel
450 BuildRequires: t1lib-devel, pcre-devel >= 6.6
451 BuildRequires: libtool-ltdl-devel, e2fsprogs-devel
452-
453 # Enforce Apache module ABI compatibility
454 Requires: httpd-mmn = %{httpd_mmn}
455 Requires: file >= 3.39
456@@ -458,6 +460,21 @@
457 support to PHP using system interfaces for inter-process
458 communication.
459
460+%if 0%{?_with_fpm}
461+%package fpm
462+Summary: Alternative PHP FastCGI implementation
463+Group: Development/Languages
464+Provides: %{real_name}-fpm = %{version}-%{release}
465+Requires: %{name} = %{version}-%{release}
466+BuildRequires: libevent-devel
467+
468+%description fpm
469+PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI
470+implementation with some additional features useful for sites
471+of any size, especially busier sites.
472+
473+%endif
474+
475 # Optional module support
476
477 %if 0%{?_with_embedded}
478@@ -544,6 +561,10 @@
479 %setup -q -n %{real_name}-%{version}
480 cp -a %SOURCE5 . # README.psa-compat
481
482+%if 0%{?_with_fpm}
483+tar -xvzf %SOURCE6
484+%endif
485+
486 %patch2 -p1 -b .install
487 %patch6 -p1 -b .embed
488 %patch7 -p1 -b .recode
489@@ -565,7 +586,10 @@
490 cp ext/ereg/regex/COPYRIGHT regex_COPYRIGHT
491
492 # Multiple builds for multiple SAPIs
493-mkdir build-cgi build-apache build-embedded build-zts
494+mkdir build-cgi build-apache build-embedded build-zts
495+%if 0%{?_with_fpm}
496+mkdir build-fpm
497+%endif
498
499 # Remove bogus test; position of read position after fopen(, "a+")
500 # is not defined by C standard, so don't presume anything.
501@@ -629,6 +653,7 @@
502 libtoolize --force --copy
503 cat `aclocal --print-ac-dir`/libtool.m4 > build/libtool.m4
504
505+
506 # Regenerate configure scripts (patches change config.m4's)
507 ./buildconf --force
508
509@@ -762,6 +787,15 @@
510 build --with-apxs2=%{_sbindir}/apxs %{without_shared}
511 popd
512
513+%if 0%{?_with_fpm}
514+#build fpm
515+pushd build-fpm
516+build --enable-fpm
517+#cp ../sapi/fpm/LICENSE ../sapi/fpm/FPM_LICENSE
518+#cp ../sapi/fpm/CREDITS ../sapi/fpm/FPM_CREDITS
519+popd
520+%endif
521+
522 %if 0%{?_with_embedded:1}
523 # Build for inclusion as embedded script language into applications,
524 # /usr/lib[64]/libphp5.so
525@@ -805,11 +839,26 @@
526 %install
527 [ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
528
529+%if 0%{?_with_fpm}
530+#install php-fpm and create the folder in /etc
531+pushd build-fpm
532+make install INSTALL_ROOT=%{buildroot}
533+cp -a %SOURCE7 $RPM_BUILD_ROOT%{_sysconfdir}/php-fpm.conf
534+rm $RPM_BUILD_ROOT%{_sysconfdir}/php-fpm.conf.default
535+install -m 755 -d %{buildroot}%{_sysconfdir}/fpm.d
536+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/init.d/
537+install -m 755 %SOURCE8 $RPM_BUILD_ROOT%{_sysconfdir}/init.d/php-fpmd
538+popd
539+#cp sapi/fpm/LICENSE $RPM_BUILD_ROOT/fpm_LICENSE
540+#cp sapi/fpm/CREDITS $RPM_BUILD_ROOT/fpm_CREDITS
541+%endif
542+
543 # Install the version for embedded script language in applications + php_embed.h
544 %if 0%{?_with_embedded}
545 make -C build-embedded install-sapi install-headers INSTALL_ROOT=%{buildroot}
546 %endif
547
548+
549 # Install everything from the CGI SAPI build
550 pushd build-cgi
551 make install INSTALL_ROOT=%{buildroot}
552@@ -930,6 +979,14 @@
553 %postun embedded -p /sbin/ldconfig
554 %endif
555
556+%if 0%{?_with_fpm}
557+%post fpm
558+chkconfig --add php-fpmd
559+%preun fpm
560+chkconfig --del php-fpmd
561+%endif
562+
563+
564 %if 0%{?_with_psa}
565 %post psa-compat
566 mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e 'update Components set
567@@ -961,6 +1018,7 @@
568 %{_bindir}/php-cgi
569 %{_mandir}/man1/php.1*
570
571+
572 %files devel
573 %defattr(-,root,root)
574 %{_bindir}/php-config
575@@ -971,6 +1029,18 @@
576 %{_mandir}/man1/phpize.1*
577 %config %{_sysconfdir}/rpm/macros.php
578
579+%if 0%{?_with_fpm}
580+%files fpm
581+%defattr(-,root,root)
582+%config %{_sysconfdir}/php-fpm.conf
583+%{_sbindir}/php-fpm
584+%{_mandir}/man1/php-fpm.1.gz
585+%{_sysconfdir}/fpm.d
586+%{_sysconfdir}/init.d/php-fpmd
587+%doc sapi/fpm/CREDITS
588+%doc sapi/fpm/LICENSE
589+%endif
590+
591 %files pgsql -f files.pgsql
592 %files mysql -f files.mysql
593 %files odbc -f files.odbc

Subscribers

People subscribed via source and target branches

to all changes: