[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[WIP 2/2] gnu: Add "PHP FPM" OS config example.
From: |
Hartmut Goebel |
Subject: |
[WIP 2/2] gnu: Add "PHP FPM" OS config example. |
Date: |
Thu, 8 Dec 2016 18:52:10 +0100 |
* 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