2021-06-28 23:13:55 +00:00
|
|
|
import ../make-test-python.nix ({ pkgs, lib, php, ... }: {
|
2021-03-09 03:18:52 +00:00
|
|
|
name = "php-${php.version}-fpm-nginx-test";
|
2020-05-03 17:38:23 +00:00
|
|
|
meta.maintainers = lib.teams.php.members;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
machine = { config, lib, pkgs, ... }: {
|
2021-03-09 03:18:52 +00:00
|
|
|
environment.systemPackages = [ php ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
virtualHosts."phpfpm" =
|
|
|
|
let
|
|
|
|
testdir = pkgs.writeTextDir "web/index.php" "<?php phpinfo();";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
root = "${testdir}/web";
|
|
|
|
locations."~ \\.php$".extraConfig = ''
|
|
|
|
fastcgi_pass unix:${config.services.phpfpm.pools.foobar.socket};
|
|
|
|
fastcgi_index index.php;
|
2022-02-21 08:47:16 +00:00
|
|
|
include ${config.services.nginx.package}/conf/fastcgi_params;
|
2021-06-28 23:13:55 +00:00
|
|
|
include ${pkgs.nginx}/conf/fastcgi.conf;
|
|
|
|
'';
|
|
|
|
locations."/" = {
|
|
|
|
tryFiles = "$uri $uri/ index.php";
|
|
|
|
index = "index.php index.html index.htm";
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.phpfpm.pools."foobar" = {
|
|
|
|
user = "nginx";
|
2021-03-09 03:18:52 +00:00
|
|
|
phpPackage = php;
|
2020-04-24 23:36:52 +00:00
|
|
|
settings = {
|
|
|
|
"listen.group" = "nginx";
|
|
|
|
"listen.mode" = "0600";
|
|
|
|
"listen.owner" = "nginx";
|
|
|
|
"pm" = "dynamic";
|
|
|
|
"pm.max_children" = 5;
|
|
|
|
"pm.max_requests" = 500;
|
|
|
|
"pm.max_spare_servers" = 3;
|
|
|
|
"pm.min_spare_servers" = 1;
|
|
|
|
"pm.start_servers" = 2;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
testScript = { ... }: ''
|
|
|
|
machine.wait_for_unit("nginx.service")
|
|
|
|
machine.wait_for_unit("phpfpm-foobar.service")
|
|
|
|
|
|
|
|
# Check so we get an evaluated PHP back
|
2020-10-27 00:29:36 +00:00
|
|
|
response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/")
|
2021-03-09 03:18:52 +00:00
|
|
|
assert "PHP Version ${php.version}" in response, "PHP version not detected"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Check so we have database and some other extensions loaded
|
2021-03-09 03:18:52 +00:00
|
|
|
for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite", "apcu"]:
|
2020-04-24 23:36:52 +00:00
|
|
|
assert ext in response, f"Missing {ext} extension"
|
2021-03-09 03:18:52 +00:00
|
|
|
machine.succeed(f'test -n "$(php -m | grep -i {ext})"')
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
})
|