Need tutorial for Nginx/PHP-FPM users #417
Replies: 6 comments 3 replies
-
I would also suggest some documentation about moving from Apache/Litespeed To Caddy/Frankenphp. |
Beta Was this translation helpful? Give feedback.
-
I think most of these questions can be answered by playing around with Caddy on its own first to figure out how it usually works - to me at least it reads more like being new to Caddy more than FrankenPHP itself.
This one I'm not sure on. The answer to this would likely also relate to the port conflict question - if multiple Caddy instances are trying to use the same port then yeah you'll probably have issues. But if it's a single Caddy instance then it's the same as nginx serving multiple site configs. |
Beta Was this translation helpful? Give feedback.
-
Welp all good questions, but no clear answer yet. I guess only way to find out is experiment a lot. Which is really bad to do |
Beta Was this translation helpful? Give feedback.
-
I'm also interested. It looks perfect to use in containers, but for a "normal" setup (caddy installed with apt + php-fpm) how to replace caddy with Frankenphp ? Is it only possible ? |
Beta Was this translation helpful? Give feedback.
-
Ok got it. Just need to use Frankenphp binary globally instead of Caddy, add the "frankenphp" and "php_server" directives in the Caddy config files, and start Frankenphp like Caddy with --config . |
Beta Was this translation helpful? Give feedback.
-
@manhthang2504 Replacing PHP-FPM with FrankenPHP in NginxIf you already know and understand Nginx, you can still use it with FrankenPHP just replacing PHP-FPM very similar to how you likely already do by configuring it as a reverse proxy in Nginx. map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
#...
location /index.php {
try_files /not_exists @octane;
}
location / {
try_files $uri $uri/ @octane;
}
#...
location @octane {
set $suffix "";
if ($uri = /index.php) {
set $suffix ?$query_string;
}
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Scheme $scheme;
proxy_set_header SERVER_PORT $server_port;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://127.0.0.1:8000$suffix;
}
} In the Laravel Octane Documentation you can find the full example on how to do this. Serve static files from NginxAlso, if you still want to serve static assets via Nginx instead of Caddy you can just turn off the file_server directive in your php_server {
file_server off
} Configure PHPFor your PHP ( PerformanceI've only compared local performance using Caddy directly vs with Nginx proxying Caddy and performance has been comparable (with HTTP/2), though both is a huge improvement from Nginx+PHP-FPM. And just for full disclosure, I'm running FrankenPHP with HTTPS, but it could be quite annoying to configure, but that enables HTTP/2 and HTTP/3 in Caddy which might have had if different result in performance is observed. |
Beta Was this translation helpful? Give feedback.
-
I'm interested in Franken PHP. Read the news, docs... but still confused about how to config it to migrate from Nginx/PHP-FPM.
Apart from benefit, most of the examples show it run one single application, just like
php artisan serve
.In my case, I have multiple websites on a VPS, NOT using Docker (I'm not sure to call my setup as "bare metal", because from what I understand it may refer to a physical server, but in my case it's VPS). With Nginx, I forward each domain to a PHP-FPM socket. Each PHP-FPM socket run it own linux user (web1_user, web2_user...) (pooling) and my app is chown to that user, to prevent local exploit if one is compromised.
I read article about Roadrunner, Swoole and Franken PHP, seem like there's a new term (to me) called "application server". To my understanding as of now, it mean that one server serve one application, separately. It make me wonder whether it will make conflict in the PORT using. I'm not sure if using Docker can solve it, but I'm not into using Docker in my case. So every app must config a separate port? How to config domain to point to each app? Does FrankenPHP run on shared linux user, or can I config each app running on separate linux user like PHP-FPM pooling above?
Each web app run its own FrankenPHP instance, does it mean that I have several Caddy webserver instances running? Does it create more overhead in compare with one single Nginx service?
Another point is WAF. With Nginx, I have Mod_Security. I know Caddy have Coraza, but there're only tutorial for config Caddy with Coraza, not the Franken PHP itself. From what I read, Franken PHP has Caddy under its hood, but how to config Franken PHP's Caddy? The configuration is same with plain/stand alone Caddy or not?
If the Franken PHP documentation has the Production Deployment with these explaination for Nginx/PHP-FPM user like me, it will smooth the transition alot.
Beta Was this translation helpful? Give feedback.
All reactions