NGINX Unit

CodeIgniter§

要使用 Unit 运行使用 CodeIgniter Web 框架构建的应用

  1. 使用 PHP 语言模块安装 Unit

  2. 下载 CodeIgniter 的 核心文件构建 你的应用。在此,我们使用 基本应用模板,将其安装在 /path/to/app/

  3. 运行以下命令,以便 Unit 可以访问 应用目录

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

    注意

    unit:unit 用户组对仅适用于 官方软件包、Docker 镜像 和一些 第三方仓库。否则,帐户名称可能有所不同;运行 ps aux | grep unitd 命令以确保。

    有关更多详细信息,包括权限,请参阅 安全检查清单

  4. 接下来,准备 CodeIgniter 配置以供 Unit 使用

    {
        "listeners": {
            "*:80": {
                "pass": "routes"
            }
        },
    
        "routes": [
            {
                "match": {
                    "uri": "!/index.php"
                },
    
                "action": {
                    "share": "/path/to/app/public$uri",
                    "fallback": {
                        "pass": "applications/codeigniter"
                    }
                }
            }
        ],
    
        "applications": {
            "codeigniter": {
                "type": "php",
                "root": "/path/to/app/public/",
                "script": "index.php"
            }
        }
    }
    
  5. 上传更新后的配置。假设上述 JSON 已添加到 config.json

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

    注意

    控制套接字 路径可能有所不同;运行 unitd -h 或参见 启动和关闭 了解详情。

    更新成功后,您的应用应可在侦听器的 IP 地址和端口上使用

CodeIgniter Sample App on Unit