{"slug":"phira-mp","title":"Phira多人联机服务器搭建/使用教程","description":"懒人可以直接下载预构建的可执行文件，但如果想获得日志需要自备Rust环境","coverImage":"https://b.acofork.com/img/phira-mp-2024-11-06-08-20-39-image.webp","coverWidth":1283,"coverHeight":792,"date":"2024-11-05","tags":["服务器"],"pinned":false,"wordCount":540,"html":"<h2 id=\"直接下载服务端文件并运行\">直接下载服务端文件并运行</h2><p><a href=\"https://github.com/afoim/phira-mp-autobuild\" target=\"_blank\" rel=\"noopener noreferrer\">https://github.com/afoim/phira-mp-autobuild</a></p>\n<p>这里有一些由Github Action自动构建的服务端文件，涵盖以下系统和架构<img src=\"https://b.acofork.com/img/phira-mp-2024-11-06-08-28-34-image.webp\" alt=\"\" width=\"480\" height=\"318\" loading=\"eager\" decoding=\"async\" /></p>\n<p>也可以前往<a href=\"https://phira.dmocken.top/Multiplayer%20Server%E5%A4%9A%E4%BA%BA%E6%B8%B8%E6%88%8F%E6%9C%8D%E5%8A%A1%E5%99%A8\" target=\"_blank\" rel=\"noopener noreferrer\">Multiplayer Server | Dmocken的Phira下载站</a>自行寻找</p>\n<p>寻找适用于你的系统的文件，下载下来并执行即可。默认服务端将会在你的主机12346端口上开放，如果需要自定义端口，请使用<code>--port</code>参数指定端口。然后即可使用Phira来填写IP/域名:端口来连接</p>\n<p>*如果要显示Log，请使用 <code>RUST_LOG=debug ./xxx</code> 去运行，默认日志等级是 <code>WARN</code></p>\n<p>如果这些文件不适用于你正在使用的系统请前往<a href=\"#自行构建高级\">自行构建（高级）</a>继续阅读</p>\n<h2 id=\"自行构建-高级\">自行构建（高级）</h2><p>由于phira-mp使用Rust编写，若想要自行构建需要在你的操作系统上安装Rust环境</p>\n<h3 id=\"对于windows\">对于Windows</h3><p>前往<a href=\"https://www.rust-lang.org/zh-CN/learn/get-started\" target=\"_blank\" rel=\"noopener noreferrer\">Rust 下载页</a>，下载 Rust  <img src=\"https://b.acofork.com/img/phira-mp-2024-11-06-09-57-44-6b333b87e835dfa299b0c3c95e5ea4e0.webp\" alt=\"\" width=\"3840\" height=\"1888\" loading=\"lazy\" decoding=\"async\" />\n打开后会弹出一个 CMD 窗口，输入 1（Quick Install）回车，等待 Visual Studio 安装（如果此步 Visual Studio 下载很慢也可以<a href=\"https://visualstudio.microsoft.com/zh-hans/downloads/\" target=\"_blank\" rel=\"noopener noreferrer\">手动下载</a>）  </p>\n<p><img src=\"https://b.acofork.com/img/phira-mp-2024-11-06-09-57-49-61b4d36dc8cd1ce47da66be5e2a920cd.webp\" alt=\"\" width=\"2048\" height=\"1071\" loading=\"lazy\" decoding=\"async\" />在 Visual Studio 中，勾选<strong>使用 C++ 的桌面开发</strong>，然后安装<br /><img src=\"https://b.acofork.com/img/phira-mp-2024-11-06-09-58-05-390c775c83dc245b0690fda699bfee5f.webp\" alt=\"\" width=\"3840\" height=\"1946\" loading=\"lazy\" decoding=\"async\" />然后请跳过 Linux 教程直接阅读<a>构建 phira-mp</a></p>\n<h3 id=\"对于linux\">对于Linux</h3><p>执行：<code>curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh</code></p>\n<p>选择 1 回车</p>\n<p>执行：<code>source $HOME/.cargo/env</code></p>\n<h2 id=\"使用rust构建phira-mp\">使用Rust构建phira-mp</h2><p>克隆仓库：<code>git clone https://github.com/TeamFlos/phira-mp.git</code>（不支持IPv6）或<code>git clone https://github.com/afoim/phira-mp-autobuild.git</code>（支持IPv6）</p>\n<p><code>cd phira-mp</code>或<code>cd phira-mp-autobuild</code></p>\n<p>更新依赖：<code>cargo update</code></p>\n<p>构建：<code>cargo build --release -p phira-mp-server</code></p>\n<p>运行程序并将 log 打印到终端，会显示你监听的端口：<code>RUST_LOG=info target/release/phira-mp-server</code><br />（如果你需要指定端口号：<code>RUST_LOG=info target/release/phira-mp-server --port 8080</code>）</p>\n<p><img src=\"https://b.acofork.com/img/phira-mp-2024-11-06-10-14-36-0dce4358b21773ae1261e7fc39339c32.webp\" alt=\"\" width=\"1920\" height=\"1102\" loading=\"lazy\" decoding=\"async\" /></p>\n","toc":[{"id":"直接下载服务端文件并运行","text":"直接下载服务端文件并运行","depth":2},{"id":"自行构建-高级","text":"自行构建（高级）","depth":2},{"id":"对于windows","text":"对于Windows","depth":3},{"id":"对于linux","text":"对于Linux","depth":3},{"id":"使用rust构建phira-mp","text":"使用Rust构建phira-mp","depth":2}]}