Skip to contentSkip to conversation

php.ini: set date.timezone to UTC

PATCH New Floris Bos 4 participants 18 messages May 1, 2015 – May 2, 2015

lore
Share & tools
lore

Floris Bos

author
#0 lore raw

PATCH 1/1 php.ini: set date.timezone to UTC

Prevent a warning being logged each time a PHP date/time method is used by setting UTC as (default) timezone in php.ini

---
 package/php/php.mk | 1 +
 1 file changed, 1 insertion(+)
package/php/php.mk +1 -0
index 3b9a117..7bd3f63 100644
@@ -288,6 +288,7 @@ define PHP_INSTALL_FIXUP
 	rm -f $(TARGET_DIR)/usr/bin/phpize
 	$(INSTALL) -D -m 0755 $(PHP_DIR)/php.ini-production \
 		$(TARGET_DIR)/etc/php.ini
+	$(SED) 's/;date.timezone =/date.timezone = UTC/' $(TARGET_DIR)/etc/php.ini
 endef
 
 PHP_POST_INSTALL_TARGET_HOOKS += PHP_INSTALL_FIXUP
Signature · 1 line
2.1.4
author
#1 lore raw

PATCH v2 1/3 php: fpm sapi: install startup script

Install the startup script if using the FastCGI Process Manager.

---
v2: add systemd support

---
 package/php/0006-fix-php-fpm.service.in.patch | 35 +++++++++++++++++++++++++++
 package/php/php.mk                            | 15 ++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 package/php/0006-fix-php-fpm.service.in.patch
package/php/0006-fix-php-fpm.service.in.patch new file +35 -0
new file mode 100644
index 0000000..a182a25
@@ -0,0 +1,35 @@
+From bb19125781c0794da9a63fee62e263ff4efff661 Mon Sep 17 00:00:00 2001
+From: Floris Bos <[email protected]>
+Date: Fri, 1 May 2015 15:28:55 +0200
+Subject: [PATCH] Fix php-fpm.service.in
+
+- Expand file paths.
+- Remove obsolete After=syslog.target. Syslog is socket activated nowadays.
+
+Signed-off-by: Floris Bos <[email protected]>
+---
+ sapi/fpm/php-fpm.service.in | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/sapi/fpm/php-fpm.service.in b/sapi/fpm/php-fpm.service.in
+index a2df30e..c135f04 100644
+--- a/sapi/fpm/php-fpm.service.in
++++ b/sapi/fpm/php-fpm.service.in
+@@ -1,11 +1,11 @@
+ [Unit]
+ Description=The PHP FastCGI Process Manager
+-After=syslog.target network.target
++After=network.target
+ 
+ [Service]
+ Type=@php_fpm_systemd@
+-PIDFile=@localstatedir@/run/php-fpm.pid
+-ExecStart=@sbindir@/php-fpm --nodaemonize --fpm-config @sysconfdir@/php-fpm.conf
++PIDFile=@EXPANDED_LOCALSTATEDIR@/run/php-fpm.pid
++ExecStart=@EXPANDED_SBINDIR@/php-fpm --nodaemonize --fpm-config @EXPANDED_SYSCONFDIR@/php-fpm.conf
+ ExecReload=/bin/kill -USR2 $MAINPID
+ 
+ [Install]
+-- 
+2.1.4
+
package/php/php.mk +15 -0
index e4331f2..4c65c35 100644
@@ -251,6 +251,21 @@ PHP_CONF_OPTS += \
 PHP_DEPENDENCIES += jpeg libpng freetype
 endif
 
+ifeq ($(BR2_PACKAGE_PHP_FPM),y)
+define PHP_INSTALL_INIT_SYSV
+	$(INSTALL) -D -m 0755 $(@D)/sapi/fpm/init.d.php-fpm \
+		$(TARGET_DIR)/etc/init.d/S49php-fpm
+endef
+
+define PHP_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -D -m 0644 $(@D)/sapi/fpm/php-fpm.service \
+		$(TARGET_DIR)/usr/lib/systemd/system/php-fpm.service
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+	ln -fs ../../../../usr/lib/systemd/system/php-fpm.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/php-fpm.service
+endef
+endif
+
 define PHP_EXTENSIONS_FIXUP
 	$(SED) "/prefix/ s:/usr:$(STAGING_DIR)/usr:" \
 		$(STAGING_DIR)/usr/bin/phpize
Signature · 1 line
2.1.4
#2 lore raw

PATCH v2 1/3 php: fpm sapi: install startup script

