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 = {
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.httpd = {
enable = true;
enablePHP = true;
# phpPackage = inputs.phps.packages.x86_64-linux.php74;
extraConfig = ''
ScriptAlias /fortune ${fortune}/bin/fortune
'';
virtualHosts."localhost" = {
documentRoot = "/var/www";
locations."/".index = "index.html index.php";
};
};
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}
}
'';
};
}