Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Document] Use case / tutorial on migrating from a traditional setup #755

Open
yellow1912 opened this issue Apr 27, 2024 · 1 comment
Open

Comments

@yellow1912
Copy link

yellow1912 commented Apr 27, 2024

Hello FrankenPHP team,

I have known about the project for a while, and finally have the time to try it out. I find the current documents a bit lacking, however. Perhaps my use case is a bit very specific and rather complex:


I'm currently running a Symfony monolithic application using Nginx + PHP-FPM, serving multiple clients from the same codebase but with distinct configurations and local directories for each client.

Every client project actually shares the same code base (so they all point to the same Symfony vendor and app folder). The only difference is each website/rpoject has its own local folder (with its own configs such as local cache folder, upload folder, database connection).

Each client setup is defined in Nginx and PHP-FPM to point to these specific local folders.


I have several questions:

  1. With my current setup, I have 1 single nginx server to handle all requests, does it work the same with FrankenPHP or do I have to spinup 1 docker for each client?
  2. Each website/client can have multiple domains. This is rather easy with nginx. Does it work for FrankenPHP? I have been handling letsencrypt cert renewal via my custom scripts so I don't really need to auto renewal offered by FrankenPHP (though it would be nice if it works)
  3. I have been using lua script (inside nginx) to handle caching and redirection. The reason I do that is mainly for performance (the request doesn't have to reach PHP in most cases). What is the alternative/recommended way with FrankenPHP?
@withinboredom
Copy link
Collaborator

I'm currently running a Symfony monolithic application using Nginx + PHP-FPM, serving multiple clients from the same codebase but with distinct configurations and local directories for each client.

I feel like your usecase is common-ish, but rather specific.

I'm currently running a Symfony monolithic application using Nginx + PHP-FPM, serving multiple clients from the same codebase but with distinct configurations and local directories for each client.

Each website/client can have multiple domains. This is rather easy with nginx. Does it work for FrankenPHP? I have been handling letsencrypt cert renewal via my custom scripts so I don't really need to auto renewal offered by FrankenPHP (though it would be nice if it works)

I suppose it depends on how you're handling this currently. If each tenant is running as a different user, then you'll need to have multiple deployments of frankenphp. This is largely due to the fact that frankenphp uses threads instead of processes and threads cannot be run as a different user than the parent process.

If all your tenant's fpm pools are running as the same user, then this can largely be supported out of the box: https://frankenphp.dev/docs/config/#:~:text=You%20can%20also%20define%20multiple%20workers%20if%20you%20serve%20multiple%20apps%20on%20the%20same%20server%3A

I have been using lua script (inside nginx) to handle caching and redirection. The reason I do that is mainly for performance (the request doesn't have to reach PHP in most cases). What is the alternative/recommended way with FrankenPHP?

You can probably leave your nginx configuration mostly the same, and instead of using FastCGI, just proxy a regular HTTP request. I can't say for certain if you'd be able to do a full caddy switch-over since you have custom lua code running, but you could try this configuration adapter for caddy: https://github.com/caddyserver/nginx-adapter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants