feat: got php working for the user server

This commit is contained in:
silver 2024-04-20 03:18:13 +01:00
parent a4c52ea87c
commit 54606be0df

View file

@ -7,6 +7,7 @@
}: }:
with lib; let with lib; let
cfg = config.services.skynet_users; cfg = config.services.skynet_users;
php_pool = "skynet_users";
in { in {
imports = [ imports = [
./acme.nix ./acme.nix
@ -69,6 +70,25 @@ in {
# normally services cannot read home dirs # normally services cannot read home dirs
systemd.services.nginx.serviceConfig.ProtectHome = "read-only"; systemd.services.nginx.serviceConfig.ProtectHome = "read-only";
systemd.services."phpfpm-${php_pool}".serviceConfig.ProtectHome = lib.mkForce "read-only";
services.phpfpm.pools.${php_pool} = {
user = config.services.nginx.user;
group = config.services.nginx.group;
settings = {
"listen.owner" = config.services.nginx.user;
"pm" = "dynamic";
"pm.max_children" = 32;
"pm.max_requests" = 500;
"pm.start_servers" = 2;
"pm.min_spare_servers" = 2;
"pm.max_spare_servers" = 5;
"php_admin_value[error_log]" = "stderr";
"php_admin_flag[log_errors]" = true;
"catch_workers_output" = true;
};
phpEnv."PATH" = lib.makeBinPath [pkgs.php];
};
services.nginx.virtualHosts = { services.nginx.virtualHosts = {
"${cfg.host.ip}" = { "${cfg.host.ip}" = {
@ -90,9 +110,14 @@ in {
locations."/" = { locations."/" = {
alias = "/home/$user/public_html/"; alias = "/home/$user/public_html/";
index = "index.html"; index = "index.html index.php";
extraConfig = "autoindex on;"; extraConfig = ''
tryFiles = "$uri$args $uri$args/ /index.html"; autoindex on;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:${config.services.phpfpm.pools.${php_pool}.socket};
include ${pkgs.nginx}/conf/fastcgi.conf;
'';
tryFiles = "$uri$args $uri$args/ /index.html /index.php";
}; };
}; };
}; };