2021-02-27 19:39:26 +01:00
|
|
|
import ../make-test-python.nix ({pkgs, lib, php, ...}: {
|
|
|
|
name = "php-${php.version}-fpm-nginx-test";
|
2020-04-19 20:56:42 +02:00
|
|
|
meta.maintainers = lib.teams.php.members;
|
2020-03-30 22:07:05 +02:00
|
|
|
|
|
|
|
machine = { config, lib, pkgs, ... }: {
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
virtualHosts."phpfpm" = let
|
|
|
|
testdir = pkgs.writeTextDir "web/index.php" "<?php phpinfo();";
|
|
|
|
in {
|
|
|
|
root = "${testdir}/web";
|
2021-01-01 00:50:51 +01:00
|
|
|
locations."~ \\.php$".extraConfig = ''
|
2020-03-30 22:07:05 +02:00
|
|
|
fastcgi_pass unix:${config.services.phpfpm.pools.foobar.socket};
|
|
|
|
fastcgi_index index.php;
|
|
|
|
include ${pkgs.nginx}/conf/fastcgi_params;
|
|
|
|
include ${pkgs.nginx}/conf/fastcgi.conf;
|
|
|
|
'';
|
|
|
|
locations."/" = {
|
|
|
|
tryFiles = "$uri $uri/ index.php";
|
|
|
|
index = "index.php index.html index.htm";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.phpfpm.pools."foobar" = {
|
|
|
|
user = "nginx";
|
2021-02-27 19:39:26 +01:00
|
|
|
phpPackage = php;
|
2020-03-30 22:07:05 +02: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-09-16 17:32:56 +02:00
|
|
|
response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/")
|
2021-02-27 19:39:26 +01:00
|
|
|
assert "PHP Version ${php.version}" in response, "PHP version not detected"
|
2020-03-30 22:07:05 +02:00
|
|
|
|
|
|
|
# Check so we have database and some other extensions loaded
|
2020-04-16 23:21:26 +02:00
|
|
|
for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite"]:
|
|
|
|
assert ext in response, f"Missing {ext} extension"
|
2020-03-30 22:07:05 +02:00
|
|
|
'';
|
|
|
|
})
|