Nice experiment! And thanks for listing the cons - the lack of Gzip compressions, inability to protect dot files and set cache headers for static files. We'll stick with good ol' nginx+PHP-FPM for now :D
Yeah, altho I think you can configure a lot of that (except for gzip). A lot of times I think you'd use this in like a container or something have an http layer on top of it that can handle gzip, etc.
Wow! This looks so promising for PHP. It appears to have more steps involved for installing. What do you think it would be more simple? To install unit from a PHP base docker image or to install PHP from a unit base image? Thank you!
Unit is awesome, but I had slightly different approach: install containerized unit-php8.2 and then run laravel. Very neat result. Until I had to make some mysql queries and not sqlite3. But that's fixable too.
Yeah for sure - definitely a valid way to go. I think their official images come out pretty large, I'm in process of playing with containerizing it myself. Got to around 285mb of image size with a base of ubuntu:22.04 (multi-stage build to compile the PHP module separately)
Might be interesting to benchmark Unit with a multi port config (attached to the same backend) & load balanced by some Nginx proxy config VS Unit with a processes config for a single port. All in all its definitely more flexible compared to FPM. And with some smart Nginx proxying, any non-PHP requests could be entirely offloaded to Nginx. That being said, if Unit's config also allowed defining the path to the unit-php binary, that would probably make a multi-PHP setup easier.
Yeah! I think the key with the multiple PHP versions is naming the PHP modules something different on each build/compilation. I haven't tested that yet, however.
I already have nginx server on my ubuntu 22.04 running for several project, I want to try nginx unit for my newest project, if I install this nginx unit, would it break my nginx and all related website?
I really appreciate this video, you are very good at explaining, I love that you go line by line. The only problem I have is with static files, for example a .txt file inside /public or the sitemap itself (.xml), do you have any idea how to handle this to make it work?
In my experience (just tested this!) these static files just work - nginx unit is smart enough to set the correct content-type headers (I tested .css, .js. .txt. .xml).It did NOT, however, protect against dot files (likely would with further config)
Been battling with this for hours now. For some reason keep getting the following error when I try to push the config ``` { "error": "Invalid configuration.", "detail": "The module to run \"php\" is not found among the available application modules." } ``` Any ideas?
that’s happened to me when they released a new version and the php module i built didn’t match versions. Make sure the version you download to build the php module is the latest version.
@@fideloper was trying to build using a base Ubuntu image but just ended up using the provided unit php docker image in the end after 5 hours of frustration lol. Maybe I'll revisit in the future but their provided image works for right now
I haven’t tried it other than casually loading up their docker image. What I like about Unit is that I don’t need to compile PHP and do any non-standard installation/run time of PHP.
Nice experiment! And thanks for listing the cons - the lack of Gzip compressions, inability to protect dot files and set cache headers for static files. We'll stick with good ol' nginx+PHP-FPM for now :D
Yeah, altho I think you can configure a lot of that (except for gzip). A lot of times I think you'd use this in like a container or something have an http layer on top of it that can handle gzip, etc.
From HN to video in under 24 hrs!
Having a play with this today so your timing is perfect.
This looks super convenient. I didn't came across it before, thanks a million for sharing it!
Great content. Keep 'em coming please!
Wow! This looks so promising for PHP. It appears to have more steps involved for installing. What do you think it would be more simple? To install unit from a PHP base docker image or to install PHP from a unit base image? Thank you!
Incredible content, Chris
Thank you!
Thanks for saying so, glad it's helpful!
Unit is awesome, but I had slightly different approach: install containerized unit-php8.2 and then run laravel. Very neat result. Until I had to make some mysql queries and not sqlite3. But that's fixable too.
Yeah for sure - definitely a valid way to go.
I think their official images come out pretty large, I'm in process of playing with containerizing it myself. Got to around 285mb of image size with a base of ubuntu:22.04 (multi-stage build to compile the PHP module separately)
Might be interesting to benchmark Unit with a multi port config (attached to the same backend) & load balanced by some Nginx proxy config VS Unit with a processes config for a single port. All in all its definitely more flexible compared to FPM. And with some smart Nginx proxying, any non-PHP requests could be entirely offloaded to Nginx. That being said, if Unit's config also allowed defining the path to the unit-php binary, that would probably make a multi-PHP setup easier.
Yeah! I think the key with the multiple PHP versions is naming the PHP modules something different on each build/compilation. I haven't tested that yet, however.
Very cool.
thanks!
I already have nginx server on my ubuntu 22.04 running for several project, I want to try nginx unit for my newest project, if I install this nginx unit, would it break my nginx and all related website?
i don’t think so - but i’d experiment in a docker container first.
I really appreciate this video, you are very good at explaining, I love that you go line by line. The only problem I have is with static files, for example a .txt file inside /public or the sitemap itself (.xml), do you have any idea how to handle this to make it work?
In my experience (just tested this!) these static files just work - nginx unit is smart enough to set the correct content-type headers (I tested .css, .js. .txt. .xml).It did NOT, however, protect against dot files (likely would with further config)
Cool , Thanks
Been battling with this for hours now. For some reason keep getting the following error when I try to push the config
```
{
"error": "Invalid configuration.",
"detail": "The module to run \"php\" is not found among the available application modules."
}
```
Any ideas?
that’s happened to me when they released a new version and the php module i built didn’t match versions.
Make sure the version you download to build the php module is the latest version.
@@fideloper was trying to build using a base Ubuntu image but just ended up using the provided unit php docker image in the end after 5 hours of frustration lol. Maybe I'll revisit in the future but their provided image works for right now
how to get metrics?
Great content! Would love to hear your opinion on Laravel Octane with different application servers as well.
Fancy to try frankenphp?
I haven’t tried it other than casually loading up their docker image. What I like about Unit is that I don’t need to compile PHP and do any non-standard installation/run time of PHP.
or, we use GO :)
awesome content Nonetheles... Thanks
According my tests unit-php can't handle concurrencty when script is doing sleep()
oh that's interesting! If some PHP sleep()'s in middle of handling a web request, what behavior do you see? Every other request fails?
@@fideloper no but they are queued up, unit seem to process only sleep in one process at the time