[PATCH] services: httpd: Allow using it with PHP.

  • Done
  • quality assurance status badge
Details
3 participants
  • Ludovic Courtès
  • Christopher Baines
  • Florian Pelz
Owner
unassigned
Submitted by
Florian Pelz
Severity
normal

Debbugs page

Florian Pelz wrote 6 years ago
(address . guix-patches@gnu.org)
20181020164401.ylh63egrl4mbz3qb@florianbeaglebone.fritz.box
* gnu/services/web.scm (httpd): Make existing httpd-module API public.
* doc/guix.texi (Apache HTTP Server): Document its usage with PHP-FPM.
---
doc/guix.texi | 31 +++++++++++++++++++++++++++++++
gnu/services/web.scm | 5 +++++
2 files changed, 36 insertions(+)

Toggle diff (74 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index f4f19949f..58c2cd7f5 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -50,6 +50,7 @@ Copyright @copyright{} 2018 Oleg Pykhalov@*
Copyright @copyright{} 2018 Mike Gerwitz@*
Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
Copyright @copyright{} 2018 Gábor Boskovits@*
+Copyright @copyright{} 2018 Florian Pelz@*
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -16595,6 +16596,10 @@ within the store, for example @code{(file-append mod-wsgi
@end table
@end deffn
+@defvr {Scheme Variable} %default-httpd-modules
+A default list of @code{httpd-module} objects.
+@end defvr
+
@deffn {Data Type} httpd-config-file
This data type represents a configuration file for the httpd service.
@@ -16603,6 +16608,32 @@ This data type represents a configuration file for the httpd service.
The modules to load. Additional modules can be added here, or loaded by
additional configuration.
+For example, in order to handle requests for PHP files, you can use Apache’s
+@code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
+
+@example
+(service httpd-service-type
+ (httpd-configuration
+ (config
+ (httpd-config-file
+ (modules (cons*
+ (httpd-module
+ (name "proxy_module")
+ (file "modules/mod_proxy.so"))
+ (httpd-module
+ (name "proxy_fcgi_module")
+ (file "modules/mod_proxy_fcgi.so"))
+ %default-httpd-modules))
+ (extra-config (list "\
+<FilesMatch \\.php$>
+ SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
+</FilesMatch>"))))))
+(service php-fpm-service-type
+ (php-fpm-configuration
+ (socket "/var/run/php-fpm.sock")
+ (socket-group "httpd")))
+@end example
+
@item @code{server-root} (default: @code{httpd})
The @code{ServerRoot} in the configuration file, defaults to the httpd
package. Directives including @code{Include} and @code{LoadModule} are
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 1edb1f4d3..fcf453c24 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -70,6 +70,11 @@
httpd-config-file-user
httpd-config-file-group
+ <httpd-module>
+ httpd-module
+ httpd-module?
+ %default-httpd-modules
+
httpd-service-type
<nginx-configuration>
--
2.19.1
Ludovic Courtès wrote 6 years ago
(address . 33104@debbugs.gnu.org)
87h8h9srmc.fsf@gnu.org
Hi Florian!

Florian Pelz <pelzflorian@pelzflorian.de> skribis:

Toggle quote (3 lines)
> * gnu/services/web.scm (httpd): Make existing httpd-module API public.
> * doc/guix.texi (Apache HTTP Server): Document its usage with PHP-FPM.

At first sight this LGTM but I’m no expert. Chris, WDYT? Please apply
if it looks good to you!

Thank you,
Ludo’.
Christopher Baines wrote 6 years ago
(name . Florian Pelz)(address . pelzflorian@pelzflorian.de)
87d0rvwmvs.fsf@cbaines.net
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (10 lines)
> Hi Florian!
>
> Florian Pelz <pelzflorian@pelzflorian.de> skribis:
>
>> * gnu/services/web.scm (httpd): Make existing httpd-module API public.
>> * doc/guix.texi (Apache HTTP Server): Document its usage with PHP-FPM.
>
> At first sight this LGTM but I’m no expert. Chris, WDYT? Please apply
> if it looks good to you!

Hey both,

Thanks for this patch Florian, it looks like a good change to make, and
I've now applied it.

I think when I was writing the httpd service originally, I ended up just
sticking the module loading in the extra configuration, but this looks
like a good way of handling it.

Thanks again,

Chris
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlvUZSdfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XdnlRAAlkGA42mhvp8U16mEwxDXcqGbIOde58ohdMqTEwUOz3ZtsbaHBBMgpbuj
BqDRBnjBoqHEVRQZMcwI+leNJOUCEUyLIXd8fDBxH9pBhhib5E+I0fcud4egLeVX
dHvPOiNMizq2Q2C/3RAC56Fm2oT7ls8t8gtw/cNiZT2mYkIXx7v5sumqAkm99RZB
GwYeMaR3Ew7Dkn6JP4UqNfFZyCeDOohYC0j7okjlCpkH3MzlEIRIGO7IqTA63K3N
eoD9slpglgD/0ku7lK2Scm6vSxSsqBXFe6wxKQ6IKikZ2W7aIB7MN0Epf3fwWGPC
pdvaeE7RfTA28lwUgdZbvo0PfivRjQvlbflGZHxXzsOAOPPav9FIhB8F+VkiVpda
iPp68bBbLQ0RyN9nkf6EVuOtk4nCsxAfEUvPbLGOMD3I7+dWRQQXQw8Evaz/274H
So3J7Va6aBEPURtQTdMxmt++GYj7G/vdDPNPT72z2IngUgPejCiGHeZ4HjZgaRd4
JLkwfEX3pmNsfcnOZWKFpvQnl9a5rdBAf96ZB1vZ9tc+qRnSp950NQf2fOVTWGR1
mmWO/ejZZYroHzR2AeAGq5XZCA1novsQoddbJxYYen7p+BtWAN2HHFI7kaZ6JInu
nQZKNvNW5BJVEN0LTaz/49cmfWtWSiTFX1SxaqVje7jfvp3YUMk=
=Wajh
-----END PGP SIGNATURE-----

Closed
pelzflorian (Florian Pelz) wrote 6 years ago
(name . Christopher Baines)(address . mail@cbaines.net)
20181027145906.nelsvh2zq3xz6emu@florianbeaglebone.fritz.box
Thank you!

On Sat, Oct 27, 2018 at 02:16:23PM +0100, Christopher Baines wrote:
Toggle quote (5 lines)
> I think when I was writing the httpd service originally, I ended up just
> sticking the module loading in the extra configuration, but this looks
> like a good way of handling it.
>

Your original httpd service had a modules field, it was
already documented in the Guix manual, only the httpd-module was not
public API and the field was therefore unusable.

Regards,
Florian
?
Your comment

This issue is archived.

To comment on this conversation send an email to 33104@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 33104
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help