Quoted 18 lines · Floris Bos

Install the startup script if using the FastCGI Process Manager.

---
v2: add systemd support

---
 package/php/0006-fix-php-fpm.service.in.patch | 35 +++++++++++++++++++++++++++
 package/php/php.mk                            | 15 ++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 package/php/0006-fix-php-fpm.service.in.patch
package/php/0006-fix-php-fpm.service.in.patch new file +0 -0
new file mode 100644
index 0000000..a182a25

package/php/0006-fix-php-fpm.service.in.patch line 7

Quoted 7 lines
package/php/0006-fix-php-fpm.service.in.patch new file +7 -0
@@ -0,0 +1,35 @@
+From bb19125781c0794da9a63fee62e263ff4efff661 Mon Sep 17 00:00:00 2001
+From: Floris Bos <[email protected]>
+Date: Fri, 1 May 2015 15:28:55 +0200
+Subject: [PATCH] Fix php-fpm.service.in
+
+- Expand file paths.
+- Remove obsolete After=syslog.target. Syslog is socket activated nowadays.

Well, we do have a unit file for rsyslogd...

Will you submit this patch upstream?

Quoted 5 lines
package/php/0006-fix-php-fpm.service.in.patch new file +5 -0
+
+Signed-off-by: Floris Bos <[email protected]>
+---
+ sapi/fpm/php-fpm.service.in | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)

package/php/0006-fix-php-fpm.service.in.patch line 22

Quoted 10 lines
package/php/0006-fix-php-fpm.service.in.patch new file +10 -0
+
+diff --git a/sapi/fpm/php-fpm.service.in b/sapi/fpm/php-fpm.service.in
+index a2df30e..c135f04 100644
+--- a/sapi/fpm/php-fpm.service.in
++++ b/sapi/fpm/php-fpm.service.in
+@@ -1,11 +1,11 @@
+ [Unit]
+ Description=The PHP FastCGI Process Manager
+-After=syslog.target network.target
++After=network.target

