{ lib, config, pkgs, ... }:
let
cfg = config.myServices.websites.christophe_carpentier.website;
varDir = "/var/lib/ftp/christophe_carpentier/website";
apacheUser = config.services.httpd.Inte.user;
apacheGroup = config.services.httpd.Inte.group;
in {
options.myServices.websites.christophe_carpentier.website.enable = lib.mkEnableOption "enable Christophe Carpentier's website";
config = lib.mkIf cfg.enable {
system.activationScripts.christophe_carpentier_website = {
deps = [ "httpd" "users" ];
text = ''
install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${varDir}
'';
};
services.phpfpm.pools.christophe_carpentier_website = {
user = apacheUser;
group = apacheGroup;
settings = {
"listen.owner" = apacheUser;
"listen.group" = apacheGroup;
"pm" = "ondemand";
"pm.max_children" = "5";
"pm.process_idle_timeout" = "60";
"php_admin_value[session.save_handler]" = "redis";
"php_admin_value[session.save_path]" = "'unix:///run/redis-php-sessions/redis.sock?persistent=1&prefix=ChristopheCarpentier:website:'";
"php_admin_value[open_basedir]" = "${varDir}:/tmp";
};
phpOptions = config.services.phpfpm.phpOptions + ''
disable_functions = "mail"
'';
phpPackage = pkgs.php72.withExtensions ({ enabled, all }: enabled ++ [all.redis]);
};
services.websites.env.production.modules = [ "proxy_fcgi" ];
services.websites.env.integration.vhostConfs.christophe_carpentier_website = {
certName = "integration";
addToCerts = true;
hosts = ["www.cc.immae.dev" "cc.immae.dev"];
root = varDir;
extraConfig = [
''
SetHandler "proxy:unix:${config.services.phpfpm.pools.christophe_carpentier_website.socket}|fcgi://localhost"
DirectoryIndex index.php index.htm index.html
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride All
Require all granted
''
];
};
};
}