From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hartmut Goebel Subject: [WIP 2/2] gnu: Add "PHP FPM" OS config example. Date: Thu, 8 Dec 2016 18:52:10 +0100 Message-ID: <1481219530-786-3-git-send-email-h.goebel@crazy-compilers.com> References: <1481219132-27353-1-git-send-email-h.goebel@crazy-compilers.com> <1481219530-786-1-git-send-email-h.goebel@crazy-compilers.com> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cF2rl-00071M-IT for guix-devel@gnu.org; Thu, 08 Dec 2016 12:52:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cF2rj-0004bT-9v for guix-devel@gnu.org; Thu, 08 Dec 2016 12:52:21 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:33221) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cF2ri-0004bE-VE for guix-devel@gnu.org; Thu, 08 Dec 2016 12:52:19 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3tZNH55WBzz3hj1W for ; Thu, 8 Dec 2016 18:52:17 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3tZNH55Pz3zvnMm for ; Thu, 8 Dec 2016 18:52:17 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id 1wu5WrgVZdiW for ; Thu, 8 Dec 2016 18:52:16 +0100 (CET) Received: from hermia.goebel-consult.de (ppp-188-174-144-224.dynamic.mnet-online.de [188.174.144.224]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS for ; Thu, 8 Dec 2016 18:52:16 +0100 (CET) Received: from lenashee.goebel-consult.de (lenashee.goebel-consult.de [192.168.110.2]) by hermia.goebel-consult.de (Postfix) with ESMTP id 4F10260787 for ; Thu, 8 Dec 2016 18:52:10 +0100 (CET) In-Reply-To: <1481219530-786-1-git-send-email-h.goebel@crazy-compilers.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * gnu/system/examples/php-fpm.tmpl: New file. * Makefile.am (EXAMPLES): Add it. * doc/locak.mk (OS_CONFIG_EXAMPLES_TEXI): Add doc/os-config-php-fpm.texi. * gnu/system/install.scm (/etc/configuration-files)[directory]: Add php-fpm.tmpl. --- Makefile.am | 3 +- doc/local.mk | 3 +- gnu/system/examples/php-fpm.tmpl | 115 +++++++++++++++++++++++++++++++++++++++ gnu/system/install.scm | 6 +- 4 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 gnu/system/examples/php-fpm.tmpl diff --git a/Makefile.am b/Makefile.am index 0e3ddac..f39c80b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -189,7 +189,8 @@ KCONFIGS = \ EXAMPLES = \ gnu/system/examples/bare-bones.tmpl \ gnu/system/examples/desktop.tmpl \ - gnu/system/examples/lightweight-desktop.tmpl + gnu/system/examples/lightweight-desktop.tmpl \ + gnu/system/examples/php-fpm.tmpl GOBJECTS = $(MODULES:%.scm=%.go) guix/config.go $(dist_noinst_DATA:%.scm=%.go) diff --git a/doc/local.mk b/doc/local.mk index 64bd2a5..f8b702e 100644 --- a/doc/local.mk +++ b/doc/local.mk @@ -48,7 +48,8 @@ EXTRA_DIST += \ OS_CONFIG_EXAMPLES_TEXI = \ %D%/os-config-bare-bones.texi \ %D%/os-config-desktop.texi \ - %D%/os-config-lightweight-desktop.texi + %D%/os-config-lightweight-desktop.texi \ + %D%/os-config-php-fpm.texi # Bundle this file so that makeinfo finds it in out-of-source-tree builds. BUILT_SOURCES += $(OS_CONFIG_EXAMPLES_TEXI) diff --git a/gnu/system/examples/php-fpm.tmpl b/gnu/system/examples/php-fpm.tmpl new file mode 100644 index 0000000..fb5143e --- /dev/null +++ b/gnu/system/examples/php-fpm.tmpl @@ -0,0 +1,115 @@ +;; -*- mode: scheme -*- +;; +;; This is an operating system configuration template for a basic php-fpm +;; server. It will serve a single page on http://localhost/ + +(use-modules (gnu)) +(use-service-modules networking php web) +(use-package-modules admin) +(use-package-modules php) ; for php-hello-world, an example php application + +(define NGINX + ;; FIXME: should be (string-append nginx "/")) + "/gnu/store/np656cjgc87rv18klcr2vwxk6g0kjhbz-nginx-1.11.6") +(define PHP-HELLO-WORLD + ;; FIXME: should be (string-append php-hello-world "/")) + "/gnu/store/9wqzxfs2xgr4ic1iwq124dq7cfqg1yi9-php-hello-world-0.1") + +;; TODO: Use nginx configuration mechanisms when they are finished +(define (CONFIG nginx php-hello-world) + (string-append " +user nginx www; +pid /var/run/nginx/pid; +error_log /var/log/nginx/error.log info; + +http { + client_body_temp_path /var/run/nginx/client_body_temp; + proxy_temp_path /var/run/nginx/proxy_temp; + fastcgi_temp_path /var/run/nginx/fastcgi_temp; + uwsgi_temp_path /var/run/nginx/uwsgi_temp; + scgi_temp_path /var/run/nginx/scgi_temp; + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log info; + + server_tokens off; + + include " nginx "/share/nginx/conf/fastcgi.conf; + + server { + listen 80; + server_name _; + root " php-hello-world "/; + index index.php; + + # Per server logging + access_log /var/log/nginx/www.access.log; + error_log /var/log/nginx/www.error.log notice; + + location / { + try_files $uri $uri/ /index.php; + } + # serve static files directly + location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { + access_log off; + expires max; + } + + location ~ \\.php$ { + try_files $uri =404; + fastcgi_pass unix:/var/run/php-fpm-www.sock; + fastcgi_index index.php; + } + } +} +")) + +(define CONFIG (CONFIG NGINX PHP-HELLO-WORLD)) + + +(operating-system + (host-name "phempton") + (timezone "Europe/Berlin") + (locale "en_US.UTF-8") + (kernel-arguments '("vga=791")) ; 1024x768 pixel + + ;; Assuming /dev/sdX is the target hard disk, and "my-root" is + ;; the label of the target root file system. + (bootloader (grub-configuration (device "/dev/sdX"))) + (file-systems (cons (file-system + (device "my-root") + (title 'label) + (mount-point "/") + (type "ext4")) + %base-file-systems)) + + ;; Globally-installed packages. + (packages (cons* + php-hello-world ; an example php application + %base-packages)) + + ;; We need to add a user and a group for each pool (defaults are the pool + ;; name). TODO: This should be done automatically, based on the pool + ;; configuration given below. + (groups (cons + (user-group (name "www")) + %base-groups)) + (users (cons + (user-account + (name "www") + (group "www") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin"))) + %base-user-accounts)) + + (services (cons* + (dhcp-client-service) + (console-keymap-service "de") + (nginx-service + #:config-file (plain-file "nginx.conf" CONFIG)) + (php-fpm-service + #:config + (php-fpm-configuration + (pools (list + (php-fpm-pool + (name "www")))))) + %base-services))) diff --git a/gnu/system/install.scm b/gnu/system/install.scm index dfa003f..8c95944 100644 --- a/gnu/system/install.scm +++ b/gnu/system/install.scm @@ -224,10 +224,12 @@ the user's target storage device rather than on the RAM disk." target))) '(#$(file "bare-bones.tmpl") #$(file "desktop.tmpl") - #$(file "lightweight-desktop.tmpl")) + #$(file "lightweight-desktop.tmpl") + #$(file "php-fpm.tmpl")) '("bare-bones.scm" "desktop.scm" - "lightweight-desktop.scm")) + "lightweight-desktop.scm" + "php-fpm.scm")) #t)))) `(("configuration" ,directory))) -- 2.7.4