搬瓦工搭建 Pterodactyl 游戏面板教程

Pterodactyl 是一款开源的游戏服务器管理面板,提供美观的 Web 界面来创建、管理和监控游戏服务器。它支持 Minecraft、CS2、Valheim、Rust、ARK 等数十种游戏,基于 Docker 容器隔离运行,安全性和资源管理都非常出色。本文将详细介绍如何在搬瓦工 VPS 上搭建 Pterodactyl 面板。购买搬瓦工 VPS 请参考 全部方案,使用优惠码 NODESEEK2026 可享受 6.77% 的折扣。

一、架构概述

Pterodactyl 由两部分组成:

  • Panel:Web 管理面板,提供用户界面和 API,基于 PHP Laravel 框架。
  • Wings:服务器守护进程,负责实际管理 Docker 容器和游戏服务器实例。

Panel 和 Wings 可以安装在同一台 VPS 上,也可以分别部署在不同服务器上实现分布式管理。

二、系统要求

  • 操作系统:Ubuntu 22.04 LTS(推荐)。
  • 内存:Panel 本身需要约 512MB,加上游戏服务器实际需求。
  • PHP:8.1 或更高版本。
  • 数据库:MySQL 5.7+ 或 MariaDB 10.2+。
  • Web 服务器:Nginx 或 Apache。
  • Docker:Wings 节点需要安装 Docker。
  • 域名:需要一个域名并配置 SSL 证书。

三、安装 Panel

3.1 安装依赖

apt update && apt upgrade -y

# 安装 PHP 8.1 及扩展
apt install -y php8.1 php8.1-cli php8.1-gd php8.1-mysql php8.1-pdo php8.1-mbstring php8.1-tokenizer php8.1-bcmath php8.1-xml php8.1-fpm php8.1-curl php8.1-zip php8.1-intl

# 安装 Nginx
apt install -y nginx

# 安装 MariaDB
apt install -y mariadb-server

# 安装 Redis
apt install -y redis-server

# 安装 Composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

3.2 配置数据库

mysql -u root -p << 'EOF'
CREATE DATABASE panel;
CREATE USER 'pterodactyl'@'localhost' IDENTIFIED BY 'your_db_password';
GRANT ALL PRIVILEGES ON panel.* TO 'pterodactyl'@'localhost';
FLUSH PRIVILEGES;
EXIT;
EOF

3.3 下载 Panel

mkdir -p /var/www/pterodactyl
cd /var/www/pterodactyl

curl -Lo panel.tar.gz https://github.com/pterodactyl/panel/releases/latest/download/panel.tar.gz
tar -xzvf panel.tar.gz
chmod -R 755 storage/* bootstrap/cache/

3.4 配置 Panel

cp .env.example .env
composer install --no-dev --optimize-autoloader

php artisan key:generate --force
php artisan p:environment:setup
php artisan p:environment:database
php artisan p:environment:mail

# 运行数据库迁移
php artisan migrate --seed --force

# 创建管理员账号
php artisan p:user:make

3.5 设置文件权限

chown -R www-data:www-data /var/www/pterodactyl/*

3.6 配置定时任务

(crontab -l 2>/dev/null; echo "* * * * * php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1") | crontab -

3.7 配置队列服务

cat > /etc/systemd/system/pteroq.service << 'EOF'
[Unit]
Description=Pterodactyl Queue Worker
After=redis-server.service

[Service]
User=www-data
Group=www-data
Restart=always
ExecStart=/usr/bin/php /var/www/pterodactyl/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3
StartLimitInterval=180
StartLimitBurst=30
RestartSec=5s

[Install]
WantedBy=multi-user.target
EOF

systemctl enable pteroq
systemctl start pteroq

四、配置 Nginx

cat > /etc/nginx/sites-available/pterodactyl.conf << 'EOF'
server {
    listen 80;
    server_name panel.yourdomain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name panel.yourdomain.com;

    root /var/www/pterodactyl/public;
    index index.php;

    ssl_certificate /etc/letsencrypt/live/panel.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/panel.yourdomain.com/privkey.pem;

    access_log /var/log/nginx/pterodactyl.app-access.log;
    error_log /var/log/nginx/pterodactyl.app-error.log;

    client_max_body_size 100m;
    client_body_timeout 120s;
    sendfile off;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTP_PROXY "";
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
    }

    location ~ /\.ht {
        deny all;
    }
}
EOF

ln -s /etc/nginx/sites-available/pterodactyl.conf /etc/nginx/sites-enabled/
nginx -t && systemctl restart nginx

4.1 配置 SSL 证书

apt install certbot python3-certbot-nginx -y
certbot --nginx -d panel.yourdomain.com

五、安装 Wings

5.1 安装 Docker

Wings 需要 Docker 运行环境,参考 Docker 安装教程 完成安装。

5.2 安装 Wings

mkdir -p /etc/pterodactyl
curl -L -o /usr/local/bin/wings "https://github.com/pterodactyl/wings/releases/latest/download/wings_linux_amd64"
chmod u+x /usr/local/bin/wings

5.3 配置 Wings

在 Panel 管理界面中添加新节点后,会生成配置信息。将配置写入 Wings 配置文件:

# 在 Panel 管理界面 -> Nodes -> 创建节点 -> 获取配置
# 将配置内容粘贴到以下文件
nano /etc/pterodactyl/config.yml

5.4 创建 Wings 服务

cat > /etc/systemd/system/wings.service << 'EOF'
[Unit]
Description=Pterodactyl Wings Daemon
After=docker.service
Requires=docker.service
PartOf=docker.service

[Service]
User=root
WorkingDirectory=/etc/pterodactyl
LimitNOFILE=4096
PIDFile=/var/run/wings/daemon.pid
ExecStart=/usr/local/bin/wings
Restart=on-failure
StartLimitInterval=180
StartLimitBurst=30
RestartSec=5s

[Install]
WantedBy=multi-user.target
EOF

systemctl enable wings
systemctl start wings

六、创建游戏服务器

安装完成后,通过 Web 界面管理游戏服务器:

  1. 登录 Panel 管理界面。
  2. 进入 Admin > Servers > Create New。
  3. 选择预装的 Egg(游戏模板),如 Minecraft、Valheim、CS2 等。
  4. 配置资源限制(CPU、内存、磁盘空间)。
  5. 完成创建后,用户即可在前台界面管理游戏服务器。

七、常见问题

Wings 无法连接 Panel

确认 Panel 的 SSL 证书有效,Wings 配置文件中的 Panel URL 正确。检查防火墙是否开放了 Wings 的端口(默认 8080 和 2022)。

游戏服务器无法启动

在 Wings 日志中查看详细错误信息:

journalctl -u wings -f

总结

Pterodactyl 是目前最专业的开源游戏服务器管理面板,通过直观的 Web 界面即可管理多种游戏服务器。搭配搬瓦工 VPS 使用,可以轻松搭建和运营游戏服务器。相关游戏服务器教程包括 ValheimRustCS2幻兽帕鲁 等。如需更简单的 Minecraft 管理方案,可以参考 Crafty 面板。购买搬瓦工 VPS 请访问 bwh81.net,使用优惠码 NODESEEK2026 可享受 6.77% 的折扣。

关于本站

搬瓦工VPS中文网(bwgvps.com)是非官方中文信息站,整理搬瓦工的方案、优惠和教程。我们不销售主机,不提供技术服务。

新手必读
搬瓦工优惠码

NODESEEK2026(优惠 6.77%)

购买时填入即可抵扣。