1 import ../make-test-python.nix ({ pkgs, lib, php, ... }: {
2 name = "php-${php.version}-fpm-nginx-test";
3 meta.maintainers = lib.teams.php.members;
5 nodes.machine = { config, lib, pkgs, ... }: {
6 environment.systemPackages = [ php ];
11 virtualHosts."phpfpm" =
13 testdir = pkgs.writeTextDir "web/index.php" "<?php phpinfo();";
16 root = "${testdir}/web";
17 locations."~ \\.php$".extraConfig = ''
18 fastcgi_pass unix:${config.services.phpfpm.pools.foobar.socket};
19 fastcgi_index index.php;
20 include ${config.services.nginx.package}/conf/fastcgi_params;
21 include ${pkgs.nginx}/conf/fastcgi.conf;
24 tryFiles = "$uri $uri/ index.php";
25 index = "index.php index.html index.htm";
30 services.phpfpm.pools."foobar" = {
34 "listen.group" = "nginx";
35 "listen.mode" = "0600";
36 "listen.owner" = "nginx";
38 "pm.max_children" = 5;
39 "pm.max_requests" = 500;
40 "pm.max_spare_servers" = 3;
41 "pm.min_spare_servers" = 1;
42 "pm.start_servers" = 2;
46 testScript = { ... }: ''
47 machine.wait_for_unit("nginx.service")
48 machine.wait_for_unit("phpfpm-foobar.service")
50 # Check so we get an evaluated PHP back
51 response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/")
52 assert "PHP Version ${php.version}" in response, "PHP version not detected"
54 # Check so we have database and some other extensions loaded
55 for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite", "apcu"]:
56 assert ext in response, f"Missing {ext} extension"
57 machine.succeed(f'test -n "$(php -m | grep -i {ext})"')