I actually don't see why this is needed. If no syslog.target is defined, then
it will be ignored (at least that's what I understand from the systemd documentation [1]).

Regards,
Arnout

package/php/0006-fix-php-fpm.service.in.patch line 34

Quoted 12 lines
package/php/0006-fix-php-fpm.service.in.patch new file +12 -0
+ 
+ [Service]
+ Type=@php_fpm_systemd@
+-PIDFile=@localstatedir@/run/php-fpm.pid
+-ExecStart=@sbindir@/php-fpm --nodaemonize --fpm-config @sysconfdir@/php-fpm.conf
++PIDFile=@EXPANDED_LOCALSTATEDIR@/run/php-fpm.pid
++ExecStart=@EXPANDED_SBINDIR@/php-fpm --nodaemonize --fpm-config @EXPANDED_SYSCONFDIR@/php-fpm.conf
+ ExecReload=/bin/kill -USR2 $MAINPID
+ 
+ [Install]
+-- 
+2.1.4

[snip]

[1] http://www.freedesktop.org/software/systemd/man/systemd.unit.html

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
author
#3 lore raw

PATCH v2 1/3 php: fpm sapi: install startup script

Hi,

Quoted 3 lines · Arnout Vandecappelle
+- Expand file paths.
+- Remove obsolete After=syslog.target. Syslog is socket activated nowadays.

Well, we do have a unit file for rsyslogd...

Other distros consider it obsolete, and told their maintainers to remove syslog.target last year.

http://lists.opensuse.org/archive/opensuse-packaging/2013-05/msg00102.html
https://lintian.debian.org/tags/systemd-service-file-refers-to-obsolete-target.html

Quoted 1 line

Will you submit this patch upstream?

Did submit a simple pull request to php-src github earlier today. But do not plan to chase it.

Yours sincerely,

Floris Bos

#4 lore raw

PATCH v2 1/3 php: fpm sapi: install startup script

Quoted 7 lines · Floris Bos

Hi,

Quoted 3 lines · Arnout Vandecappelle
+- Expand file paths.
+- Remove obsolete After=syslog.target. Syslog is socket activated nowadays.

Well, we do have a unit file for rsyslogd...

Quoted 5 lines

Other distros consider it obsolete, and told their maintainers to remove syslog.target last year.

http://lists.opensuse.org/archive/opensuse-packaging/2013-05/msg00102.html
https://lintian.debian.org/tags/systemd-service-file-refers-to-obsolete-target.html

Ah OK I get it now.

Thanks,
Arnout

Quoted 11 lines
Quoted 2 lines

Will you submit this patch upstream?

Did submit a simple pull request to php-src github earlier today. But do not plan to chase it.

Yours sincerely,

Floris Bos

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#5 lore raw

PATCH v2 1/3 php: fpm sapi: install startup script

In reply to Floris Bos
Quoted 3 lines · Floris Bos

Install the startup script if using the FastCGI Process Manager.

(after Floris' further explanation).

Regards,
Arnout

Quoted 77 lines

---
v2: add systemd support

---
 package/php/0006-fix-php-fpm.service.in.patch | 35 +++++++++++++++++++++++++++
 package/php/php.mk                            | 15 ++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 package/php/0006-fix-php-fpm.service.in.patch
package/php/0006-fix-php-fpm.service.in.patch new file +35 -0
new file mode 100644
index 0000000..a182a25
@@ -0,0 +1,35 @@
+From bb19125781c0794da9a63fee62e263ff4efff661 Mon Sep 17 00:00:00 2001
+From: Floris Bos <[email protected]>
+Date: Fri, 1 May 2015 15:28:55 +0200
+Subject: [PATCH] Fix php-fpm.service.in
+
+- Expand file paths.
+- Remove obsolete After=syslog.target. Syslog is socket activated nowadays.
+
+Signed-off-by: Floris Bos <[email protected]>
+---
+ sapi/fpm/php-fpm.service.in | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/sapi/fpm/php-fpm.service.in b/sapi/fpm/php-fpm.service.in
+index a2df30e..c135f04 100644
+--- a/sapi/fpm/php-fpm.service.in
++++ b/sapi/fpm/php-fpm.service.in
+@@ -1,11 +1,11 @@
+ [Unit]
+ Description=The PHP FastCGI Process Manager
+-After=syslog.target network.target
++After=network.target
+ 
+ [Service]
+ Type=@php_fpm_systemd@
+-PIDFile=@localstatedir@/run/php-fpm.pid
+-ExecStart=@sbindir@/php-fpm --nodaemonize --fpm-config @sysconfdir@/php-fpm.conf
++PIDFile=@EXPANDED_LOCALSTATEDIR@/run/php-fpm.pid
++ExecStart=@EXPANDED_SBINDIR@/php-fpm --nodaemonize --fpm-config @EXPANDED_SYSCONFDIR@/php-fpm.conf
+ ExecReload=/bin/kill -USR2 $MAINPID
+ 
+ [Install]
+-- 
+2.1.4
+
package/php/php.mk +15 -0
index e4331f2..4c65c35 100644
@@ -251,6 +251,21 @@ PHP_CONF_OPTS += \
 PHP_DEPENDENCIES += jpeg libpng freetype
 endif
 
+ifeq ($(BR2_PACKAGE_PHP_FPM),y)
+define PHP_INSTALL_INIT_SYSV
+	$(INSTALL) -D -m 0755 $(@D)/sapi/fpm/init.d.php-fpm \
+		$(TARGET_DIR)/etc/init.d/S49php-fpm
+endef
+
+define PHP_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -D -m 0644 $(@D)/sapi/fpm/php-fpm.service \
+		$(TARGET_DIR)/usr/lib/systemd/system/php-fpm.service
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+	ln -fs ../../../../usr/lib/systemd/system/php-fpm.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/php-fpm.service
+endef
+endif
+
 define PHP_EXTENSIONS_FIXUP
 	$(SED) "/prefix/ s:/usr:$(STAGING_DIR)/usr:" \
 		$(STAGING_DIR)/usr/bin/phpize
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#6 lore raw

PATCH v2 1/3 php: fpm sapi: install startup script

In reply to Floris Bos

Dear Floris Bos,

Quoted 11 lines · Floris Bos

Install the startup script if using the FastCGI Process Manager.

---
v2: add systemd support

---
 package/php/0006-fix-php-fpm.service.in.patch | 35 +++++++++++++++++++++++++++
 package/php/php.mk                            | 15 ++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 package/php/0006-fix-php-fpm.service.in.patch

Applied, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
author
#7 lore raw

PATCH v2 2/3 php: fpm sapi: install php-fpm.conf

In reply to Floris Bos

Install a custom php-fpm.conf instead of the stock one.

- Listening on /var/run/php-fpm.sock instead of TCP port so we can restrict access to webserver user www-data.
- Using ondemand pm, so PHP children are only started after a PHP request, instead of kept resident all the time.

---
v2: limit children to 5 by default

---
 package/php/php-fpm.conf | 14 ++++++++++++++
 package/php/php.mk       |  8 ++++++++
 2 files changed, 22 insertions(+)
 create mode 100644 package/php/php-fpm.conf
package/php/php-fpm.conf new file +14 -0
new file mode 100644
index 0000000..b75a58f
@@ -0,0 +1,14 @@
+[www]
+# Only start children when there are requests to be processed
+pm = ondemand
+# Terminate them again after there haven't been any for 2 minutes
+pm.process_idle_timeout = 120s
+# Maximum number of children processing PHP requests concurrently
+pm.max_children = 5
+
+listen = /var/run/php-fpm.sock
+listen.owner = www-data
+listen.group = www-data
+user = www-data
+group = www-data
+
package/php/php.mk +8 -0
index 4c65c35..3b9a117 100644
@@ -264,6 +264,14 @@ define PHP_INSTALL_INIT_SYSTEMD
 	ln -fs ../../../../usr/lib/systemd/system/php-fpm.service \
 		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/php-fpm.service
 endef
+
+define PHP_INSTALL_FPM_CONF
+	$(INSTALL) -D -m 0644 package/php/php-fpm.conf \
+		$(TARGET_DIR)/etc/php-fpm.conf
+	rm -f $(TARGET_DIR)/etc/php-fpm.conf.default
+endef
+
+PHP_POST_INSTALL_TARGET_HOOKS += PHP_INSTALL_FPM_CONF
 endif
 
 define PHP_EXTENSIONS_FIXUP
Signature · 1 line
2.1.4
#8 lore raw

PATCH v2 2/3 php: fpm sapi: install php-fpm.conf

Quoted 8 lines · Floris Bos

Install a custom php-fpm.conf instead of the stock one.

- Listening on /var/run/php-fpm.sock instead of TCP port so we can restrict access to webserver user www-data.
- Using ondemand pm, so PHP children are only started after a PHP request, instead of kept resident all the time.

Quoted 3 lines

---
v2: limit children to 5 by default

And split it into two patches :-)

Regards,
Arnout

Quoted 46 lines
---
 package/php/php-fpm.conf | 14 ++++++++++++++
 package/php/php.mk       |  8 ++++++++
 2 files changed, 22 insertions(+)
 create mode 100644 package/php/php-fpm.conf
package/php/php-fpm.conf new file +14 -0
new file mode 100644
index 0000000..b75a58f
@@ -0,0 +1,14 @@
+[www]
+# Only start children when there are requests to be processed
+pm = ondemand
+# Terminate them again after there haven't been any for 2 minutes
+pm.process_idle_timeout = 120s
+# Maximum number of children processing PHP requests concurrently
+pm.max_children = 5
+
+listen = /var/run/php-fpm.sock
+listen.owner = www-data
+listen.group = www-data
+user = www-data
+group = www-data
+
package/php/php.mk +8 -0
index 4c65c35..3b9a117 100644
@@ -264,6 +264,14 @@ define PHP_INSTALL_INIT_SYSTEMD
 	ln -fs ../../../../usr/lib/systemd/system/php-fpm.service \
 		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/php-fpm.service
 endef
+
+define PHP_INSTALL_FPM_CONF
+	$(INSTALL) -D -m 0644 package/php/php-fpm.conf \
+		$(TARGET_DIR)/etc/php-fpm.conf
+	rm -f $(TARGET_DIR)/etc/php-fpm.conf.default
+endef
+
+PHP_POST_INSTALL_TARGET_HOOKS += PHP_INSTALL_FPM_CONF
 endif
 
 define PHP_EXTENSIONS_FIXUP
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#9 lore raw

PATCH v2 2/3 php: fpm sapi: install php-fpm.conf

In reply to Floris Bos

Dear Floris Bos,

Quoted 9 lines · Floris Bos

Install a custom php-fpm.conf instead of the stock one.

- Listening on /var/run/php-fpm.sock instead of TCP port so we can restrict access to webserver user www-data.
- Using ondemand pm, so PHP children are only started after a PHP request, instead of kept resident all the time.

Quoted 7 lines

---
v2: limit children to 5 by default

---
 package/php/php-fpm.conf | 14 ++++++++++++++
 package/php/php.mk       |  8 ++++++++
 2 files changed, 22 insertions(+)
 create mode 100644 package/php/php-fpm.conf

Applied, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
author
#10 lore raw

PATCH v2 3/3 lighttpd: add option to enable php-fpm configuration

In reply to Floris Bos

If both lighttpd and php-fpm are selected, offer to enable PHP in the lighttpd configuration.

---
 package/lighttpd/Config.in    | 20 ++++++++++++++++++++
 package/lighttpd/fastcgi.conf |  2 ++
 package/lighttpd/lighttpd.mk  | 11 +++++++++++
 3 files changed, 33 insertions(+)
 create mode 100644 package/lighttpd/fastcgi.conf
package/lighttpd/Config.in +20 -0
index 2c101e7..e984ef8 100644
@@ -56,4 +56,24 @@ config BR2_PACKAGE_LIGHTTPD_LUA
 	help
 	  Enable Lua support. Needed to support mod_magnet
 
+config BR2_PACKAGE_LIGHTTPD_PHP_FPM
+	bool "enable php in configuration"
+	depends on BR2_PACKAGE_PHP
+	depends on BR2_PACKAGE_PHP_FPM
+	default "y"
+	help
+	  Configure lighttpd to handle PHP requests through php-fpm.
+
+	  Also enables allow-x-send-file, allowing you to offload static file sending
+	  to lighttpd with PHP code like:
+
+	  header("X-Send-File: /path/to/file");
+
+	  This is a necessity for letting the user download larger files, as
+	  lighttpd buffers all PHP script output infinitely to memory, and
+	  may run out if you use the normal readfile() method to output files.
+
+comment "php support depends on php with FPM sapi"
+	depends on !BR2_PACKAGE_PHP || !BR2_PACKAGE_PHP_FPM
+
 endif
package/lighttpd/fastcgi.conf new file +2 -0
new file mode 100644
index 0000000..46c5f9a
@@ -0,0 +1,2 @@
+server.modules += ( "mod_fastcgi" )
+fastcgi.server  = ( ".php" => (( "socket" => "/var/run/php-fpm.sock", "allow-x-send-file" => "enable" )) )
package/lighttpd/lighttpd.mk +11 -0
index 626cd69..16ca88b 100644
@@ -77,6 +77,17 @@ endef
 
 LIGHTTPD_POST_INSTALL_TARGET_HOOKS += LIGHTTPD_INSTALL_CONFIG
 
+ifeq ($(BR2_PACKAGE_LIGHTTPD_PHP_FPM),y)
+define LIGHTTPD_INSTALL_FASTCGI_CONFIG
+	$(INSTALL) -D -m 0644 package/lighttpd/fastcgi.conf \
+		$(TARGET_DIR)/etc/lighttpd/conf.d/fastcgi.conf
+	$(SED) '/#include \"conf.d\/fastcgi.conf\"/s/^#//' \
+		$(TARGET_DIR)/etc/lighttpd/modules.conf
+endef
+
+LIGHTTPD_POST_INSTALL_TARGET_HOOKS += LIGHTTPD_INSTALL_FASTCGI_CONFIG
+endif
+
 define LIGHTTPD_INSTALL_INIT_SYSV
 	$(INSTALL) -D -m 0755 package/lighttpd/S50lighttpd \
 		$(TARGET_DIR)/etc/init.d/S50lighttpd
Signature · 1 line
2.1.4
#11 lore raw

PATCH v2 3/3 lighttpd: add option to enable php-fpm configuration

Quoted 16 lines · Floris Bos

If both lighttpd and php-fpm are selected, offer to enable PHP in the lighttpd configuration.

---
 package/lighttpd/Config.in    | 20 ++++++++++++++++++++
 package/lighttpd/fastcgi.conf |  2 ++
 package/lighttpd/lighttpd.mk  | 11 +++++++++++
 3 files changed, 33 insertions(+)
 create mode 100644 package/lighttpd/fastcgi.conf
package/lighttpd/Config.in +0 -0
index 2c101e7..e984ef8 100644

package/lighttpd/Config.in config BR2_PACKAGE_LIGHTTPD_LUA · line 61

Quoted 6 lines
package/lighttpd/Config.in +3 -0
@@ -56,4 +56,24 @@ config BR2_PACKAGE_LIGHTTPD_LUA
 	help
 	  Enable Lua support. Needed to support mod_magnet
 
+config BR2_PACKAGE_LIGHTTPD_PHP_FPM
+	bool "enable php in configuration"
+	depends on BR2_PACKAGE_PHP

This is unneeded (implied by the one below)

package/lighttpd/Config.in config BR2_PACKAGE_LIGHTTPD_LUA · line 63

Quoted 2 lines
package/lighttpd/Config.in +2 -0
+	depends on BR2_PACKAGE_PHP_FPM
+	default "y"

We don't put "" around y

package/lighttpd/Config.in config BR2_PACKAGE_LIGHTTPD_LUA · line 67

Quoted 4 lines
package/lighttpd/Config.in +4 -0
+	help
+	  Configure lighttpd to handle PHP requests through php-fpm.
+
+	  Also enables allow-x-send-file, allowing you to offload static file sending

This line is too long

package/lighttpd/Config.in config BR2_PACKAGE_LIGHTTPD_LUA · line 77

Quoted 10 lines
package/lighttpd/Config.in +10 -0
+	  to lighttpd with PHP code like:
+
+	  header("X-Send-File: /path/to/file");
+
+	  This is a necessity for letting the user download larger files, as
+	  lighttpd buffers all PHP script output infinitely to memory, and
+	  may run out if you use the normal readfile() method to output files.
+
+comment "php support depends on php with FPM sapi"
+	depends on !BR2_PACKAGE_PHP || !BR2_PACKAGE_PHP_FPM

And I'd make this

	depends on BR2_PACKAGE_PHP && !BR2_PACKAGE_PHP_FPM

The user will be smart enough to enable php if he needs is, so no comment needed for that. But he may not be smart enough to enable FPM. And FPM is part of a choice so you can't select it (well actually it's not really part of the choice so you can select it, but it would be a little weird to say the least).

