{ lib, pkgs, config, ... }:
let
adminer = pkgs.callPackage ../commons/adminer.nix { inherit config; };
cfg = config.myServices.websites.telio_tortay.production;
varDir = "/var/lib/ftp/telio_tortay";
env = config.myEnv.websites.telio_tortay;
apacheUser = config.services.httpd.Prod.user;
apacheGroup = config.services.httpd.Prod.group;
in {
options.myServices.websites.telio_tortay.production.enable = lib.mkEnableOption "enable Telio Tortay's website";
config = lib.mkIf cfg.enable {
services.webstats.sites = [ { name = "telio-tortay.immae.eu"; } ];
security.acme.certs."ftp".extraDomainNames = [ "telio-tortay.immae.eu" ];
system.activationScripts.telio_tortay = {
deps = [ "httpd" ];
text = ''
install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/ftp/telio_tortay/logs
'';
};
systemd.services.phpfpm-telio_tortay.after = lib.mkAfter [ "mysql.service" ];
systemd.services.phpfpm-telio_tortay.wants = [ "mysql.service" ];
services.phpfpm.pools.telio_tortay = {
user = apacheUser;
group = apacheGroup;
settings = {
"listen.owner" = apacheUser;
"listen.group" = apacheGroup;
"pm" = "dynamic";
"pm.max_children" = "20";
"pm.start_servers" = "2";
"pm.min_spare_servers" = "1";
"pm.max_spare_servers" = "3";
"php_admin_value[open_basedir]" = "${varDir}:/tmp";
"php_admin_value[session.save_handler]" = "redis";
"php_admin_value[session.save_path]" = "'unix:///run/redis-php-sessions/redis.sock?persistent=1&prefix=TelioTortay:Production:'";
};
phpOptions = config.services.phpfpm.phpOptions + ''
disable_functions = "mail"
'';
phpPackage = pkgs.php72.withExtensions({ enabled, all }: enabled ++ [all.redis]);
};
services.websites.env.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ];
services.websites.env.production.vhostConfs.telio_tortay = {
certName = "telio_tortay";
certMainHost = "telio-tortay.immae.eu";
hosts = ["telio-tortay.immae.eu" "realistesmedia.fr" "www.realistesmedia.fr" ];
root = varDir;
extraConfig = [
(adminer.apache.vhostConf null)
''
Use Stats telio-tortay.immae.eu
ServerAdmin ${env.server_admin}
ErrorLog "${varDir}/logs/error_log"
CustomLog "${varDir}/logs/access_log" combined
SetHandler "proxy:unix:${config.services.phpfpm.pools.telio_tortay.socket}|fcgi://localhost"
AllowOverride None
Require all denied
AllowOverride None
Require all denied
DirectoryIndex index.php index.htm index.html
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride all
Require all granted
''
];
};
};
}