import{_ as s,c as a,o as h,ah as e}from"./chunks/framework.BJEpWshW.js";const F=JSON.parse('{"title":"Linux 部署","description":"","frontmatter":{},"headers":[],"relativePath":"admin/linux.md","filePath":"admin/linux.md"}'),l={name:"admin/linux.md"};function n(t,i,k,r,p,d){return h(),a("div",null,[...i[0]||(i[0]=[e(`<h1 id="linux-部署" tabindex="-1">Linux 部署 <a class="header-anchor" href="#linux-部署" aria-label="Permalink to “Linux 部署”">​</a></h1><p>在 Linux 服务器上运行 WebAI2API 的特殊配置说明。</p><h2 id="显示方式选择" tabindex="-1">显示方式选择 <a class="header-anchor" href="#显示方式选择" aria-label="Permalink to “显示方式选择”">​</a></h2><p>在 Linux 服务器上运行非无头模式时，需要配置显示环境。</p><h3 id="方式一-xvfb-vnc-推荐" tabindex="-1">方式一：Xvfb + VNC (推荐) <a class="header-anchor" href="#方式一-xvfb-vnc-推荐" aria-label="Permalink to “方式一：Xvfb + VNC (推荐)”">​</a></h3><p>使用虚拟显示器运行程序，通过 VNC 远程查看。</p><h4 id="使用内置命令" tabindex="-1">使用内置命令 <a class="header-anchor" href="#使用内置命令" aria-label="Permalink to “使用内置命令”">​</a></h4><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">npm</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> start</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -xvfb</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -vnc</span></span></code></pre></div><p>这会自动：</p><ul><li>启动 Xvfb 虚拟显示器</li><li>启动 x11vnc 服务器</li><li>可通过 WebUI 直接查看 VNC 画面</li></ul><h4 id="手动配置" tabindex="-1">手动配置 <a class="header-anchor" href="#手动配置" aria-label="Permalink to “手动配置”">​</a></h4><p>如果内置命令无法满足需求：</p><ol><li><strong>启动虚拟显示器</strong></li></ol><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">xvfb-run</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --server-num=99</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --server-args=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;-ac -screen 0 1920x1080x24&quot;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> npm</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> start</span></span></code></pre></div><ol start="2"><li><strong>映射到 VNC</strong></li></ol><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">x11vnc</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -display</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> :99</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -localhost</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -nopw</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -forever</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -noxdamage</span></span></code></pre></div><h2 id="vnc-连接" tabindex="-1">VNC 连接 <a class="header-anchor" href="#vnc-连接" aria-label="Permalink to “VNC 连接”">​</a></h2><h3 id="通过-ssh-隧道-推荐" tabindex="-1">通过 SSH 隧道 (推荐) <a class="header-anchor" href="#通过-ssh-隧道-推荐" aria-label="Permalink to “通过 SSH 隧道 (推荐)”">​</a></h3><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 本地终端</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ssh</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -L</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 5900:127.0.0.1:5900</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> root@服务器IP</span></span></code></pre></div><p>然后使用 VNC 客户端连接 <code>127.0.0.1:5900</code>。</p><h3 id="通过-webui" tabindex="-1">通过 WebUI <a class="header-anchor" href="#通过-webui" aria-label="Permalink to “通过 WebUI”">​</a></h3><p>服务启动后，访问 WebUI 的「VNC 显示」页面即可直接查看。</p><h3 id="安装依赖" tabindex="-1">安装依赖 <a class="header-anchor" href="#安装依赖" aria-label="Permalink to “安装依赖”">​</a></h3><h3 id="ubuntu-debian" tabindex="-1">Ubuntu/Debian <a class="header-anchor" href="#ubuntu-debian" aria-label="Permalink to “Ubuntu/Debian”">​</a></h3><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> update</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> apt-get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xvfb</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> x11vnc</span></span></code></pre></div><h3 id="centos-rhel" tabindex="-1">CentOS/RHEL <a class="header-anchor" href="#centos-rhel" aria-label="Permalink to “CentOS/RHEL”">​</a></h3><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> yum</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xorg-x11-server-Xvfb</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> x11vnc</span></span></code></pre></div><h3 id="arch-linux" tabindex="-1">Arch Linux <a class="header-anchor" href="#arch-linux" aria-label="Permalink to “Arch Linux”">​</a></h3><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sudo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> pacman</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -S</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xorg-server-xvfb</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> x11vnc</span></span></code></pre></div><h3 id="方式二-x11-转发" tabindex="-1">方式二：X11 转发 <a class="header-anchor" href="#方式二-x11-转发" aria-label="Permalink to “方式二：X11 转发”">​</a></h3><p>适用于通过 SSH 连接服务器的场景。</p><ol><li>在本地安装 X Server（如 VcXsrv、Xming）</li><li>使用支持 X11 转发的终端（如 WindTerm）</li><li>在 SSH 会话中启用 X11 转发</li></ol><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ssh</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -X</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> user@server</span></span></code></pre></div><h2 id="docker-部署" tabindex="-1">Docker 部署 <a class="header-anchor" href="#docker-部署" aria-label="Permalink to “Docker 部署”">​</a></h2><p>Docker 镜像已内置 Xvfb 和 VNC 支持：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">docker</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> run</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -d</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> webai2api</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \\</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">  -p</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 3000:3000</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -p</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 5900:5900</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \\</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">  -v</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;$(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">pwd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">)/data:/app/data&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \\</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">  -e</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> LOGIN_MODE=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \\</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">  --shm-size=2gb</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \\</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">  foxhui/lmarena-imagen-automator:latest</span></span></code></pre></div><p>通过 VNC 客户端连接 <code>localhost:5900</code> 完成登录。</p><h2 id="常见问题" tabindex="-1">常见问题 <a class="header-anchor" href="#常见问题" aria-label="Permalink to “常见问题”">​</a></h2><h3 id="端口被占用" tabindex="-1">端口被占用 <a class="header-anchor" href="#端口被占用" aria-label="Permalink to “端口被占用”">​</a></h3><p>如果 5900 端口已被占用，VNC 服务器会自动查找 5901-5999 范围内可用的端口。</p><h3 id="显示号冲突" tabindex="-1">显示号冲突 <a class="header-anchor" href="#显示号冲突" aria-label="Permalink to “显示号冲突”">​</a></h3><p>Xvfb 会自动从 50 开始查找可用的显示号，避免与现有 X 服务器冲突。</p>`,42)])])}const o=s(l,[["render",n]]);export{F as __pageData,o as default};
