Use apache and mod_php in www services

This commit is contained in:
2025-05-26 15:23:29 -07:00
parent f21f543976
commit 455a36f0d1

View File

@@ -1,60 +1,26 @@
{ pkgs, config, inputs, ... }: { pkgs, inputs, ... }:
{ let
fortune = pkgs.writeShellScript "cgi" ''
echo "Content-type: text/html"
echo ""
${pkgs.fortune}/bin/fortune
'';
in {
services.mysql = { services.mysql = {
enable = true; enable = true;
package = pkgs.mariadb; package = pkgs.mariadb;
}; };
users.groups.www = {}; services.httpd = {
enable = true;
users.users.www = { enablePHP = true;
isSystemUser = true; # phpPackage = inputs.phps.packages.x86_64-linux.php74;
home = "/var/www"; extraConfig = ''
group = "www"; ScriptAlias /fortune ${fortune}/bin/fortune
}; '';
virtualHosts."localhost" = {
services.phpfpm = { documentRoot = "/var/www";
pools = { locations."/".index = "index.html index.php";
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}
}
'';
};
} }