{ 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}
install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/christophe_carpentier
'';
};
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[open_basedir]" = "/var/lib/php/sessions/christophe_carpentier:${varDir}:/tmp";
"php_admin_value[session.save_path]" = "/var/lib/php/sessions/christophe_carpentier";
};
phpOptions = config.services.phpfpm.phpOptions + ''
disable_functions = "mail"
'';
phpPackage = pkgs.php72;
};
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
''
];
};
};
}