Regards,
Arnout

Quoted 33 lines
package/lighttpd/Config.in +1 -0
+
 endif
package/lighttpd/fastcgi.conf new file +2 -0
new file mode 100644
index 0000000..46c5f9a
@@ -0,0 +1,2 @@
+server.modules += ( "mod_fastcgi" )
+fastcgi.server  = ( ".php" => (( "socket" => "/var/run/php-fpm.sock", "allow-x-send-file" => "enable" )) )
package/lighttpd/lighttpd.mk +11 -0
index 626cd69..16ca88b 100644
@@ -77,6 +77,17 @@ endef
 
 LIGHTTPD_POST_INSTALL_TARGET_HOOKS += LIGHTTPD_INSTALL_CONFIG
 
+ifeq ($(BR2_PACKAGE_LIGHTTPD_PHP_FPM),y)
+define LIGHTTPD_INSTALL_FASTCGI_CONFIG
+	$(INSTALL) -D -m 0644 package/lighttpd/fastcgi.conf \
+		$(TARGET_DIR)/etc/lighttpd/conf.d/fastcgi.conf
+	$(SED) '/#include \"conf.d\/fastcgi.conf\"/s/^#//' \
+		$(TARGET_DIR)/etc/lighttpd/modules.conf
+endef
+
+LIGHTTPD_POST_INSTALL_TARGET_HOOKS += LIGHTTPD_INSTALL_FASTCGI_CONFIG
+endif
+
 define LIGHTTPD_INSTALL_INIT_SYSV
 	$(INSTALL) -D -m 0755 package/lighttpd/S50lighttpd \
 		$(TARGET_DIR)/etc/init.d/S50lighttpd
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#12 lore raw

