NGINX Unit

Joomla§

要使用 Unit 运行 Joomla 内容管理系统

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

  2. 安装和配置 Joomla 的 先决条件

  3. 安装 Joomla 的 核心文件。在此,我们将其安装在 /path/to/app/;在配置中使用真实路径。

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

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

    注意

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

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

  5. 接下来,准备Joomla配置以进行单元测试(对shareroot使用实际值)

    {
        "listeners": {
            "*:80": {
                "pass": "routes"
            }
        },
    
        "routes": [
            {
                "match": {
                    "uri": [
                        "*.php",
                        "*.php/*",
                        "/administrator/"
                    ]
                },
    
                "action": {
                    "pass": "applications/joomla/direct"
                }
            },
            {
                "action": {
                    "share": "/path/to/app$uri",
                    "fallback": {
                        "pass": "applications/joomla/index"
                    }
                }
            }
        ],
    
        "applications": {
            "joomla": {
                "type": "php",
                "targets": {
                    "direct": {
                        "root": "/path/to/app/"
                    },
    
                    "index": {
                        "root": "/path/to/app/",
                        "script": "index.php"
                    }
                }
            }
        }
    }
    

    第一个路由步骤处理管理部分和指定PHP脚本的所有URL;direct目标不会设置script选项以供默认使用,因此Unit会查找相应的.php文件。

    下一步通过share提供静态文件。其fallback搜索引擎友好型URL启用重写机制。所有请求都会转到在Joomla目录根目录下运行index.php脚本的index目标。

  6. 上传更新后的配置。假设上述JSON已添加到config.json

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

    注意

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

    成功更新后,Joomla应在侦听器的IP和端口上可用以完成设置

Joomla on Unit - Setup Screen