Nginx Unit changes how we host PHP (& Laravel)

preview_player
Показать описание
Nginx Unit changes the game in how he host and containerize Laravel applications. We no longer need PHP-FPM, nor are limited by its max_children settings.

We cover installing and configuring Nginx Unit for use with PHP and Laravel.

Since we don't want to use the system-default PHP (instead wanting to use good old ppa:ondrej/php to install PHP), we need to manually compile the Nginx Unit PHP module - otherwise it attempts to load the wrong underlying PHP libaries.

Luckily that's pretty easy! We see how to run Unit, use it with a Laravel app, and discuss the pros & cons of Nginx Unit.

⌚️ Timestamps

00:00 Intro
00:05 What is Nginx Unit
01:47 Install PHP
03:49 Install Nginx Unit
05:39 Compile Unit's PHP Module
08:04 Create a Laravel app
09:28 Configure Unit
16:08 Nginx Unit Processes
17:50 The Good
19:21 The Bad
Рекомендации по теме
Комментарии
Автор

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

vaviloffx
Автор

From HN to video in under 24 hrs!
Having a play with this today so your timing is perfect.

locusm
Автор

Great content. Keep 'em coming please!

ryanvelbon
Автор

Incredible content, Chris
Thank you!

DaviMartins
Автор

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!

uxweb
Автор

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?

tom
Автор

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?

cooltech
Автор

This looks super convenient. I didn't came across it before, thanks a million for sharing it!

Loige
Автор

According my tests unit-php can't handle concurrencty when script is doing sleep()

gadelat
Автор

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.

packofblackdogs
Автор

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.

fevangelou
Автор

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?

thecaribcoder
Автор

Great content! Would love to hear your opinion on Laravel Octane with different application servers as well.

hristijant
welcome to shbcf.ru