PATCH 1/1 php.ini: set date.timezone to UTC

In reply to Floris Bos
Quoted 13 lines · Floris Bos

Prevent a warning being logged each time a PHP date/time method is used by setting UTC as (default) timezone in php.ini

---
 package/php/php.mk | 1 +
 1 file changed, 1 insertion(+)
package/php/php.mk +0 -0
index 3b9a117..7bd3f63 100644

package/php/php.mk define PHP_INSTALL_FIXUP · line 291

Quoted 4 lines
package/php/php.mk +1 -0
@@ -288,6 +288,7 @@ define PHP_INSTALL_FIXUP
 	rm -f $(TARGET_DIR)/usr/bin/phpize
 	$(INSTALL) -D -m 0755 $(PHP_DIR)/php.ini-production \
 		$(TARGET_DIR)/etc/php.ini
+	$(SED) 's/;date.timezone =/date.timezone = UTC/' $(TARGET_DIR)/etc/php.ini

Would it be possible to use BR2_TARGET_LOCALTIME (if set) instead? Something like:

ifeq ($(BR2_TARGET_LOCALTIME),)
PHP_LOCALTIME = UTC
else
PHP_LOCALTIME = $(BR2_TARGET_LOCALTIME)
endif

	$(SED) 's%;date.timezone =.*%date.timezone = $(PHP_LOCALTIME)%' \
		$(TARGET_DIR)/etc/php.ini

