Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRTitor committed Oct 1, 2024
1 parent 94590b5 commit 3b6756a
Showing 1 changed file with 31 additions and 37 deletions.
68 changes: 31 additions & 37 deletions dev-environment/nginx.nix
Original file line number Diff line number Diff line change
@@ -1,45 +1,39 @@
{ pkgs, lib, config, userSettings, ... }:
let
app = "phpdemo";
domain = "localhost";
dataDir = "/var/www/${domain}";
in {
services.phpfpm.pools.${app} = {
user = app;
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 = {
enable = true;
virtualHosts.${domain}.locations."/${app}" = {
root = dataDir;
{
config,
lib,
pkgs,
...
}: {
services.nginx.enable = true;
services.nginx.virtualHosts."localhost" = {
locations."/phptest" = {
root = "/var/www/phptest";
extraConfig = ''
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:${config.services.phpfpm.pools.${app}.socket};
fastcgi_pass unix:${config.services.phpfpm.pools.mypool.socket};
include ${pkgs.nginx}/conf/fastcgi.conf;
fastcgi_index index.php;
'';
};
};
users.users.${app} = {
isSystemUser = true;
createHome = true;
home = dataDir;
group = app;
services.mysql = {
enable = true;
package = pkgs.mariadb;
};
users.groups.${app} = {};

users.users.${userSettings.username}.extraGroups = [
app
];
}
# PHP-FPM pool configuration
# Needed for nginx to communicate with PHP
services.phpfpm.pools.mypool = {
user = "nobody";
settings = {
"pm" = "dynamic";
"listen.owner" = config.services.nginx.user;
"pm.max_children" = 5;
"pm.start_servers" = 2;
"pm.min_spare_servers" = 1;
"pm.max_spare_servers" = 3;
"pm.max_requests" = 500;
};
phpEnv."PATH" = lib.makeBinPath [ pkgs.php ];
};
}

0 comments on commit 3b6756a

Please sign in to comment.