debian搭建pterodactyl(翼龙面板)

搭建pterodactyl panel

使用debian10系统,主要参考官方的教程

依赖环境配置

先安装依赖环境,注意根据自己的发行版作出修改,官方要求php至少要是php7.3以及以上版本。

官方列出了下面这些依赖:

  • PHP 7.3+ (7.4 recommended) with the following extensions: cli, openssl, gd, mysql, PDO, mbstring, tokenizer, bcmath, xml or dom, curl, zip, and fpm if you are planning to use nginx

  • MySQL 5.7.22 or higher (MySQL 8 recommended) or MariaDB 10.2 or higher.

  • Redis (redis-server)

  • A webserver (Apache, NGINX, Caddy, etc.)

  • curl

  • tar

  • unzip

  • git

  • composer

    Add “add-apt-repository” command

    apt -y install software-properties-common curl apt-transport-https ca-certificates gnupg

    #官方提供的这两个库貌似有问题,所以我直接使用了debian10源中的软件版本了另外 debian10源中的php版本为7.3需要作出一些修改

    Add additional repositories for PHP, Redis, and MariaDB 添加额外的库,然后使用mariadb的脚本来安装数据库

    LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php add-apt-repository -y ppa:chris-lea/redis-server curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

    Update repositories list

    apt update

    Add universe repository if you are on Ubuntu 18.04

    apt-add-repository universe

    Install Dependencies

    apt -y install php7.4 php7.4-{cli,gd,mysql,pdo,mbstring,tokenizer,bcmath,xml,fpm,curl,zip} mariadb-server nginx tar unzip git redis-server

    初始化一下数据库

    mysql_secure_installation

安装php的依赖管理工具composer

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

安装面板

下载面板相关文件

新建一个文件夹并从github上下载已经打包好了的面板文件,并修改权限。

mkdir -p /var/www/html/pterodactyl
cd /var/www/html/pterodactyl
curl -Lo panel.tar.gz https://github.com/pterodactyl/panel/releases/download/v1.0.2/panel.tar.gz
tar -xzvf panel.tar.gz
chmod -R 755 storage/* bootstrap/cache/

安装之前的配置

数据库配置

#我们需要创建一个面板的数据库用户以及相关的数据库
mysql -u root -p
CREATE USER 'paneluser'@'127.0.0.1' IDENTIFIED BY '123456';
CREATE DATABASE paneldb;
GRANT ALL PRIVILEGES ON paneldb.* TO 'paneluser'@'127.0.0.1' WITH GRANT OPTION;
FLUSH PRIVILEGES;

composer安装依赖

cp .env.example .env
composer install --no-dev --optimize-autoloader
# 只有第一次安装的时候使用下面这条命令
# Only run the command below if you are installing this Panel for
# the first time and do not have any Pterodactyl Panel data in the database.
php artisan key:generate --force

记得备份.env文件中的密钥的APP_KEY,这个密钥用来加密所有需要安全储存的文件,如果这个丢失了,你的加密过的数据都取不出来了。(即使有数据库备份)

面板环境配置

使用下面的几条命令来初始化面板的数据库服务器、邮件服务器等环境进行初始化。

php artisan p:environment:setup
#修改为我们之前创建数据库时使用的参数
php artisan p:environment:database

# To use PHP's internal mail sending (not recommended), select "mail". To use a
# custom SMTP server, select "smtp".
php artisan p:environment:mail

初始化数据库

我们接着要初始化我们之前创建的数据库。 这里我暂时没有使用redis,而是采用了默认的配置(使用文件系统和mysql数据库来作为Cache Driver和Session Driver)

php artisan migrate --seed

数据库初始化

添加第一个用户

添加我们的第一个用户(管理员)

php artisan p:user:make

权限设置

# If using NGINX or Apache (not on CentOS): 我们是debian10并使用nginx,所以使用这条命令即可
chown -R www-data:www-data * 

# If using NGINX on CentOS:
chown -R nginx:nginx *

# If using Apache on CentOS
chown -R apache:apache *

nginx配置

之后配置一下nginx的根目录以及php应该就可以访问面板了。

vim /etc/nginx/sites-enabled/default

root /var/www/html/pterodactyl/public;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.3-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;
        include /etc/nginx/fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

之后systemctl restart nginx重启一次nginx,再访问我们的网页便能看见面板了。

登录页面

配置面板节点

我们之前的操作只是安装好了面板,而pterodactyl作为可以商用的面板,一个面板可以同时管理多个服务器,所以我们还得配置一下面板的节点,因为是自己用的,所以使用了同一台服务器作为节点。

只配置了面板是无法新增服务器的

安装daemon

之前只是安装了面板,但是除了面板我们还需要安装后端程序(daemon),注意在1.0之后的版本,后端程序开始使用wings,安装方式有了很大的区别 (我照着过时的教程弄了半天,都没成功)

The daemon manages the Docker containers that the game servers run inside of. Docker is a containerization tool, which basically packs up all the dependencies and code your application needs to run into one file, called a Docker image, which can be copied to start new servers. This allows you to define how to launch one Minecraft server, and then deploy 20 copies of that master Minecraft server image, with varying configuration, all without installing Java 20 times.

官方教程

需要先安装docker和nodejs 不需要安装nodejs了。

#apt install -y zip unzip tar make gcc g++ python python-dev curl gnupg
#教程中使用了其他仓库内的docker,但是直接使用debian官方源中的docker也是可以的
apt install docker.io
systemctl enable docker
systemctl start docker
#使用wings的话,不再需要nodejs了
mkdir -p /etc/pterodactyl
curl -L -o /usr/local/bin/wings https://github.com/pterodactyl/wings/releases/download/v1.0.1/wings_linux_amd64
chmod u+x /usr/local/bin/wings

创建location

先创建一个“地域”

location

创建node

之后我们在这个“地域”中新建一个节点,我这暂时只创建了本地节点,远程节点未来有时间了再研究。

node

对于一个节点,翼龙面板可以设置内存和硬盘限制,添加节点后,我们还需要给这个节点分配ip和端口。

分配ip和端口

启动daemon

我们需要从之前新建的node中复制配置信息,编辑 /etc/pterodactyl/config.yml(第一次编辑需要新建文件),并把这些配置信息复制进去,并保存。

复制配置信息

然后在tmux里面执行wings即可开始运行后端程序,之后我们再次查看我们的节点状况,发现节点已经在线了。

节点在线

除了tmux内直接执行wings命令,我们还可以让后端程序以守护进程的方式运行。

编辑 vim /etc/systemd/system/wings.service

[Unit]
Description=Pterodactyl Wings Daemon
After=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=600

[Install]
WantedBy=multi-user.target

之后便可以使用 systemctl enable wings等命令来运行wings后端程序了。

添加server

之后我们便可以添加面板服(server)了

添加server

比起我之前使用的mcsm,翼龙面板功能要强大很多,可以对面板服进行一些限制,如cpu资源限制,内存硬盘限制等等。不过mcsm部署简单更加适合个人使用,而pterodactyl部署要麻烦很多,但是更加适合商业用途。

进阶配置

有空再继续写了。

Licensed under CC BY-NC-SA 4.0
最后更新于 Oct 25, 2020 06:24 UTC
comments powered by Disqus
本站访客数:
Built with Hugo
主题 StackJimmy 设计