]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - nixops/modules/websites/commons/adminer.nix
Cleanup php session directories
[perso/Immae/Config/Nix.git] / nixops / modules / websites / commons / adminer.nix
CommitLineData
5c101474 1{ stdenv, fetchurl, nginx }:
940f1834
IB
2let
3 adminer = rec {
5c101474 4 webRoot = stdenv.mkDerivation rec {
940f1834
IB
5 version = "4.7.0";
6 name = "adminer-${version}";
5c101474 7 src = fetchurl {
940f1834
IB
8 url = "https://www.adminer.org/static/download/${version}/${name}.php";
9 sha256 = "1qq2g7rbfh2vrqfm3g0bz0qs057b049n0mhabnsbd1sgnpvnc5z7";
10 };
11 phases = "installPhase";
12 installPhase = ''
13 mkdir -p $out
14 cp $src $out/index.php
15 '';
16 };
17 phpFpm = rec {
18 socket = "/var/run/phpfpm/adminer.sock";
19 pool = ''
20 listen = ${socket}
21 user = ${apache.user}
22 group = ${apache.group}
23 listen.owner = ${apache.user}
24 listen.group = ${apache.group}
25 pm = ondemand
26 pm.max_children = 5
27 pm.process_idle_timeout = 60
28 ;php_admin_flag[log_errors] = on
c8e019b6
IB
29 ; Needed to avoid clashes in browser cookies (same domain)
30 php_value[session.name] = AdminerPHPSESSID
b7d2d4e3 31 php_admin_value[open_basedir] = "${webRoot}:/tmp:/var/lib/php/sessions/adminer:/var/lib/php/tmp/adminer"
c8e019b6 32 php_admin_value[session.save_path] = "/var/lib/php/sessions/adminer"
b7d2d4e3 33 php_admin_value[upload_tmp_dir] = "/var/lib/php/tmp/adminer"
940f1834
IB
34 '';
35 };
7da3ceec 36 apache = rec {
940f1834
IB
37 user = "wwwrun";
38 group = "wwwrun";
39 modules = [ "proxy_fcgi" ];
7da3ceec
IB
40 webappName = "_adminer";
41 root = "/run/current-system/webapps/${webappName}";
940f1834 42 vhostConf = ''
7da3ceec
IB
43 Alias /adminer ${root}
44 <Directory ${root}>
950ca5ee 45 DirectoryIndex index.php
273e2c61 46 Require all granted
940f1834
IB
47 <FilesMatch "\.php$">
48 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
49 </FilesMatch>
50 </Directory>
51 '';
52 };
53 nginxConf = {
54 alias = webRoot;
55 index = "index.php";
56 extraConfig = ''
5c101474 57 include ${nginx}/conf/fastcgi.conf;
940f1834
IB
58 fastcgi_split_path_info ^(.+?\.php)(/.*)$;
59 fastcgi_param HTTP_PROXY "";
60 fastcgi_param SCRIPT_FILENAME ${webRoot}/index.php;
61 fastcgi_pass unix:${phpFpm.socket};
62 fastcgi_index index.php;
63 fastcgi_intercept_errors on;
64 '';
65 };
66 };
67in
68 adminer