Installing Pterodactyl Panel
Introduction
Pterodactyl is an open-source game server management panel built with PHP, React, and Go. It provides a robust platform for managing and deploying game servers with ease, offering features such as a user-friendly interface, support for various game servers, and secure and scalable architecture. This guide will walk you through the steps to install and set up the Pterodactyl Panel on your server, ensuring you have a solid foundation for managing your game servers.
For more detailed information and official documentation, visit the Pterodactyl documentation (opens in a new tab).
Prerequisites
Before you begin, ensure you have the following:
- Install a Linux OS Ubuntu Installation Guide.
- (Optional) Setup a reverse network proxy NPM Guide.
- Root access to your server is required to run and use the Pterodactyl Panel.
Step-by-Step Guide
Dependency Installation
We will first begin by installing all of Pterodactyl's required dependencies.
-
Add
add-apt-repository
command:sudo apt -y install software-properties-common curl apt-transport-https ca-certificates gnupg
-
Add additional repositories for
PHP
:LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php # or LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/nginx
-
Add
Redis
official APT repository:curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
-
MariaDB repo setup script:
💡MariaDB repo setup script can be skipped on Ubuntu 22.04+
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
-
Update repositories list:
apt update
-
Install dependencies:
sudo apt -y install php8.1 php8.1-{common,cli,gd,mysql,mbstring,bcmath,xml,fpm,curl,zip} mariadb-server nginx tar unzip git redis-server
Installing Composer
Composer is required for dependency management in PHP. It will be used to ship all code needed to operate the panel.
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Download Files
Before we can download the files, we need a place to store them.
mkdir -p /var/www/pterodactyl
cd /var/www/pterodactyl
Once you've created the necessary directories for Pterodactyl, we can proceed to download the files.
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/
Installation
Now that we have all the files needed, we can configure the base Panel.
Database Configuration
The following steps will show you how to configure a database on the Panel.
Follow the same steps below, on a dedicated database server, and change the necessary DB_* environmental variables for a non-local database.
mysql -u root -p
NOTE: Remember to change 'yourPassword' below to be a unique password.
CREATE USER 'pterodactyl'@'127.0.0.1' IDENTIFIED BY 'yourPassword';
CREATE DATABASE panel;
GRANT ALL PRIVILEGES ON panel.* TO 'pterodactyl'@'127.0.0.1' WITH GRANT OPTION;
Creating a Database Host for Nodes
You should change the username and password below to something unique.
CREATE USER 'pterodactyluser'@'127.0.0.1' IDENTIFIED BY 'somepassword';
GRANT ALL PRIVILEGES ON *.* TO 'pterodactyluser'@'127.0.0.1' WITH GRANT OPTION;
exit
Environment Configuration
cp .env.example .env
composer install --no-dev --optimize-autoloader
Only run the below command for first-time installations of this Panel:
php artisan key:generate --force
Back up and keep your .env
file safe after environment configuration is
complete.
Now we will populate the environmental variables inside .env
via the following
commands.
Running the following commands will prompt you to answer several questions. You may check out the .env.example as a reference for the following questions.
php artisan p:environment:setup
php artisan p:environment:database
(NOT RECOMMENDED) To use PHP's internal mailing system, select "mail".
For a custom SMTP server, such as Gmail, select "smtp".
See reference .env.example.
php artisan p:environment:mail
Database Setup
It is time to set up the database contents. The command below will create the database tables and all the base Nests and Eggs that come with Pterodactyl.
The following command may take several minutes to complete, depending on your machine. Please be patient.
Please DO NOT exit the process until it is completed.
php artisan migrate --seed --force
Add The First User
Someone has to manage the Panel. The command below will create the very first user. This user should be made an administrator of the Panel. See reference .env.example.
php artisan p:user:make
Set Permissions
The last step of the installation is to set the correct permissions on the Panel files.
The following commands will change the owner of all the files and directories inside the pterodactyl directory.
Please read the command comments to find the command applicable to your environment.
# If using NGINX or Apache (not on CentOS)
chown -R www-data:www-data /var/www/pterodactyl/*
# If using NGINX on CentOS
chown -R nginx:nginx /var/www/pterodactyl/*
# If using Apache on CentOS
chown -R apache:apache /var/www/pterodactyl/*
Queue Listeners
For a more detailed explanation of queue listeners and what they do, see the official Pterodactyl documentation (opens in a new tab).
Crontab Configuration
First, we need to edit crontab. For anyone who has never used crontab, crontab is a simple way to schedule tasks inside a Unix operating system. To edit crontab, run the following command.
NOTE: You may be prompted to choose a text editor. The simplest way to
edit a file such as crontab would be nano
or gedit
. However, experienced
users are welcome to use vi/vim
.
sudo crontab -e
Once inside crontab, append the following line at the bottom of the file.
* * * * * php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1
To save and exit nano, press CTRL+S
and then CTRL+X
.
If you would like to view the contents of the crontab without opening the editor
use sudo crontab -l
Create Queue Worker
Next, we will create a new systemd worker to keep the previous process running continuously in the background. For more information, please visit the official Pterodactyl documentation (opens in a new tab).
First, create a file called pteroq.service
under the directory
/etc/systemd/system
like so:
sudo nano /etc/systemd/system/pteroq.service
Next, copy and paste the following block into the newly created file.
# Pterodactyl Queue Worker File
# ----------------------------------
[Unit]
Description=Pterodactyl Queue Worker
After=redis-server.service
[Service]
# On some systems the user and group might be different.
# Some systems use `apache` or `nginx` as the user and group.
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
Lastly, you need to enable and start the redis-server
and the pteroq.service
we just created.
sudo systemctl enable --now redis-server
sudo systemctl enable --now pteroq.service
Conclusion
Congratulations! You have completed the installation of the Pterodactyl Panel. You can now move on to configuring the webserver to access the Panel and start creating servers to play with friends.
Happy Hosting!
Video Tutorial
For a more visual guide, you can watch this video tutorial on how to install Pterodactyl Panel, using docker:
Video by Techno Tim (opens in a new tab).