Skip to content

普通安装

适用于未使用宝塔面板、由 Nginx 直接托管的服务器环境。

准备环境

  • PHP >= 8.0<= 8.3
  • Composer >= 2.0
  • MySQL 或 PostgreSQL

0. 安装 PHP 和 Composer

已安装 PHP 和 Composer 时跳过此步骤。全新的 Linux 系统可执行:

bash
curl -sO https://www.workerman.net/install-php-and-composer && sudo bash install-php-and-composer

Windows 请手动安装 PHP 和 Composer。

1. 修复 PHP 禁用函数

Linux 服务器执行:

bash
curl -Ss https://www.workerman.net/webman/fix-disable-functions | php

Windows 用户跳过此步骤。

2. 安装依赖

进入源码目录执行:

bash
composer install

3. 启动服务

Linux 执行:

bash
php start.php start -d

Windows 执行:

bat
windows.bat

4. 配置 Nginx

将以下示例中的域名、源码目录和日志路径替换为实际值:

nginx
server {
    listen 80;
    server_name chat.99kf.com;
    root /home/www/99kf/public;
    index index.php index.html;

    client_max_body_size 100M;
    access_log /var/log/nginx/chat.99kf.access.log;

    location /api/ {
        rewrite ^/api/(.*)$ /agent/$1 last;
    }
    location ^~ / {
        location ~ "^/app/[A-Za-z0-9]{20,64}(/|$)" {
            proxy_pass http://127.0.0.1:3131;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header X-Real-IP $remote_addr;
        }
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        if (!-f $request_filename){
            proxy_pass http://127.0.0.1:8787;
        }
    }
    location ~* \.(eot|ttf|woff)$ {
        add_header Access-Control-Allow-Origin *;
    }
    location ~ \.php$ {
        return 404;
    }
    location ~ ^/\.well-known/ {
        allow all;
    }
    location ~ /\. {
        return 404;
    }
}

配置完成后检查并重载 Nginx:

bash
nginx -t && nginx -s reload

5. 完成安装

访问:

text
http://你的域名/install

根据安装向导检测环境并填写数据库配置,完成后即可使用系统。

数据库配置

安装向导:数据库配置

设置管理员

安装向导:设置管理员