{ lib, pkgs, config, ... }:
let
cfg = config.myServices.websites.patrick_fodella.altermondia;
varDir = "/var/lib/ftp/patrick_fodella/altermondia";
apacheUser = config.services.httpd.Prod.user;
apacheGroup = config.services.httpd.Prod.group;
binEnvPaths = [ pkgs.zip ];
binEnv = pkgs.buildEnv { paths = binEnvPaths; name = "bin-env";};
in {
options.myServices.websites.patrick_fodella.altermondia.enable = lib.mkEnableOption "enable Patrick Fodella Altermondia's website";
config = lib.mkIf cfg.enable {
services.webstats.sites = [ { name = "altermondia.org"; } ];
systemd.services.phpfpm-patrick_fodella_altermondia.after = lib.mkAfter [ "mysql.service" ];
systemd.services.phpfpm-patrick_fodella_altermondia.wants = [ "mysql.service" ];
services.phpfpm.pools.patrick_fodella_altermondia = {
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";
"env[BIN_ENV]" = "${binEnv}/bin";
"php_admin_value[open_basedir]" = "${binEnv}:${builtins.concatStringsSep ":" binEnvPaths}:${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=PatrickFodella:Altermondia:'";
};
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.production.vhostConfs.patrick_fodella_altermondia = {
certName = "patrick_fodella";
addToCerts = true;
certMainHost = "altermondia.org";
hosts = ["altermondia.org" "www.altermondia.org" ];
root = varDir;
extraConfig = [
''
Use Stats altermondia.org
RewriteEngine on
RewriteCond "%{HTTP_HOST}" "!^altermondia\.org$" [NC]
RewriteRule ^(.+)$ https://altermondia.org$1 [R=302,L]
SetHandler "proxy:unix:${config.services.phpfpm.pools.patrick_fodella_altermondia.socket}|fcgi://localhost"
AllowOverride None
Require all denied
DirectoryIndex index.php index.htm index.html
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride all
Require all granted
''
];
};
};
}