That is, assuming that php can deal with complex timezones like Europe/Brussels.

Regards,
Arnout

Quoted 4 lines
package/php/php.mk +0 -0
 endef
 
 PHP_POST_INSTALL_TARGET_HOOKS += PHP_INSTALL_FIXUP
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
author
#13 lore raw

PATCH 1/1 php.ini: set date.timezone to UTC

Quoted 26 lines · Arnout Vandecappelle
Quoted 13 lines · Floris Bos

Prevent a warning being logged each time a PHP date/time method is used by setting UTC as (default) timezone in php.ini

---
  package/php/php.mk | 1 +
  1 file changed, 1 insertion(+)
package/php/php.mk +0 -0
index 3b9a117..7bd3f63 100644

package/php/php.mk define PHP_INSTALL_FIXUP · line 291

Quoted 4 lines
package/php/php.mk +1 -0
@@ -288,6 +288,7 @@ define PHP_INSTALL_FIXUP
  	rm -f $(TARGET_DIR)/usr/bin/phpize
  	$(INSTALL) -D -m 0755 $(PHP_DIR)/php.ini-production \
  		$(TARGET_DIR)/etc/php.ini
+	$(SED) 's/;date.timezone =/date.timezone = UTC/' $(TARGET_DIR)/etc/php.ini

