-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLCMP.nix
67 lines (60 loc) · 1.4 KB
/
LCMP.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{ config, pkgs, ... }:
{
# Caddy Webserver with PHP-FPM
services.caddy = {
enable = true;
user = "www-data";
group = "www-data";
virtualHosts."example.com" = {
extraConfig = ''
root * /var/www/example
file_server
php_fastcgi unix/var/run/phpfpm/caddy.sock
'';
};
};
# Ensure required webserver ports are open
networking.firewall.allowedTCPPorts = [ 80 443];
# MariaDB SQL
services.mysql = {
enable = true;
package = pkgs.mariadb;
};
# PHP packages
environment.systemPackages = with pkgs; [
php81
];
# PHP-FPM on required socketpath
services.phpfpm.pools = {
caddy = {
phpPackage = pkgs.php81;
user = "www-data";
group = "www-data";
phpOptions = ''
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300
'';
settings = {
"pm" = "dynamic";
"pm.max_children" = 75;
"pm.start_servers" = 10;
"pm.min_spare_servers" = 5;
"pm.max_spare_servers" = 20;
"pm.max_requests" = 500;
};
};
};
# Create required user for PHP-FPM and Caddy
users.users.www-data = {
isSystemUser = true;
home = "/var/lib/caddy";
createHome = false;
description = "System user for web services";
group = "www-data";
extraGroups = [ "root" ];
};
# Create the required group for PHP-FPM and Caddy
users.groups.www-data = {};
}