{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/zh/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Linux服务器部署","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"linux服务器部署","__idx":0},"children":["Linux服务器部署"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["在无头 Ubuntu 服务器上部署 MoreLogin，并通过本地 API 自动执行浏览器 — 无需桌面环境。"]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"你将取得什么成就","__idx":1},"children":["你将取得什么成就"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["读完本指南后，您将拥有："]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Ubuntu 24.04 无头服务器上运行的 MoreLogin 实例"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["配置网络转发，以便外部计算机可以通过 CDP（Chrome DevTools 协议）进行连接"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["一个有效的 Python 自动化脚本，用于创建、启动、控制和清理浏览器"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"架构概述","__idx":2},"children":["架构概述"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"┌──────────────────────────────────────────────────────────┐\n│                    Ubuntu 24.04 Server                   │\n│                                                          │\n│  ┌──────────────┐    ┌───────────────────────────────┐   │\n│  │   xvfb       │───▶│  MoreLogin AppImage           │   │\n│  │ (virtual     │    │  Local API :40000             │   │\n│  │  display)    │    │  CDP debug :<dynamic>         │   │\n│  │              │    │    (127.0.0.1, per profile)   │   │\n│  └──────────────┘    └───────────────────────────────┘   │\n│                              │                           │\n│                        socat forwarding                  │\n│                              │                           │\n│                     0.0.0.0:40001 → 127.0.0.1:40000      │\n│                     0.0.0.0:<N+1> → 127.0.0.1:<N>        │\n└──────────────────────────────────────────────────────────┘\n                               │\n                          External machine\n                     (Playwright / Puppeteer / Selenium)\n"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!NOTE]"," ","CDP 调试端口是",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["动态"]}," — 每个浏览器都有自己的端口，由 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/start"]}," 端点返回。上图使用 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["<N>"]}," 作为占位符。"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"先决条件","__idx":3},"children":["先决条件"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"要求"},"children":["要求"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"详情"},"children":["详情"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["操作系统"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Ubuntu 24.04 服务器 (x86_64)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["推荐规格"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["8 个 vCPU、8 GB RAM（支持 ~5 个并发浏览器环境）"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["网络"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["出站互联网访问；打开入站端口 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["40001"]}," 和您选择的转发 CDP 端口，或改用 SSH 隧道"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python"]},"（可选）"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Python 3.8+ 和 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pip"]}," 用于运行示例脚本"]}]}]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"第-1-步--安装系统依赖项","__idx":4},"children":["第 1 步 — 安装系统依赖项"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["通过 SSH 连接到您的服务器并安装所需的软件包："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# FUSE support (required for AppImage)\nsudo apt install -y libfuse2t64\n\n# GTK / accessibility / display libraries\nsudo apt install -y libatk1.0-0 libatk-bridge2.0-0 libatspi2.0-0\nsudo apt install -y libcups2\nsudo apt install -y libgtk-3-0 libgdk-pixbuf2.0-0\nsudo apt install -y libgbm1 libxkbcommon0 libasound2t64\n\n# Virtual framebuffer (headless display)\nsudo apt install -y xvfb\n\n# TCP forwarder\nsudo apt install -y socat\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"安装字体可选","__idx":5},"children":["安装字体（可选）"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["如果浏览器页面呈现无文本或显示缺失字符，请安装相应的字体包："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# CJK (Chinese, Japanese, Korean)\nsudo apt install -y fonts-noto-cjk fonts-noto-cjk-extra\n\n# Arabic\nsudo apt install -y fonts-noto-color-emoji fonts-noto-extra\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["对于其他语言，请安装匹配的",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://fonts.google.com/noto"},"children":["Noto 字体系列"]}," 软件包。"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"第-2-步--下载并启动-morelogin","__idx":6},"children":["第 2 步 — 下载并启动 MoreLogin"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"21-下载appimage","__idx":7},"children":["2.1 下载AppImage"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"wget https://get.morelogin.com/client/prod/linux/x64/2.54.0/MoreLogin_x86_64_2.54.0.AppImage\nchmod +x MoreLogin_x86_64_2.54.0.AppImage\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["将 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["2.54.0"]}," 替换为您的 MoreLogin 帐户或",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.morelogin.com/download/"},"children":["下载页面"]}," 上提供的最新版本。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"22-后台启动-morelogin","__idx":8},"children":["2.2 后台启动 MoreLogin"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["使用 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["xvfb-run"]}," 提供虚拟显示，然后运行 AppImage："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"nohup xvfb-run -a ./MoreLogin_x86_64_2.54.0.AppImage --no-sandbox > morelogin.log 2>&1 &\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["验证是否启动成功："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Check the process is running\nps aux | grep MoreLogin\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["该过程可能需要 5-10 秒才能完全初始化。"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"第3步通过api登录morelogin必填","__idx":9},"children":["第3步——通过API登录MoreLogin（必填）"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!WARNING]"," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["您必须先登录，然后才能调用任何其他本地 API 端点。"]}," 在无头服务器上，没有用于手动登录的 GUI，因此您必须通过 API 进行身份验证。如果没有这一步，所有 API 调用都将返回："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\"status\": \"error\", \"code\": 401, \"message\": \"您的登录状态已过期，请重新登录\"}\n","lang":"json"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"31-获取您的-api-凭证","__idx":10},"children":["3.1 获取您的 API 凭证"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["打开 MoreLogin 桌面客户端（在您登录的任何计算机上）并导航至 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["设置 → API 和 MCP"]},"。从 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Open API"]}," 部分复制 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["APP ID"]}," 和 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API Key"]},"："]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image.cfac9a4c31ae47e8434739e42cab4601ee08d737bba4fccba40f2f3bc78e9648.2f2649be.png","alt":"MoreLogin API 设置 — 从 Open API 部分复制 APP ID 和 API Key"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"32-通过-curl-登录","__idx":11},"children":["3.2 通过 curl 登录"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["使用您的凭据调用登录端点："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST http://127.0.0.1:40000/api/user/login \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"apiId\": \"YOUR_APP_ID\",\n    \"apiKey\": \"YOUR_API_KEY\"\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["成功的响应如下所示："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\"code\": 0, \"msg\": null, \"data\": true}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"33-验证登录","__idx":12},"children":["3.3 验证登录"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["通过列出浏览器来确认 API 已准备就绪："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -s -X POST http://127.0.0.1:40000/api/env/page \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"pageNo\": 1, \"pageSize\": 1}'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{\"code\":0, ...}"]}," 响应表示您已登录且 API 已准备就绪。"]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["检查点："]}," 您的 MoreLogin 服务器已完全运行。继续进行",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-4--configure-network-forwarding-socat"},"children":["步骤 4"]}," 进行远程访问，或者如果在同一服务器上运行脚本，则直接跳到",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-5--quick-automation-example"},"children":["步骤 5"]},"。"]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!NOTE]"," ","只要 MoreLogin 进程正在运行，登录会话就会持续存在。如果重新启动AppImage，则需要重新登录。"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"步骤-4--配置网络转发-socat","__idx":13},"children":["步骤 4 — 配置网络转发 (socat)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["默认情况下，本地 API (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[":40000"]},") 和 CDP 调试端口都绑定到 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["127.0.0.1"]},"。如果您需要从外部计算机（例如您的开发笔记本电脑）访问它们，请使用 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["socat"]}," 转发流量。"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!WARNING]"," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["安全风险 - 不要将这些端口暴露给公共互联网。"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["对于大多数端点，本地 API ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["没有内置身份验证"]},"。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["CDP 调试端口授予浏览器实例的",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["完全远程控制"]},"（读取 cookie、注入脚本、捕获屏幕截图）。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["建议："]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["使用 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["SSH 隧道"]}," 而不是 socat 进行远程访问：",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ssh -L 40000:127.0.0.1:40000 user@server"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["如果您必须使用 socat，请使用防火墙规则将访问限制为 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["仅限特定 IP"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["使用 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["VPN"]}," 或云提供商安全组来限制入站流量"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["绝不"]},"在没有 IP 限制的面向公众的服务器上打开到 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0.0.0.0"]}," 的端口 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["40001"]}," / CDP 端口"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"41-转发本地api端口","__idx":14},"children":["4.1 转发本地API端口"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"nohup socat TCP-LISTEN:40001,fork,reuseaddr,bind=0.0.0.0 TCP:127.0.0.1:40000 &\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["外部计算机现在可以访问位于 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["http://<server-ip>:40001"]}," 的 API。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"42-转发-cdp-调试端口","__idx":15},"children":["4.2 转发 CDP 调试端口"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["当您通过 API 启动浏览器时，响应会包含",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["动态"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["debugPort"]},"（例如 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["9222"]},"）。每个浏览器环境可能接收不同的端口。转发它，以便外部自动化工具（Playwright、Puppeteer、Selenium）可以连接："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Example: if debugPort=9222, forward to external port 9223 (debugPort + 1)\n# Adjust both ports to match the actual debugPort returned by /api/env/start\nnohup socat TCP-LISTEN:9223,fork,reuseaddr,bind=0.0.0.0 TCP:127.0.0.1:9222 &\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!WARNING]"," ","同时运行多个浏览器时，请确保转发的端口不会与其他浏览器的调试端口发生冲突。例如，如果浏览器环境 A 收到 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["debugPort=9222"]},"，并且您转发到 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["9223"]},"，但浏览器环境 B 收到 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["debugPort=9223"]},"，则会出现端口冲突。考虑使用更大的偏移量或专用端口范围。"]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!TIP]"," ","在生产中，在每次 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/start"]}," 调用后使用返回的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["debugPort"]}," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["动态"]},"创建 socat 转发。请参阅 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#52-create--start--automate--cleanup"},"children":["Python 示例"]}," 了解有效的实现。"]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["如果在同一服务器上运行自动化脚本，您可以跳过 socat 并直接连接到 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["127.0.0.1"]},"。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"43-开放防火墙端口","__idx":16},"children":["4.3 开放防火墙端口"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["如果您使用 socat，请仅限制对受信任 IP 的访问："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Allow only a specific IP (recommended)\nsudo ufw allow from <YOUR_IP> to any port 40001 proto tcp\nsudo ufw allow from <YOUR_IP> to any port 9223 proto tcp\n\n# Or allow from any IP (NOT recommended for production)\n# sudo ufw allow 40001/tcp\n# sudo ufw allow 9223/tcp\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"44-推荐使用-ssh-隧道","__idx":17},"children":["4.4 推荐：使用 SSH 隧道"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["为了实现最安全的远程访问，请使用 SSH 隧道 — 无需更改防火墙或 socat。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["由于 CDP 端口是",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["动态"]},"（在启动浏览器时分配），因此工作流程为："]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["首先为 API 端口建立隧道："]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Run this on your local machine\nssh -L 40000:127.0.0.1:40000 user@<server-ip>\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["通过隧道 API (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["http://127.0.0.1:40000/api/env/start"]},") 启动浏览器"]},"并读取返回的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["debugPort"]},"。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["为 CDP 端口打开第二条隧道："]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Replace <debugPort> with the actual port returned by the API\nssh -L <debugPort>:127.0.0.1:<debugPort> user@<server-ip>\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["从本地 Playwright/Puppeteer 脚本",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["连接"]},"到 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["http://127.0.0.1:<debugPort>"]},"，就像服务器位于本地一样。"]}]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!TIP]"," ","如果您事先知道端口范围，则可以将两个隧道组合在一个命令中，例如："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"ssh -L 40000:127.0.0.1:40000 -L 9222:127.0.0.1:9222 -L 9223:127.0.0.1:9223 user@<服务器IP>\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["但实际上，首先启动 API 隧道，然后根据需要添加每个浏览器的隧道会更容易。"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"第-5-步--快速自动化示例","__idx":18},"children":["第 5 步 — 快速自动化示例"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["下面是一个最小的 Python 示例，显示了浏览器的完整生命周期。有关具有并发性和错误处理功能的完整生产就绪脚本，请参阅 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/MoreLoginBrowser/MoreLogin-API-Demos/blob/main/MoreLogin-Python/linux_server_test.py"},"children":["GitHub 上的完整示例"]},"。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"51-安装python依赖项","__idx":19},"children":["5.1 安装Python依赖项"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"pip install requests playwright\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Playwright 在此仅用于其 CDP 客户端 (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["connect_over_cdp"]},")。您",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["不需要"]},"运行 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["playwright install"]}," — MoreLogin 提供自己的浏览器。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"52-为浏览器环境设置---no-sandbox-linux-必需","__idx":20},"children":["5.2 为浏览器环境设置 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]},"（Linux 必需）"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["在 Linux Server 上，浏览器引擎",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["必须"]},"使用 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]}," 标志运行。您需要在创建或修改浏览器环境时，通过 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startupParams"]}," 字段传递此参数。"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!CAUTION]"," ","如果缺少 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]},"，浏览器在大多数 Linux 服务器环境中（特别是以 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["root"]}," 用户运行或缺少完整桌面会话时）将无法启动。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"新建环境--创建时包含-startupparams","__idx":21},"children":["新建环境 — 创建时包含 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startupParams"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["使用 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/create/advanced"]}," 创建包含 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startupParams"]}," 的环境（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/create/quick"]}," 接口",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["不支持"]},"此字段）："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST http://127.0.0.1:40000/api/env/create/advanced \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"browserTypeId\": 1,\n    \"operatorSystemId\": 5,\n    \"startupParams\": [\"--no-sandbox\"]\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!TIP]"," ","如果您使用 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/create/quick"]}," 创建了环境，请在启动前调用 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/update"]}," 添加 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]}," — 参见下方。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"已有环境--通过-apienvupdate-修改","__idx":22},"children":["已有环境 — 通过 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/update"]}," 修改"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["如果您已有的浏览器环境在创建时未包含 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]},"，请在启动前进行更新："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST http://127.0.0.1:40000/api/env/update \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"envId\": \"YOUR_ENV_ID\",\n    \"startupParams\": [\"--no-sandbox\"]\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!NOTE]"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startupParams"]}," 字段接受字符串数组。您也可以在此添加其他 Chrome 标志（例如 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["[\"--no-sandbox\", \"--disable-gpu\"]"]},"）。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]}," 标志仅在 Linux 上需要 — Windows 和 macOS 环境无需此设置。"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"53-创建启动自动化清理","__idx":23},"children":["5.3 创建→启动→自动化→清理"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["此示例假设脚本与 MoreLogin ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["在同一服务器"]},"上运行。远程场景请参见代码后的注释。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\nfrom playwright.sync_api import sync_playwright\n\n# ── Configuration ──────────────────────────────────────────\n# Local:  script runs on the SAME server as MoreLogin\n# Remote: script runs on a DIFFERENT machine — see notes below\nAPI_BASE  = \"http://127.0.0.1:40000\"\n\n\n# ① Create a browser profile\nresp = requests.post(f\"{API_BASE}/api/env/create/quick\", json={\n    \"browserTypeId\": 1,\n    \"operatorSystemId\": 5,\n    \"quantity\": 1\n})\nresp_data = resp.json()\nassert resp_data[\"code\"] == 0, f\"Create failed: {resp_data}\"\nenv_id = resp_data[\"data\"][\"envIds\"][0]\nprint(f\"✅ Created profile: {env_id}\")\n\n\n# ①-b Add --no-sandbox (required on Linux Server)\nresp = requests.post(f\"{API_BASE}/api/env/update\", json={\n    \"envId\": env_id,\n    \"startupParams\": [\"--no-sandbox\"]\n})\nresp_data = resp.json()\nassert resp_data[\"code\"] == 0, f\"Update failed: {resp_data}\"\nprint(f\"✅ Set --no-sandbox for profile: {env_id}\")\n\n\n# ② Start the profile (headless)\nresp = requests.post(f\"{API_BASE}/api/env/start\", json={\n    \"envId\": env_id\n})\nresp_data = resp.json()\nassert resp_data[\"code\"] == 0, f\"Start failed: {resp_data}\"\ndebug_port = resp_data[\"data\"][\"debugPort\"]   # Dynamic — different for each profile\nprint(f\"✅ Started — debug port: {debug_port}\")\n\n\n# ③ Build the CDP URL\ncdp_url = f\"http://127.0.0.1:{debug_port}\"\n\n\n# ④ Connect via CDP and automate\nwith sync_playwright() as p:\n    browser = p.chromium.connect_over_cdp(cdp_url)\n    page = browser.contexts[0].pages[0]\n    page.goto(\"https://www.google.com\")\n    page.screenshot(path=f\"screenshot_{env_id}.png\")\n    print(f\"✅ Screenshot saved\")\n    # Use disconnect() — not close() — to detach without killing the browser.\n    # The profile will be stopped cleanly via the API in step ⑤.\n    browser.disconnect()\n\n\n# ⑤ Stop the profile\nrequests.post(f\"{API_BASE}/api/env/close\", json={\"envId\": env_id})\nprint(f\"✅ Profile stopped\")\n\n\n# ⑥ Delete the profile\nrequests.post(f\"{API_BASE}/api/env/remove\", json={\"envIds\": [env_id]})\nprint(f\"✅ Profile deleted\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!NOTE]"," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["从远程计算机运行？"]}," 两种方法："]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["选项 A — SSH 隧道（推荐）："]}," ","设置从本地计算机到服务器的 SSH 隧道（请参阅 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#44-recommended-use-ssh-tunnel-instead"},"children":["§ 4.4"]},"），然后保留 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["API_BASE = \"http://127.0.0.1:40000\""]}," 和 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cdp_url = f\"http://127.0.0.1:{debug_port}\""]}," — SSH 使远程端口显示为本地。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["选项 B — 服务器上的 socat："]}," ","在 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["服务器"]}," 上，为 API 端口和每个 CDP 端口启动 socat 转发："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# 在服务器上运行这些，而不是在本地计算机上\nsocat TCP-LISTEN:40001,fork,reuseaddr,bind=0.0.0.0 TCP:127.0.0.1:40000 &\nsocat TCP-LISTEN:$((debug_port+1)),fork,reuseaddr,bind=0.0.0.0 TCP:127.0.0.1:$debug_port &\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["然后在脚本中设置 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["API_BASE = \"http://<server-ip>:40001\""]}," 和 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cdp_url = f\"http://<server-ip>:{debug_port + 1}\""]},"。"," ","⚠️ 使用防火墙规则限制访问 - 请参阅 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#43-open-firewall-ports"},"children":["§ 4.3"]},"。"]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!IMPORTANT]"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resp.json()[\"data\"][\"envIds\"]"]}," 结构与当前的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/create/quick"]}," 响应格式匹配。如果您遇到不同的形状（例如 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data: [\"id1\", ...]"]},"），请检查您的版本的 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/api-reference/browser"},"children":["API 参考"]}," - 响应格式可能因版本而异。"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"性能基准","__idx":24},"children":["性能基准"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["使用",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/MoreLoginBrowser/MoreLogin-API-Demos/blob/main/MoreLogin-Python/linux_server_test.py"},"children":["完整压力测试脚本"]},"在 Ubuntu 24.04 服务器虚拟机（8 个 vCPU、8 GB RAM）上获得以下结果："]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"指标"},"children":["指标"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"数值"},"children":["数值"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["总运行次数"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["100"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["并发"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["4（同时）"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["成功率"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["100.0%"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["总时间"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["604.06秒"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["每项任务的平均时间"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["6.04秒"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["吞吐量"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0.17 任务/秒"]}]}]}]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["这些数字作为基线。实际性能取决于服务器规格、网络条件和页面复杂性。"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"生产部署-systemd","__idx":25},"children":["生产部署 (systemd)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["对于生产服务器，将 MoreLogin 作为 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["systemd 服务"]}," 运行，以在启动时自动启动、在崩溃时重新启动以及集中日志记录。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"创建服务文件","__idx":26},"children":["创建服务文件"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"sudo tee /etc/systemd/system/morelogin.service > /dev/null <<'EOF'\n[Unit]\nDescription=MoreLogin Browser (headless)\nAfter=network-online.target\nWants=network-online.target\n\n[Service]\nType=simple\nUser=root\nWorkingDirectory=/opt/morelogin\nExecStart=/usr/bin/xvfb-run -a /opt/morelogin/MoreLogin_x86_64_2.54.0.AppImage --no-sandbox\nRestart=on-failure\nRestartSec=10\nStandardOutput=journal\nStandardError=journal\n\n[Install]\nWantedBy=multi-user.target\nEOF\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["调整 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["WorkingDirectory"]}," 和 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ExecStart"]}," 路径以匹配您放置 AppImage 的位置。"]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!TIP]"," ","对于生产，请考虑创建专用用户（例如 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["morelogin"]},"）而不是作为 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["root"]}," 运行，并相应地调整文件所有权和权限。如果 AppImage 当前需要 root 权限，您可以保留 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["User=root"]},"，但最佳实践是在非 root 帐户下隔离该进程。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"启用并启动","__idx":27},"children":["启用并启动"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"sudo systemctl daemon-reload\nsudo systemctl enable morelogin    # Auto-start on boot\nsudo systemctl start morelogin     # Start now\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"管理服务","__idx":28},"children":["管理服务"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"sudo systemctl status morelogin    # Check status\nsudo journalctl -u morelogin -f    # Stream logs\nsudo systemctl restart morelogin   # Restart\nsudo systemctl stop morelogin      # Stop\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!NOTE]"," ","重新启动后，您必须再次调用",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#32-log-in-via-curl"},"children":["登录端点"]}," - API 会话无法在进程重新启动后继续存在。对于自动恢复，请考虑添加 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ExecStartPost"]}," 脚本或在服务启动后调用登录端点的运行状况检查 cron 作业。"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"故障排除","__idx":29},"children":["故障排除"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"morelogin-无法启动","__idx":30},"children":["MoreLogin 无法启动"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"AppImages require FUSE to run.\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["修复："]}," 安装 FUSE 支持："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"sudo apt install -y libfuse2t64\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"浏览器页面显示空白文本缺失字符","__idx":31},"children":["浏览器页面显示空白文本/缺失字符"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["修复："]}," 安装目标语言的字体包（请参阅",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#install-fonts-optional"},"children":["步骤 1 - 安装字体"]},"）。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"cdp-连接被外部机器拒绝","__idx":32},"children":["CDP 连接被外部机器拒绝"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["原因："]}," CDP 调试端口默认绑定到 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["127.0.0.1"]},"。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["修复："]}," 设置 socat 转发（请参阅",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-4--configure-network-forwarding-socat"},"children":["步骤 4"]},"）并确保防火墙规则允许转发的端口。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"curl-到本地-api-返回连接被拒绝","__idx":33},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["curl"]}," 到本地 API 返回“连接被拒绝”"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["原因："]}," MoreLogin 尚未完成启动，或进程崩溃。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["修复："]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["启动后等待 5-10 秒"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["检查 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["morelogin.log"]}," 是否有错误"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["验证进程正在运行：",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ps aux | grep MoreLogin"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api返回401登录状态已过期","__idx":34},"children":["API返回401“登录状态已过期”"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\"status\": \"error\", \"code\": 401, \"message\": \"Your login status has expired, please log in again\"}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["原因："]}," 您没有通过API登录，或者MoreLogin进程被重启。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["修复："]}," 在任何其他 API 调用之前调用登录端点（请参阅",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-3--log-in-to-morelogin-via-api-required"},"children":["步骤 3"]},"）。"]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"下一步","__idx":35},"children":["下一步"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"目标"},"children":["目标"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"链接"},"children":["链接"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["完整的浏览器 API 参考"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/api-reference/browser"},"children":["浏览器 API"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["认证设置"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/api-reference/getting-started/authentication"},"children":["身份验证指南"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Playwright / Selenium / Puppeteer 示例"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/api-reference/examples"},"children":["自动化示例"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["完整的Linux压力测试脚本"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/MoreLoginBrowser/MoreLogin-API-Demos/blob/main/MoreLogin-Python/linux_server_test.py"},"children":["GitHub — linux_server_test.py"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["CLI 快速入门"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/cli/quick-start"},"children":["CLI 指南"]}]}]}]}]}]}]},"headings":[{"value":"Linux服务器部署","id":"linux服务器部署","depth":1},{"value":"你将取得什么成就","id":"你将取得什么成就","depth":2},{"value":"架构概述","id":"架构概述","depth":2},{"value":"先决条件","id":"先决条件","depth":2},{"value":"第 1 步 — 安装系统依赖项","id":"第-1-步--安装系统依赖项","depth":2},{"value":"安装字体（可选）","id":"安装字体可选","depth":3},{"value":"第 2 步 — 下载并启动 MoreLogin","id":"第-2-步--下载并启动-morelogin","depth":2},{"value":"2.1 下载AppImage","id":"21-下载appimage","depth":3},{"value":"2.2 后台启动 MoreLogin","id":"22-后台启动-morelogin","depth":3},{"value":"第3步——通过API登录MoreLogin（必填）","id":"第3步通过api登录morelogin必填","depth":2},{"value":"3.1 获取您的 API 凭证","id":"31-获取您的-api-凭证","depth":3},{"value":"3.2 通过 curl 登录","id":"32-通过-curl-登录","depth":3},{"value":"3.3 验证登录","id":"33-验证登录","depth":3},{"value":"步骤 4 — 配置网络转发 (socat)","id":"步骤-4--配置网络转发-socat","depth":2},{"value":"4.1 转发本地API端口","id":"41-转发本地api端口","depth":3},{"value":"4.2 转发 CDP 调试端口","id":"42-转发-cdp-调试端口","depth":3},{"value":"4.3 开放防火墙端口","id":"43-开放防火墙端口","depth":3},{"value":"4.4 推荐：使用 SSH 隧道","id":"44-推荐使用-ssh-隧道","depth":3},{"value":"第 5 步 — 快速自动化示例","id":"第-5-步--快速自动化示例","depth":2},{"value":"5.1 安装Python依赖项","id":"51-安装python依赖项","depth":3},{"value":"5.2 为浏览器环境设置 --no-sandbox （Linux 必需）","id":"52-为浏览器环境设置---no-sandbox-linux-必需","depth":3},{"value":"新建环境 — 创建时包含 startupParams","id":"新建环境--创建时包含-startupparams","depth":4},{"value":"已有环境 — 通过 /api/env/update 修改","id":"已有环境--通过-apienvupdate-修改","depth":4},{"value":"5.3 创建→启动→自动化→清理","id":"53-创建启动自动化清理","depth":3},{"value":"性能基准","id":"性能基准","depth":2},{"value":"生产部署 (systemd)","id":"生产部署-systemd","depth":2},{"value":"创建服务文件","id":"创建服务文件","depth":3},{"value":"启用并启动","id":"启用并启动","depth":3},{"value":"管理服务","id":"管理服务","depth":3},{"value":"故障排除","id":"故障排除","depth":2},{"value":"MoreLogin 无法启动","id":"morelogin-无法启动","depth":3},{"value":"浏览器页面显示空白文本/缺失字符","id":"浏览器页面显示空白文本缺失字符","depth":3},{"value":"CDP 连接被外部机器拒绝","id":"cdp-连接被外部机器拒绝","depth":3},{"value":"curl 到本地 API 返回“连接被拒绝”","id":"curl-到本地-api-返回连接被拒绝","depth":3},{"value":"API返回401“登录状态已过期”","id":"api返回401登录状态已过期","depth":3},{"value":"下一步","id":"下一步","depth":2}],"frontmatter":{"seo":{"title":"Linux服务器部署"}},"lastModified":"2026-07-13T14:51:02.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/zh/linux-server/overview","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}