NGINX Unit
v. 1.19.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. Set installation path permissions to secure access, for example:

    # chown -R unit_user:unit_group /path/to/app/
    

    Note the values to be used in Unit configuration.

  4. Next, put together the CodeIgniter configuration for Unit:

    {
        "listeners": {
            "*:80": {
                "pass": "routes/ci_app"
            }
        },
    
        "routes": {
            "ci_app": [
                {
                    "match": {
                        "uri": "!/index.php"
                    },
    
                    "action": {
                        "share": "/path/to/app/public/",
                        "fallback": {
                            "pass": "applications/ci_app"
                        }
                    }
                }
            ]
        },
    
        "applications": {
            "ci_app": {
                "type": "php",
                "user": "unit_user",
                "group": "unit_group",
                "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 --help or see Startup for details.

  6. After a successful update, your app should be available on the listener’s IP address and port:

CodeIgniter Sample App on Unit