NGINX Unit
v. 1.25.0

CodeIgniter§

To run apps built with the CodeIgniter web framework using Unit:

  1. Install Unit with a PHP language module.

  2. Download CodeIgniter’s core files and build your application. Here, let’s use a basic app template, installing it at /path/to/app/.

  3. 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.

  4. Next, prepare the CodeIgniter configuration for Unit:

    {
        "listeners": {
            "*:80": {
                "pass": "routes"
            }
        },
    
        "routes": [
            {
                "match": {
                    "uri": "!/index.php"
                },
    
                "action": {
                    "share": "/path/to/app/public/",
                    "fallback": {
                        "pass": "applications/codeigniter"
                    }
                }
            }
        ],
    
        "applications": {
            "codeigniter": {
                "type": "php",
                "root": "/path/to/app/public/",
                "script": "index.php"
            }
        }
    }
    
  5. 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, your app should be available on the listener’s IP address and port:

CodeIgniter Sample App on Unit