Would it be possible to use BR2_TARGET_LOCALTIME (if set) instead? Something like:

ifeq ($(BR2_TARGET_LOCALTIME),)
PHP_LOCALTIME = UTC
else
PHP_LOCALTIME = $(BR2_TARGET_LOCALTIME)
endif

Quoted 4 lines
	$(SED) 's%;date.timezone =.*%date.timezone = $(PHP_LOCALTIME)%' \
		$(TARGET_DIR)/etc/php.ini

That is, assuming that php can deal with complex timezones like Europe/Brussels.

PHP used to use the system's time zone name automatically in older PHP versions.
But nowadays fills your log with warnings that is not reliable:

==
Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. ==

It certainly does work for common names like Europe/Brussels, but not sure if that goes for every zone name.

Yours sincerely,

Floris Bos

#14 lore raw

PATCH 1/1 php.ini: set date.timezone to UTC

Quoted 31 lines · Floris Bos
Quoted 30 lines · Arnout Vandecappelle
Quoted 13 lines · Floris Bos

Prevent a warning being logged each time a PHP date/time method is used by setting UTC as (default) timezone in php.ini

---
  package/php/php.mk | 1 +
  1 file changed, 1 insertion(+)
package/php/php.mk +0 -0
index 3b9a117..7bd3f63 100644

package/php/php.mk define PHP_INSTALL_FIXUP · line 291

Quoted 4 lines
package/php/php.mk +1 -0
@@ -288,6 +288,7 @@ define PHP_INSTALL_FIXUP
      rm -f $(TARGET_DIR)/usr/bin/phpize
      $(INSTALL) -D -m 0755 $(PHP_DIR)/php.ini-production \
          $(TARGET_DIR)/etc/php.ini
+    $(SED) 's/;date.timezone =/date.timezone = UTC/' $(TARGET_DIR)/etc/php.ini

Would it be possible to use BR2_TARGET_LOCALTIME (if set) instead? Something
like:

ifeq ($(BR2_TARGET_LOCALTIME),)
PHP_LOCALTIME = UTC
else
PHP_LOCALTIME = $(BR2_TARGET_LOCALTIME)
endif

    $(SED) 's%;date.timezone =.*%date.timezone = $(PHP_LOCALTIME)%' \
        $(TARGET_DIR)/etc/php.ini
Quoted 8 lines
Quoted 2 lines

That is, assuming that php can deal with complex timezones like
Europe/Brussels.

PHP used to use the system's time zone name automatically in older PHP versions. But nowadays fills your log with warnings that is not reliable:

==
Warning: strtotime(): It is not safe to rely on the system's timezone settings.

Any idea _why_ it is not safe? I've tried to google it but didn't come up with
a reason, just a lot of fixes.

Quoted 9 lines

You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.
==

It certainly does work for common names like Europe/Brussels, but not sure if that goes for every zone name.

Hm, php (like so often) has its own re-implementation of the timezone
database... . It's based on the same Olson database so it's probably OK for valid timezones, but tzdata has additional posix/ and right/ variants and it also has the old SystemV/ timezones...

Well, people who use one of these weird timezones will see the php error so
they can solve it I guess.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
author
#15 lore raw

