旧安卓手机部署openclaw
安卓版本6.0.18核 664G2.下载termux工具可以用笔记本提前下载好传给手机安卓上最经典、最强大的Linux环境模拟器社区资源极其丰富github下载地址可以选择对应的安卓版本的安装包universal.apk是通用的包推荐安装https://github.com/termux/termux-app/releases3.手机连接好wifi重要4.将下载好的termux.apk在手机上进行安装略5.在手机上安装后打开termux终端执行初始化操作都是在手机上的termux中操作5.1 安装openssh方便通过ssh进行远程连接下载比较慢需要等会如果中途出现网络错误可以ctrl c 打断重新执行安装命令$ pkg install openssh -y5.2 设置密码$ passwd #回车输入密码回车设置完成5.3 启动sshd服务$ sshd5.4 查看当前用户我这边默认输出的用户u0_a116$ whoami5.5 查看当前IP地址$ ip a5.6 修改默认的ssh端口默认端口是8022可选$ vi ~/../usr/etc/ssh/sshd_config #最后添加并保存根据自己需要设定端口 Port 22225.7 为了termux程序不被手机后台终止可以设置后台锁定或者设置手机为常亮模式6.通过电脑ssh远程连接之后就可以在电脑上操作了[rootlocalhost ~]# ssh -p 2222 u0_a116172.16.1.1507.初始化命令操作7.1 查看当前内核信息$ uname -a Linux localhost 3.10.84-perf-g1269e29-00269-g112a120 #1 SMP PREEMPT Thu Jun 4 16:40:13 CST 2020 aarch64 Android7.2 安装其他工具命令示范# 安装curl命令 $ pkg install curl # 安装nginx服务 $ pkg install nginx8.安装ubuntu系统在termux的基础上安装ubuntu系统可以更好的模拟真是操作系统8.1 安装atilo工具# 1. 添加 atilo 的官方仓库源 echo deb [trustedyes archall] https://yadominjinta.github.io/files/ termux extras $PREFIX/etc/apt/sources.list.d/atilo.list # 2. 更新包列表 apt update # 3. 安装 atilo apt install atilo # 4. 查看 atilo 支持哪些 Linux 发行版 atilo images # 5. 拉取 Ubuntu容器 atilo pull ubuntu # 6. 进入 Ubuntu 容器 atilo run ubuntu具体的安装过程下载ubuntu镜像需要解决安卓手机**的问题安装ubuntu过程8.2 ubuntu上的操作8.2.1 查看ubuntu系统版本rootlocalhost:~# cat /etc/os-release NAMEUbuntu VERSION20.04.6 LTS (Focal Fossa) IDubuntu ID_LIKEdebian PRETTY_NAMEUbuntu 20.04.6 LTS VERSION_ID20.04 HOME_URLhttps://www.ubuntu.com/ SUPPORT_URLhttps://help.ubuntu.com/ BUG_REPORT_URLhttps://bugs.launchpad.net/ubuntu/ PRIVACY_POLICY_URLhttps://www.ubuntu.com/legal/terms-and-policies/privacy-policy VERSION_CODENAMEfocal UBUNTU_CODENAMEfocal8.2.2 系统初始化# 更新软件源 apt update apt upgrade -y # 安装基础工具 apt install -y net-tools iproute2 iputils-ping curl9.安装 Node.js 22 和 OpenClaw本地大模型部署内容在下边需要提前部署好本地大模型方便后续openclaw连接9.1 安装nodejs 22 版本v22.22.1# 添加 NodeSource 官方源并安装 Node.js 22 curl -fsSL https://deb.nodesource.com/setup_22.x | bash - apt install -y nodejs # 验证 Node.js 版本应为 v22.22.1 node --version安装nodejs22过程9.2 安装git# 安装gitopenclaw需要 apt install -y git安装git过程9.3 安装openclaw9.3.1 安装openclaw# 全局安装 OpenClaw npm install -g openclawlatestrootlocalhost:~# npm install -g openclawlatest npm warn deprecated node-domexception1.0.0: Use your platforms native DOMException instead added 539 packages in 6m 89 packages are looking for funding run npm fund for details9.3.2 启动openclaw gateway# 启动 OpenClaw gateway默认端口 18789 openclaw gateway提示缺少配置需要咱们先执行“openclaw setup”进行初始化配置或者跳过配置都可以rootlocalhost:~# openclaw gateway OpenClaw 2026.3.13 (61d171a) — Im not saying your workflow is chaotic... Im just bringing a linter and a helmet. 05:48:49 Missing config. Run openclaw setup or set gateway.modelocal (or pass --allow-unconfigured).9.3.3 运行 openclaw setup 生成配置文件方法一直接生成配置文件后续配置rootlocalhost:~# openclaw setup OpenClaw 2026.3.13 (61d171a) — Im like tmux: confusing at first, then suddenly you cant live without me. Wrote ~/.openclaw/openclaw.json Workspace OK: ~/.openclaw/workspace Sessions OK: ~/.openclaw/agents/main/sessions方法二通过交互式窗口生成配置文件openclaw交互配置过程9.3.4 openclaw配置连接本地大模型获取openclaw连接本地大模型的id可以看到id为Qwen3.5-4B在部署大模型的时候可以指定模型名称- --served-model-name - Qwen3.5-4B使用下列命令可以看到idrootlocalhost lipengcheng]# curl http://172.16.4.28:8000/v1/models {object:list,data:[{id:Qwen3.5-4B,object:model,created:1774180466,owned_by:vllm,root:/model,parent:null,max_model_len:32768,permission:[{id:modelperm-ab46652e69e81417,object:model_permission,created:1774180466,allow_create_engine:false,allow_sampling:true,allow_logprobs:true,allow_search_indices:false,allow_view:true,allow_fine_tuning:false,organization:*,group:null,is_blocking:false}]}]}配置文件~/.openclaw/openclaw.json可根据自己的实际情况修改我这里只修改或者添加了基础信息比如本地大模型的 baseUrlapiKeyidnamecontextWindowmaxTokens等models: { mode: merge, // 【模板】合并模式固定写法保持 merge providers: { vllm: { // 【模板】提供商名称 vllm固定写法可自定义但通常不变 // 以下为【本地需修改】字段 baseUrl: http://172.16.4.28:8000/v1, // ⚠️ 本地修改你的 vLLM 服务地址IP:端口/v1 apiKey: local_vllm_key, // ⚠️ 本地修改自定义 API KeyvLLM 默认不校验可任意填 // api: openai-completions, // 【模板】API 类型固定 openai-completions models: [ { // 以下为【本地需修改】字段 id: Qwen3.5-4B, // ⚠️ 本地修改模型唯一标识必须与 defaults.model.primary 值一致 name: Qwen3.5-4B, // ⚠️ 本地修改模型显示名称可随意不影响匹配 contextWindow: 32768, // ⚠️ 本地修改模型上下文长度必须与 vLLM 的 --max-model-len 相同 maxTokens: 8192 // ⚠️ 本地修改单次最大输出 token 数≤ contextWindow - 输入长度 // // 以下为【模板】字段固定不变 reasoning: false, // 【模板】本地模型不支持推理链固定 false input: [text], // 【模板】输入类型固定 [text] cost: { // 【模板】本地模型成本为 0 input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } // } ] } } }agent需要添加 agents.defaults.model.primary的值需要增加前缀vllm因为的大模型是从vllm中获取的 如果使用openai部署的需改改为openai后边的是大模型的id需要和model模块中的id保持一致agents: { // 模板部分 defaults: { // 【模板】所有 agent 的默认配置 // ----- 本地需修改 ----- model: { primary: vllm/Qwen3.5-4B // ⚠️ 本地修改指定使用的模型完整标识必须与 models 中的 provider/id 匹配 }, // ----- 模板部分一般不动 ----- workspace: /root/.openclaw/workspace, // 【模板】agent 工作目录存放对话历史、缓存等 compaction: { // 【模板】上下文压缩策略 mode: safeguard // 【模板】安全模式当上下文即将超限时自动压缩 } } }9.3.5 配置局域网访问openclaw默认只能127访问~/.openclaw/openclaw.json 中的gateway模块中的 mode: local, 此值必须为local否则openclaw gateway会阻断启动# 将网关绑定的网络接口设置为“lan”通常意味着监听局域网 IP而非仅 localhost # 使得局域网内其他设备可以访问 OpenClaw 的 Web 界面或 API。 openclaw config set gateway.bind lan # 允许在非 HTTPS 环境下使用控制台 UI 的身份验证。 # 默认情况下OpenClaw 可能要求 HTTPS 才能进行登录启用此选项可以允许不安全的 HTTP 连接 # 方便在局域网内测试但生产环境不建议开启。 openclaw config set gateway.controlUi.allowInsecureAuth true # 允许使用请求头中的 Host 或 Origin 作为回退来验证跨域访问。 # 当代理或反向代理导致正常的安全检查失败时开启此选项可以绕过部分限制 # 使局域网内的前端能正常访问网关 API。 openclaw config set gateway.controlUi.dangerouslyAllowHostHeaderOriginFallback true # 完全禁用设备配对认证机制。 # 通常 OpenClaw 要求新设备进行授权确认关闭此选项后任何能访问网关的设备都可以直接使用 # 方便在受信任的局域网环境中快速接入但会降低安全性。 openclaw config set gateway.controlUi.dangerouslyDisableDeviceAuth true9.3.6 连接openclaw的web ui需要从~/.openclaw/openclaw.json配置文件中auth模块中获取token然后登录webui的时候需要填写http://openclaw ip:18789/9.3.7 在openclaw web ui中发送你好测试10.本地服务器大模型部署centos或者ubuntu操作系统我这是使用的centos7.9的操作系统10.1 docker安装https://www.cnblogs.com/Leonardo-li/p/1824628810.2 下载vLLM20.7G# latest版本对应v0.17.1 docker pull vllm/vllm-openai:latest10.3 使用modescope下载千问模型查看modescope支持的模型https://www.modelscope.cn/models我的是NVIDIA T416G显存所以选择了Qwen3.5-4B模型实际选择模型需要根据自己的算力情况最开始测试的Qwen3.5-9B, 运行不起来Qwen3.5-4B占用了11.7G的显存# 下载modescope ,使用 modelscope推荐国内网络 pip3 install modelscope -i https://pypi.tuna.tsinghua.edu.cn/simple # 使用 ModelScope 下载 Qwen3.5-4B python3 -c from modelscope.hub.snapshot_download import snapshot_download; snapshot_download(Qwen/Qwen3.5-4B, cache_dir/data/lipengcheng/models)10.4 编写使用vllm启动qwen3.5-4B模型的docker-compose.yaml文件version: 3.8 services: vllm: image: vllm/vllm-openai:latest container_name: vllm_qwen restart: unless-stopped privileged: true ports: - 8000:8000 volumes: - /data/lipengcheng/models/Qwen/Qwen3.5-4B:/model - /etc/localtime:/etc/localtime:ro environment: - CUDA_VISIBLE_DEVICES1 - OPENBLAS_NUM_THREADS1 - OMP_NUM_THREADS1 - VLLM_DISABLE_TRACING1 - VLLM_USE_V10 - OTEL_SDK_DISABLEDtrue - OTEL_PYTHON_DISABLED_INSTRUMENTATIONSall ulimits: nproc: 65535 nofile: 65535 shm_size: 10g command: - /model - --tensor-parallel-size - 1 - --dtype - float16 - --gpu-memory-utilization - 0.9 #使用90%的模型能力 - --max-model-len - 32768 #模型上下文长度必须大于16000因为openclaw要求大于16000 - --served-model-name - Qwen3.5-4B # 添加这一行指定 API 返回的模型 id - --max-num-seqs - 1 - --trust-remote-code - --enable-auto-tool-choice - --tool-call-parser - hermes # 解析器名称根据模型可选 hermes / mistral / llama3_json / qwen deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu]启动容器加载模型启动时间较慢我这边启动了40多分钟也是根据你的服务器性能资源决定docker-compose up -dvllm加载模型启动输出日志访问大模型进行测试已经可以正常问了但由于我是用的是qwen3.5-4B基础模型所以返回的数据中有些注释之类的先忽略主要是为了oepnclaw接入本地大模型测试后期在调整大模型[rootlocalhost lipengcheng]# curl http://localhost:8000/v1/chat/completions -H Content-Type: application/json -d { model: /model, messages: [{role: user, content: 你好}], max_tokens: 100 } {id:chatcmpl-bd5b7c3d595dd29e,object:chat.completion,created:1774074680,model:/model,choices:[{index:0,message:{role:assistant,content:Thinking Process:\n\n1. **Analyze the Input:**\n * Input: \你好\ (Nǐ hǎo)\n * Language: Chinese\n * Meaning: \Hello\\n * Intent: Greeting, initiating conversation.\n\n2. **Determine the appropriate response:**\n * Tone: Friendly, polite, helpful.\n * Content: Return the greeting, offer assistance.\n * Language,refusal:null,annotations:null,audio:null,function_call:null,tool_calls:[],reasoning:null},logprobs:null,finish_reason:length,stop_reason:null,token_ids:null}],service_tier:null,system_fingerprint:null,usage:{prompt_tokens:11,total_tokens:111,completion_tokens:100,prompt_tokens_details:null},prompt_logprobs:null,prompt_token_ids:null,kv_transfer_params:null}11.遇到的问题11.1 使用清华源执行更新时报错如下# 1.修改pkg为清华源 $ vi $PREFIX/etc/apt/sources.list ##替换为清华源 deb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main # 2. 更新源命令 $ pkg update # 3. 关键报错信息 CANNOT LINK EXECUTABLE: library libssl.so.1.1 not found E: Method https has died unexpectedly! # 4. 解决方法 # 4.1 可以试着把源https修改为http deb http://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main # 4.2 执行更新 pkg update # 4.3 安装修复https工具 pkg install openssl1.1-tool -y # 4.4 将清华源http修改为https deb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main11.2 由于安卓6.0的限制termux底层只能按照nodejs 12的版本安装不了高版本11.3 openclaw报错这个错误是因为 vLLM 后端在响应 OpenClaw 的工具调用请求时缺少必要的启动参数。错误信息 400 auto tool choice requires --enable-auto-tool-choice and --tool-call-parser to be set 表示 vLLM 需要启用工具调用功能但你当前的启动命令中未包含相关配置。原因OpenClaw 的 Agent 可能尝试使用工具如联网搜索、计算器等并在请求中设置了 tool_choice: auto。 vLLM 默认不支持工具调用function calling需要显式添加 --enable-auto-tool-choice 和 --tool-call-parser 参数在启动vllm时在command最后添加3行command: - /model - --tensor-parallel-size - 1 - --dtype - float16 - --gpu-memory-utilization - 0.9 - --max-model-len - 32768 - --served-model-name - Qwen3.5-4B - --max-num-seqs - 1 - --trust-remote-code # 添加如下3行 - --enable-auto-tool-choice - --tool-call-parser - hermes