NGINX Unit
v. 1.32.1

Lumen§

To run apps based on the Lumen framework using Unit:

  1. Install Unit with a PHP language module.

  2. Install and configure Lumen’s prerequisites.

  3. Create a Lumen project. For our purposes, the path is /path/to/app/:

    $ cd /path/to/
    $ composer create-project laravel/lumen app
    
  4. Run the following command so Unit can access the application directory:

    # chown -R unit:unit /path/to/app/
    

    Note

    The unit:unit user-group pair is available only with official packages, Docker images, and some third-party repos. Otherwise, account names may differ; run the ps aux | grep unitd command to be sure.

    For further details, including permissions, see the security checklist.

  5. Next, prepare the Lumen configuration for Unit (use real values for share and root):

    {
        "listeners": {
            "*:80": {
                "pass": "routes"
            }
        },
    
        "routes": [
            {
                "match": {
                    "uri": "!/index.php"
                },
                "action": {
                    "share": "/path/to/app/public/",
                    "fallback": {
                        "pass": "applications/lumen"
                    }
                }
            }
        ],
    
        "applications": {
            "lumen": {
                "type": "php",
                "root": "/path/to/app/public/",
                "script": "index.php"
            }
        }
    }
    
  6. Upload the updated configuration. Assuming the JSON above was added to config.json:

    # curl -X PUT --data-binary @config.json --unix-socket \
           /path/to/control.unit.sock http://localhost/config/
    

    Note

    The control socket path may vary; run unitd -h or see Startup and Shutdown for details.

    After a successful update, browse to http://localhost and set up your Lumen application.