diff --git a/hosts/marauder/default.nix b/hosts/marauder/default.nix index 509ecc2..c4a9f06 100755 --- a/hosts/marauder/default.nix +++ b/hosts/marauder/default.nix @@ -6,7 +6,7 @@ self.nixosModules.zerotier ./backup.nix ./dev.nix - ./phpdev.nix + ./www.nix ./printing.nix ]; diff --git a/hosts/marauder/phpdev.nix b/hosts/marauder/phpdev.nix deleted file mode 100755 index d91df2e..0000000 --- a/hosts/marauder/phpdev.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ pkgs, inputs, ... }: -{ - services.mysql = { - enable = true; - package = pkgs.mariadb; - }; - - services.httpd = { - enable = true; - adminAddr = "admin@localhost"; - enablePHP = true; - virtualHosts = { - "localhost" = { - documentRoot = "/var/www/localhost"; - locations."/".index = "index.html index.php"; - }; - }; - }; - - environment.systemPackages = [ - inputs.phps.packages.x86_64-linux.php72 - ]; -} diff --git a/hosts/marauder/www.nix b/hosts/marauder/www.nix new file mode 100755 index 0000000..a46e807 --- /dev/null +++ b/hosts/marauder/www.nix @@ -0,0 +1,60 @@ +{ pkgs, config, inputs, ... }: +{ + services.mysql = { + enable = true; + package = pkgs.mariadb; + }; + + users.groups.www = {}; + + users.users.www = { + isSystemUser = true; + home = "/var/www"; + group = "www"; + }; + + services.phpfpm = { + pools = { + php = { + user = "www"; + settings = { + "listen.owner" = config.services.caddy.user; + "pm" = "static"; + "pm.max_children" = 1; + "php_admin_value[error_log]" = "stderr"; + "php_admin_flag[log_errors]" = true; + "php_flag[display_errors]" = true; + "catch_workers_output" = true; + }; + }; + php56 = { + user = "www"; + phpPackage = inputs.phps.packages.x86_64-linux.php56; + settings = { + "listen.owner" = config.services.caddy.user; + "pm" = "static"; + "pm.max_children" = 1; + "php_admin_value[error_log]" = "stderr"; + "php_admin_flag[log_errors]" = true; + "php_flag[display_errors]" = false; + "catch_workers_output" = true; + }; + }; + }; + }; + + services.caddy = { + enable = true; + virtualHosts."localhost".extraConfig = '' + root * /var/www + file_server + tls internal + handle /phpmyadmin/* { + php_fastcgi unix/${config.services.phpfpm.pools.php56.socket} + } + handle { + php_fastcgi unix/${config.services.phpfpm.pools.php.socket} + } + ''; + }; +}