#!/bin/sh

set -euo pipefail

pkg_add php-8.4.12

cat <<EOF > /var/www/htdocs/index.php
<?php
    echo "hello world";
?>
EOF

cat <<EOF > ~/httpd.conf
prefork 1

server "default" {
    no log
    listen on * port 80
    root "/htdocs"
    fastcgi {
        param SCRIPT_FILENAME "/htdocs/index.php"
        socket "/run/php-fpm.sock"
    }
}
EOF

httpd -vd -f ~/httpd.conf &
php-fpm-8.4
(printf 'GET / HTTP/1.1\r\nHost: whatever\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n'; sleep 1) | nc -N localhost 80 | hexdump -C
