FrankenPHP is a modern, high-performance PHP application server and reverse proxy built with Caddy. It supports features like automatic HTTPS, HTTP/3, worker mode, and native support for Symfony and Laravel. If you’re running Ubuntu 24.04 and want to try FrankenPHP, here’s how to set it up.
Prerequisites
- Ubuntu 24.04 (fresh install or existing server)
- Root or sudo access
- Basic terminal knowledge
Step 1: Update Your System
Before installing anything, make sure your system packages are up-to-date:
sudo apt update && sudo apt upgrade -y
Step 2: Install Required Dependencies
FrankenPHP is built on top of Caddy, so we’ll start by installing xcaddy
to build a custom Caddy with FrankenPHP.
sudo apt install -y curl git build-essential php php-cli
Install xcaddy
:
curl -sfL https://github.com/caddyserver/xcaddy/releases/latest/download/xcaddy_$(uname -s)_$(uname -m) -o xcaddy
chmod +x xcaddy
sudo mv xcaddy /usr/local/bin/
Step 3: Build Caddy with FrankenPHP
Now build a custom version of Caddy with the FrankenPHP module:
xcaddy build --with github.com/dunglas/frankenphp
Move the built binary to a system path:
sudo mv caddy /usr/local/bin/
Step 4: Verify Installation
Check if FrankenPHP was included:
caddy list-modules | grep frankenphp
You should see something like: http.handlers.frankenphp
Step 5: Create a Basic FrankenPHP App
Create a simple PHP file:
mkdir -p ~/frankenphp-site
cd ~/frankenphp-site
echo "<?php phpinfo();" > index.php
Step 6: Create a Caddyfile
FrankenPHP uses Caddy’s config file format. Create a Caddyfile
:
nano ~/frankenphp-site/Caddyfile
Paste the following:
:8080
root * .
php_fastcgi localhost:9000
file_server
Optional: Replace
php_fastcgi
withfrankenphp
for native execution.
Example:
:8080
root * .
frankenphp
file_server
Step 7: Run FrankenPHP
From the project directory:
caddy run --config Caddyfile
Visit http://localhost:8080
(or your server IP) in your browser. You should see the PHP info page.
Final Tips
- Use
systemd
to run FrankenPHP as a service for production. - Secure your server with HTTPS using Caddy’s built-in features.
- Refer to the FrankenPHP documentation for advanced use cases.
Conclusion
FrankenPHP is fast, flexible, and easy to deploy. With Ubuntu 24.04 and just a few commands, you can have a powerful PHP app server up and running in no time.
Let me know in the comments if you ran into any issues—or if you’re using FrankenPHP in production!
Leave a Reply