PATCH 1/1 php.ini: set date.timezone to UTC

Quoted 6 lines · Arnout Vandecappelle
Quoted 3 lines · Floris Bos

On 05/02/2015 12:23 AM, Arnout Vandecappelle wrote:
== Warning: strtotime(): It is not safe to rely on the system's timezone settings.

Any idea _why_ it is not safe? I've tried to google it but didn't come up with
a reason, just a lot of fixes.

No idea.

Quoted 9 lines
Quoted 9 lines

You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.
==

It certainly does work for common names like Europe/Brussels, but not sure if that goes for every zone name.

Quoted 7 lines

Hm, php (like so often) has its own re-implementation of the timezone
database... . It's based on the same Olson database so it's probably OK for valid timezones, but tzdata has additional posix/ and right/ variants and it also has the old SystemV/ timezones...

Well, people who use one of these weird timezones will see the php error so
they can solve it I guess.

I do know Debian has a patch to let PHP use the system's timezone database instead of the internal one.
We could borrow that one, but then we would be deviating from upstream (which did not want the patch, and prefers to stick with their internal db).

Yours sincerely,

Floris Bos

#16 lore raw

PATCH 1/1 php.ini: set date.timezone to UTC

Quoted 5 lines · Floris Bos

I do know Debian has a patch to let PHP use the system's timezone database instead of the internal one.
We could borrow that one, but then we would be deviating from upstream (which did not want the patch, and prefers to stick with their internal db).

As far as i remember it's a chicken-and-egg problem.
PHP is used in many old distros/systems that don't have modern tzdata and that was a problem, so they bundled it (also cross-operating system consistent behaviour).
But then the bundled one might be out of date as well, and takes up space :) IMHO it should be a build-time php option.
Regards.

author
#17 lore raw

PATCH 1/1 php.ini: set date.timezone to UTC

In reply to Arnout Vandecappelle
Quoted 34 lines · Arnout Vandecappelle
Quoted 33 lines · Floris Bos
Quoted 32 lines · Arnout Vandecappelle
Quoted 13 lines · Floris Bos

Prevent a warning being logged each time a PHP date/time method is used by setting UTC as (default) timezone in php.ini

---
   package/php/php.mk | 1 +
   1 file changed, 1 insertion(+)
package/php/php.mk +0 -0
index 3b9a117..7bd3f63 100644

package/php/php.mk define PHP_INSTALL_FIXUP · line 291

Quoted 4 lines
package/php/php.mk +1 -0
@@ -288,6 +288,7 @@ define PHP_INSTALL_FIXUP
       rm -f $(TARGET_DIR)/usr/bin/phpize
       $(INSTALL) -D -m 0755 $(PHP_DIR)/php.ini-production \
           $(TARGET_DIR)/etc/php.ini
+    $(SED) 's/;date.timezone =/date.timezone = UTC/' $(TARGET_DIR)/etc/php.ini

Would it be possible to use BR2_TARGET_LOCALTIME (if set) instead? Something
like:

ifeq ($(BR2_TARGET_LOCALTIME),)
PHP_LOCALTIME = UTC
else
PHP_LOCALTIME = $(BR2_TARGET_LOCALTIME)
endif

     $(SED) 's%;date.timezone =.*%date.timezone = $(PHP_LOCALTIME)%' \
         $(TARGET_DIR)/etc/php.ini

That is, assuming that php can deal with complex timezones like
Europe/Brussels.

Quoted 7 lines
Quoted 5 lines

PHP used to use the system's time zone name automatically in older PHP versions. But nowadays fills your log with warnings that is not reliable:

==
Warning: strtotime(): It is not safe to rely on the system's timezone settings.

Any idea _why_ it is not safe? I've tried to google it but didn't come up with
a reason, just a lot of fixes.

I just read:
http://derickrethans.nl/distributions-please-dont-cripple-php-or-red-hat-stop-fucking-around.html

And the problem seem to just be that there isn't a standardized way to retrieve the exact timezone name set on a system, only derived information. If you have Europe/London set on your system in the winter, PHP's old time zone detection algorithm would only be able to detect that it is currently "UTC" instead of that the timezone is set to London. I can imagine that indeed gives problems if you have PHP code that works with time and date values in the past or future, and needs to take into account day light savings time.

That means there are only problems with the detection, and not really with the time zone names (except the exotic ones).
And there should be no problem just specifying BR2_TARGET_LOCALTIME in php.ini like you suggested.

Signature · 3 lines
Yours sincerely,

Floris Bos