diff --git a/doc/guix.texi b/doc/guix.texi index f2ef941b4..dcab3bd76 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -15173,7 +15173,7 @@ with some additional features useful for sites of any size. These features include: @itemize @bullet @item Adaptive process spawning -@item Basic statistics (ala Apache's mod_status) +@item Basic statistics (similar to Apache's mod_status) @item Advanced process management with graceful stop/start @item Ability to start workers with different uid/gid/chroot/environment and different php.ini (replaces safe_mode) @@ -15194,7 +15194,9 @@ A Service type for @code{php-fpm}. @deftp {Data Type} php-fpm-configuration Data Type for php-fpm service configuration. @table @asis -@item @code {socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")}) +@item @code{php} (default: @code{php}) +The php package to use. +@item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")}) The address on which to accept FastCGI requests. Valid syntaxes are: @table @asis @item @code{"ip.add.re.ss:port"} @@ -15205,20 +15207,20 @@ Listen on a TCP socket to all addresses on a specific port. Listen on a unix socket. @end table -@item @code {user} (default: @code{php-fpm}) +@item @code{user} (default: @code{php-fpm}) User who will own the php worker processes. -@item @code {group} (default: @code{php-fpm}) +@item @code{group} (default: @code{php-fpm}) Group of the worker processes. -@item @code {socket-user} (default: @code{php-fpm}) +@item @code{socket-user} (default: @code{php-fpm}) User who can speak to the php-fpm socket. -@item @code {socket-group} (default: @code{php-fpm}) +@item @code{socket-group} (default: @code{php-fpm}) Group that can speak to the php-fpm socket. -@item @code {pid-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.pid")}) +@item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")}) The process id of the php-fpm process is written to this file once the service has started. -@item @code {log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")}) +@item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")}) Log for the php-fpm master process. -@item @code {process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)}) +@item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)}) Detailed settings for the php-fpm process manager. Must be either: @table @asis @@ -15226,62 +15228,66 @@ Must be either: @item @code{} @item @code{} @end table -@item @code {display-errors} (default @code{#f}) +@item @code{display-errors} (default @code{#f}) Determines wether php errors and warning should be sent to clients and displayed in their browsers. This is useful for local php development, but a security risk for public sites, as error messages can reveal passwords and personal data. -@item @code {workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")}) +@item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")}) This file will log the @code{stderr} outputs of php worker processes. Can be set to @code{#f} to disable logging. -@item @code {file} (default @code{#f}) +@item @code{file} (default @code{#f}) An optional override of the whole configuration. You can use the @code{mixed-text-file} function or an absolute filepath for it. @end table @end deftp @deftp {Data type} php-fpm-dynamic-process-manager-configuration -Data Type for the @code{dynamic} php-fpm process manager. -With the @code{dynamic} process manager spare worker processes are kept around +Data Type for the @code{dynamic} php-fpm process manager. With the +@code{dynamic} process manager, spare worker processes are kept around based on it's configured limits. @table @asis -@item @code {max-children} (default: @code{5}) +@item @code{max-children} (default: @code{5}) Maximum of worker processes. -@item @code {start-servers} (default: @code{2}) +@item @code{start-servers} (default: @code{2}) How many worker processes should be started on start-up. -@item @code {min-spare-servers} (default: @code{1}) +@item @code{min-spare-servers} (default: @code{1}) How many spare worker processes should be kept around at minimum. -@item @code {max-spare-servers} (default: @code{3}) +@item @code{max-spare-servers} (default: @code{3}) How many spare worker processes should be kept around at maximum. @end table @end deftp @deftp {Data type} php-fpm-static-process-manager-configuration -Data Type for the @code{static} php-fpm process manager. -With the @code{static} process manager an unchanging number -of worker processes is created. +Data Type for the @code{static} php-fpm process manager. With the +@code{static} process manager, an unchanging number of worker processes +are created. @table @asis -@item @code {max-children} (default: @code{5}) +@item @code{max-children} (default: @code{5}) Maximum of worker processes. @end table @end deftp @deftp {Data type} php-fpm-on-demand-process-manager-configuration -Data Type for the @code{on-demand} php-fpm process manager. -With the @code{on-demand} process manager worker processes are only created -as requests arrive. +Data Type for the @code{on-demand} php-fpm process manager. With the +@code{on-demand} process manager, worker processes are only created as +requests arrive. @table @asis -@item @code {max-children} (default: @code{5}) +@item @code{max-children} (default: @code{5}) Maximum of worker processes. -@item @code {process-idle-timeout} (default: @code{10}) +@item @code{process-idle-timeout} (default: @code{10}) The time in seconds after which a process with no requests is killed. @end table @end deftp -@defvr {Scheme Variable} nginx-php-fpm-location +@deffn {Scheme Procedure} nginx-php-fpm-location @ + [#:nginx-package nginx] @ + [socket (string-append "/var/run/php" @ + (version-major (package-version php)) @ + "-fpm.sock")] A helper function to quickly add php to an @code{nginx-server-configuration}. -@end defvr +@end deffn A simple services setup for nginx with php can look like this: @example diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 3b3be215a..00599df6d 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -98,7 +98,7 @@ php-fpm-configuration-display-errors php-fpm-configuration-workers-log-file php-fpm-configuration-file - + php-fpm-dynamic-process-manager-configuration make-php-fpm-dynamic-process-manager-configuration @@ -107,13 +107,13 @@ php-fpm-dynamic-process-manager-configuration-start-servers php-fpm-dynamic-process-manager-configuration-min-spare-servers php-fpm-dynamic-process-manager-configuration-max-spare-servers - + php-fpm-static-process-manager-configuration make-php-fpm-static-process-manager-configuration php-fpm-static-process-manager-configuration? php-fpm-static-process-manager-configuration-max-children - + php-fpm-on-demand-process-manager-configuration make-php-fpm-on-demand-process-manager-configuration @@ -302,12 +302,10 @@ of index files." "events {}\n"))) (define %nginx-accounts - (list (user-group (name "php-fpm") (system? #t)) - (user-group (name "nginx") (system? #t)) + (list (user-group (name "nginx") (system? #t)) (user-account (name "nginx") (group "nginx") - (supplementary-groups '("php-fpm")) (system? #t) (comment "nginx server user") (home-directory "/var/empty") @@ -450,7 +448,7 @@ of index files." (socket-user php-fpm-configuration-socket-user (default "php-fpm")) (socket-group php-fpm-configuration-socket-group - (default "php-fpm")) + (default "nginx")) (pid-file php-fpm-configuration-pid-file (default (string-append "/var/run/php" (version-major (package-version php)) @@ -542,13 +540,13 @@ of index files." "pm.start_servers =" (number->string pm.start-servers) "\n" "pm.min_spare_servers =" (number->string pm.min-spare-servers) "\n" "pm.max_spare_servers =" (number->string pm.max-spare-servers) "\n")) - + (($ pm.max-children) (list "pm = static\n" "pm.max_children =" (number->string pm.max-children) "\n")) - + (($ pm.max-children pm.process-idle-timeout) @@ -604,16 +602,19 @@ of index files." (define php-fpm-service-type - (service-type (name 'php-fpm) - (description "Run `php-fpm' to provide a fastcgi socket for calling php through a webserver.") - (extensions - (list (service-extension shepherd-root-service-type - php-fpm-shepherd-service) - (service-extension activation-service-type - php-fpm-activation) - (service-extension account-service-type - php-fpm-accounts))) - (default-value (php-fpm-configuration)))) + (service-type + (name 'php-fpm) + (description + "Run @command{php-fpm} to provide a fastcgi socket for calling php through +a webserver.") + (extensions + (list (service-extension shepherd-root-service-type + php-fpm-shepherd-service) + (service-extension activation-service-type + php-fpm-activation) + (service-extension account-service-type + php-fpm-accounts))) + (default-value (php-fpm-configuration)))) (define* (nginx-php-location #:key