All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] nginx: add option to enable php-fpm configuration
@ 2015-05-03  0:09 Floris Bos
  2015-05-03  0:09 ` [Buildroot] [PATCH v3] lighttpd: " Floris Bos
  0 siblings, 1 reply; 3+ messages in thread
From: Floris Bos @ 2015-05-03  0:09 UTC (permalink / raw)
  To: buildroot

Offer to install a minimal nginx.conf that has php support enabled
when both nginx and php-fpm are selected.

Signed-off-by: Floris Bos <bos@je-eigen-domein.nl>
---
 package/nginx/Config.in      | 11 +++++++++++
 package/nginx/nginx-php.conf | 38 ++++++++++++++++++++++++++++++++++++++
 package/nginx/nginx.mk       |  9 +++++++++
 3 files changed, 58 insertions(+)
 create mode 100644 package/nginx/nginx-php.conf

diff --git a/package/nginx/Config.in b/package/nginx/Config.in
index be445f4..48498c1 100644
--- a/package/nginx/Config.in
+++ b/package/nginx/Config.in
@@ -321,4 +321,15 @@ config BR2_PACKAGE_NGINX_ADD_MODULES
 	help
 	  Space separated list of urls of the additional modules
 
+config BR2_PACKAGE_NGINX_PHP_FPM
+	bool "enable php in configuration"
+	depends on BR2_PACKAGE_PHP_FPM
+	select BR2_PACKAGE_NGINX_HTTP_FASTCGI_MODULE
+	default y
+	help
+	  Install a minimal nginx.conf that handles PHP requests through php-fpm.
+
+comment "php support depends on php with FPM sapi"
+	depends on BR2_PACKAGE_PHP && !BR2_PACKAGE_PHP_FPM
+
 endif
diff --git a/package/nginx/nginx-php.conf b/package/nginx/nginx-php.conf
new file mode 100644
index 0000000..9d17ebf
--- /dev/null
+++ b/package/nginx/nginx-php.conf
@@ -0,0 +1,38 @@
+#
+# nginx.conf minimal config with php-fpm
+#
+
+events {
+    worker_connections  1024;
+}
+
+http {
+    include      mime.types;
+    default_type application/octet-stream;
+    sendfile     on;
+    #gzip        on;
+
+    server {
+        listen      80;
+        server_name $hostname;
+        root        /usr/html;
+
+        location / {
+            index index.php index.html index.htm;
+        }
+
+        location ~ \.php$ {
+            # Ensure a PHP file with that name exists on the file system
+            try_files     $uri =404;
+
+            fastcgi_pass  unix:/var/run/php-fpm.sock;
+            include       fastcgi.conf;
+
+            # By default nginx buffers all script output to memory and temp
+            # files, freeing up the PHP process asap for the next request.
+            # Turn this off if not desired (e.g. if you send large files)
+            #
+            #fastcgi_buffering off;
+        }
+    }
+}
diff --git a/package/nginx/nginx.mk b/package/nginx/nginx.mk
index 90ebbcc..24e2a41 100644
--- a/package/nginx/nginx.mk
+++ b/package/nginx/nginx.mk
@@ -237,4 +237,13 @@ define NGINX_INSTALL_INIT_SYSV
 		$(TARGET_DIR)/etc/init.d/S50nginx
 endef
 
+ifeq ($(BR2_PACKAGE_NGINX_PHP_FPM),y)
+define NGINX_INSTALL_PHP_CONFIG
+	$(INSTALL) -D -m 0644 package/nginx/nginx-php.conf \
+		$(TARGET_DIR)/etc/nginx/nginx.conf
+endef
+
+NGINX_POST_INSTALL_TARGET_HOOKS += NGINX_INSTALL_PHP_CONFIG
+endif
+
 $(eval $(generic-package))
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH v3] lighttpd: add option to enable php-fpm configuration
  2015-05-03  0:09 [Buildroot] [PATCH] nginx: add option to enable php-fpm configuration Floris Bos
@ 2015-05-03  0:09 ` Floris Bos
  2015-11-30 22:32   ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: Floris Bos @ 2015-05-03  0:09 UTC (permalink / raw)
  To: buildroot

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

Signed-off-by: Floris Bos <bos@je-eigen-domein.nl>

---
v3: clean up Config.in.
    show "php support depends on php with FPM sapi" message
    only when user did select lighttpd + php, but with different SAPI.
---
 package/lighttpd/Config.in    | 19 +++++++++++++++++++
 package/lighttpd/fastcgi.conf |  2 ++
 package/lighttpd/lighttpd.mk  | 11 +++++++++++
 3 files changed, 32 insertions(+)
 create mode 100644 package/lighttpd/fastcgi.conf

diff --git a/package/lighttpd/Config.in b/package/lighttpd/Config.in
index 2c101e7..dea2676 100644
--- a/package/lighttpd/Config.in
+++ b/package/lighttpd/Config.in
@@ -56,4 +56,23 @@ 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_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
diff --git a/package/lighttpd/fastcgi.conf b/package/lighttpd/fastcgi.conf
new file mode 100644
index 0000000..46c5f9a
--- /dev/null
+++ b/package/lighttpd/fastcgi.conf
@@ -0,0 +1,2 @@
+server.modules += ( "mod_fastcgi" )
+fastcgi.server  = ( ".php" => (( "socket" => "/var/run/php-fpm.sock", "allow-x-send-file" => "enable" )) )
diff --git a/package/lighttpd/lighttpd.mk b/package/lighttpd/lighttpd.mk
index 626cd69..16ca88b 100644
--- a/package/lighttpd/lighttpd.mk
+++ b/package/lighttpd/lighttpd.mk
@@ -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
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH v3] lighttpd: add option to enable php-fpm configuration
  2015-05-03  0:09 ` [Buildroot] [PATCH v3] lighttpd: " Floris Bos
@ 2015-11-30 22:32   ` Thomas Petazzoni
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2015-11-30 22:32 UTC (permalink / raw)
  To: buildroot

Dear Floris Bos,

On Sun,  3 May 2015 02:09:54 +0200, Floris Bos wrote:
> If both lighttpd and php-fpm are selected, offer to
> enable PHP in the lighttpd configuration.
> 
> Signed-off-by: Floris Bos <bos@je-eigen-domein.nl>

Thanks for your patch. Your patch is well-documented and written, but
after some discussion on IRC, we believe that the sort of custom
configuration you are doing belongs more to your rootfs overlay +
post-build script than to an option in the official Buildroot.

Indeed, we could add zillions of options to customize all aspects of
lighttpd, but it would be a nightmare to maintain in Buildroot. So we
try to stick with mainly compile-time configuration of lighttpd,
installing a minimally working configuration file by default. The rest
of the runtime configuration should be done in each user's rootfs
overlay and post build scripts.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-30 22:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-03  0:09 [Buildroot] [PATCH] nginx: add option to enable php-fpm configuration Floris Bos
2015-05-03  0:09 ` [Buildroot] [PATCH v3] lighttpd: " Floris Bos
2015-11-30 22:32   ` Thomas Petazzoni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.