]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/christophe_carpentier/agora-project.nix
Migrate php sessions to redis
[perso/Immae/Config/Nix.git] / modules / private / websites / christophe_carpentier / agora-project.nix
1 { lib, config, pkgs, ... }:
2 let
3 cfg = config.myServices.websites.christophe_carpentier.agora-project;
4 varDir = "/var/lib/ftp/christophe_carpentier/agora-project";
5 apacheUser = config.services.httpd.Inte.user;
6 apacheGroup = config.services.httpd.Inte.group;
7 in {
8 options.myServices.websites.christophe_carpentier.agora-project.enable = lib.mkEnableOption "enable Christophe Carpentier's agora-project";
9
10 config = lib.mkIf cfg.enable {
11 system.activationScripts.christophe_carpentier_agora_project = {
12 deps = [ "httpd" "users" ];
13 text = ''
14 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${varDir}
15 '';
16 };
17 services.phpfpm.pools.christophe_carpentier_agora_project = {
18 user = apacheUser;
19 group = apacheGroup;
20 settings = {
21 "listen.owner" = apacheUser;
22 "listen.group" = apacheGroup;
23
24 "pm" = "ondemand";
25 "pm.max_children" = "5";
26 "pm.process_idle_timeout" = "60";
27
28 "php_admin_value[open_basedir]" = "${varDir}:/tmp";
29 "php_admin_value[session.save_handler]" = "redis";
30 "php_admin_value[session.save_path]" = "'unix:///run/redis-php-sessions/redis.sock?persistent=1&prefix=ChristopheCarpentier:agora-project:'";
31 "php_admin_value[upload_max_filesize]" = "20M";
32 "php_admin_value[post_max_size]" = "20M";
33 };
34 phpOptions = config.services.phpfpm.phpOptions + ''
35 disable_functions = "mail"
36 '';
37 phpPackage = pkgs.php74;
38 };
39 services.websites.env.production.modules = [ "proxy_fcgi" ];
40 services.websites.env.integration.vhostConfs.christophe_carpentier_agora_project = {
41 certName = "integration";
42 addToCerts = true;
43 hosts = ["agora-project.cc.immae.dev"];
44 root = varDir;
45 extraConfig = [
46 ''
47 <FilesMatch "\.php$">
48 SetHandler "proxy:unix:${config.services.phpfpm.pools.christophe_carpentier_agora_project.socket}|fcgi://localhost"
49 </FilesMatch>
50
51 <Directory ${varDir}>
52 DirectoryIndex index.php index.htm index.html
53 Options Indexes FollowSymLinks MultiViews Includes
54 AllowOverride All
55 Require all granted
56 </Directory>
57 ''
58 ];
59 };
60 };
61 }
62
63