1. The problem I’m having:
I’m trying to work with frankenphp. Specifically I need to be able to load php.d
files for configuration. According to phpinfo()
no php.ini
file is being loaded. The docs FrankenPHP: the modern PHP app server say " To load additional PHP configuration files, the PHP_INI_SCAN_DIR
environment variable can be used. When set, PHP will load all the file with the .ini
extension present in the given directories."
… but doesn’t explain how to actually do that. I looked at the Caddy documentation on Environment Variables and I couldn’t understand how that would relate.
2. Error messages and/or full log output:
N/A
3. Caddy version:
4. How I installed and ran Caddy:
frankenphp
a. System environment:
Alma Linux 9
b. Command:
systemctl start frankenphp
c. Service/unit/compose file:
[Unit]
Description=FrankenPHP Server
After=network.target network-online.target
Requires=network-online.target
[Service]
Restart=on-failure
Type=notify
User=frankenphp
Group=frankenphp
ExecStartPre=/usr/bin/frankenphp validate --config /etc/frankenphp/Caddyfile
ExecStart=/usr/bin/frankenphp run --environ --config /etc/frankenphp/Caddyfile
ExecReload=/usr/bin/frankenphp reload --config /etc/frankenphp/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddy config:
{
# Enable FrankenPHP
frankenphp
# Logging
log {
output stderr
level DEBUG
}
}
dev.sportch.co.uk {
# Enable compression (optional)
encode zstd br gzip
root * /var/www/html/app
# Define a route for handling requests
route {
# Security: Hide specific paths
@hide path /.env *.sql *.template /gtscripts/* *.txt *.md /random /support vapi/ var/ /support /system.* /lib
respond @hide 404
# Execute PHP files
php_server
# Rewrite subfolder requests for screenscrapers
rewrite /ladder/* /ladder/index.php
rewrite /manager/* /manager/index.php
# Add WebSocket support
@websocket {
header Connection *Upgrade*
header Upgrade websocket
}
reverse_proxy @websocket localhost:5502
}
}