1 { lib, pkgs, config, ... }:
3 adminer = pkgs.callPackage ../commons/adminer.nix { inherit config; };
4 cfg = config.myServices.websites.naturaloutil.production;
5 varDir = "/var/lib/ftp/jerome";
6 env = config.myEnv.websites.jerome;
8 options.myServices.websites.naturaloutil.production.enable = lib.mkEnableOption "enable Naturaloutil's website";
10 config = lib.mkIf cfg.enable {
11 services.webstats.sites = [ { name = "naturaloutil.immae.eu"; } ];
13 security.acme.certs."ftp".extraDomains."naturaloutil.immae.eu" = null;
16 dest = "webapps/prod-naturaloutil";
22 $mysql_user = '${env.mysql.user}' ;
23 $mysql_server = '${env.mysql.host}' ;
24 $mysql_base = '${env.mysql.database}' ;
25 $mysql_password = '${env.mysql.password}' ;
28 ${if env.mysql.host != "localhost" then ''
29 mysqli_options ($db, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);
30 $db->ssl_set(NULL, NULL, "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt", NULL, NULL);
32 $database = connect_db($db, $mysql_server, $mysql_base, $mysql_user, $mysql_password);
36 system.activationScripts.naturaloutil = {
39 install -m 0755 -o wwwrun -g wwwrun -d /var/lib/php/sessions/naturaloutil
42 systemd.services.phpfpm-jerome.after = lib.mkAfter [ "mysql.service" ];
43 systemd.services.phpfpm-jerome.wants = [ "mysql.service" ];
44 services.phpfpm.pools.jerome = {
48 "listen.owner" = "wwwrun";
49 "listen.group" = "wwwrun";
52 "pm.max_children" = "5";
53 "pm.process_idle_timeout" = "60";
55 "php_admin_value[open_basedir]" = "/var/lib/php/sessions/naturaloutil:/var/secrets/webapps/prod-naturaloutil:${varDir}:/tmp";
56 "php_admin_value[session.save_path]" = "/var/lib/php/sessions/naturaloutil";
59 BDD_CONNECT = "/var/secrets/webapps/prod-naturaloutil";
61 phpOptions = config.services.phpfpm.phpOptions + ''
62 extension=${pkgs.php}/lib/php/extensions/mysqli.so
65 services.websites.env.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ];
66 services.websites.env.production.vhostConfs.naturaloutil = {
67 certName = "naturaloutil";
68 certMainHost = "naturaloutil.immae.eu";
69 hosts = ["naturaloutil.immae.eu" ];
72 (adminer.apache.vhostConf null)
74 Use Stats naturaloutil.immae.eu
75 ServerAdmin ${env.server_admin}
76 ErrorLog "${varDir}/logs/error_log"
77 CustomLog "${varDir}/logs/access_log" combined
80 SetHandler "proxy:unix:${config.services.phpfpm.pools.jerome.socket}|fcgi://localhost"
83 <Directory ${varDir}/logs>
88 DirectoryIndex index.php index.htm index.html
89 Options Indexes FollowSymLinks MultiViews Includes