Nginx Unit with Docker, PHP, and Laravel
NGINX Unit is a dynamic web application server, designed to run applications in multiple languages. Unit is lightweight, polyglot, and dynamically configured via API. The design of the server allows reconfiguration of specific application parameters as needed by the engineering or operations.
NGINX Unit is currently available as a beta. As such, it is suitable for use in a testing environment but is not recommended for use in production.
Unit is beta right now, so I decided to start experimenting with it for PHP applications. You can check out my Nginx Unit Demo repository, which runs a Laravel application with Nginx Unit in Docker.
While researching, I decided to use the ubuntu:xenial image to make things easier instead of building from source. Here’s the Dockerfile for reference:
One of the exciting features of Unit for me was the ability to run multiple language configurations (i.e., a Golang and PHP application) and how you define the configuration objects through an API. If you check out my repository, after the Docker container starts, I run the following to define the PHP application:
And here’s my demo configuration object for the Laravel application:
Take my repo for a spin and let me know what you think @paulredmond!