Installing Pterodactyl Panel on Ubuntu 18.04.03 LTS

From https://pterodactyl.io

Pterodactyl is the open-source game server management panel built with PHP7, Nodejs, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to administrators and users. What more are you waiting for? Make game servers a first-class citizen on your platform today.

This guide will be a condensed version of the public documentation aiming to get you online fast.
Please read the terminology from the public documentation.

Pterodactyl does not support most OpenVZ systems due to incompatabilities with Docker. If you are planning on running this software on an OpenVZ based system you will — most likely — not be successful.
KVM Systems currently work.

Pterodactyl Panel is designed to run on your own web server. You will need to have root access to your server in order to run and use this panel.

You are expected to already have a FQDN (a domain name) with an A record pointing your panel as well as a SSL Certificate for your domain. If your using Cloudflare, you will NOT be able to use SFTP using the domain name.

Step 1 - Installing Dependencies
The panel relies on a webserver, redis, mysql/mariadb, and php 7.2+.
You can install them with the following commands:

sudo apt update #Update our system repository list.
sudo apt upgrade -y #Update all packages
sudo apt -y install software-properties-common curl #Add "add-apt-repository" command

LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php #Install PPA for PHP 7.3

sudo apt update #Refresh package list again
sudo apt-add-repository universe #Needed for Ubuntu 18.04
sudo apt install redis-server mariadb-server php7.3  php7.3-cli  php7.3-gd  php7.3-pdo  php7.3-mbstring  php7.3-tokenizer php7.3-bcmath  php7.3-xml  php7.3-fpm php7.3-curl php7.3-mysql php7.3-zip nginx tar unzip git -y

This should finish super quick so we can move on to installing Composer.

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

Step 2 - Installing The Panel
After that, we need to create our web directory at /var/www/pterodactyl and download our panel archive. At the time of this guide, v0.7.15 is the latest right now.

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

curl -Lo panel.tar.gz https://github.com/pterodactyl/panel/releases/download/v0.7.15/panel.tar.gz
tar --strip-components=1 -xzvf panel.tar.gz
chmod -R 755 storage/* bootstrap/cache/

Step 3 - Configuring MariaDB
We need to create one user for the panel and one user to create user databases.

Chances are you don’t have a password for the root mysql user, so when prompted for a password press ENTER.

mysql -u root -p

You should now be at a prompt with MarianDB [(None)]>.
You can enter these commands one at a time.
The user must only allowed to login at 127.0.0.1

USE mysql;
CREATE USER 'pterodactyl'@'127.0.0.1' IDENTIFIED BY 'somePassword123';

CREATE DATABASE panel;
GRANT ALL PRIVILEGES ON panel.* TO 'pterodactyl'@'127.0.0.1' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Creating the Database Host for Nodes

USE mysql;
CREATE USER 'pterodactyluser'@'127.0.0.1' IDENTIFIED BY 'somepassword';

GRANT ALL PRIVILEGES ON *.* TO 'pterodactyluser'@'127.0.0.1' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Once that is done you can type exit to exit the MariaDB prompt.
We need to allow external database access.

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

We need to modify bind-address= to equal bind-address = 0.0.0.0
This will allow outside access and access from your docker containers. We can now go back to configuring our panel.

Step 4 - Finish Setting Up Our Panel

cd /var/www/pterodactyl
cp .env.example .env

composer install --no-dev --optimize-autoloader
php artisan key:generate --force #Only run this if you are installing the panel for the first time.

Take the time right now to copy your .env file over to your local host machine as this file contains your panel configuration and encryption key. It is not recommended at all to share this file with anyone.

Lets continue setting up the panel.

php artisan p:environment:setup

You will be prompted to enter an email, please enter your email then press enter.
After that, you must enter your domain prefixed with https://. Ex: https://subdomain.domain.com.
Set up your time zone by typing your region/nearest big city. Ex: America/Los_Angeles.
When prompted for a Cache Driver, Session Driver, and Queue Driver, enter redis and press enter for all 3.

Enable UI based settings editor? Select Yes.
Redis Host, Password and Port: Press Enter

Next Run:

php artisan p:environment:database
  • Database Host: 127.0.0.1
  • Database Port: 3306
  • Database Name: panel
  • Database Username: pterodactyl
  • Database Password: somePassword123 (Unless changed during MariaDB Setup)
# To use PHP's internal mail sending (not recommended), select "mail". To use a
# custom SMTP server, select "smtp".
php artisan p:environment:mail

If your planning to use this panel and make it available for users with WHMCS, you will need to setup a SMTP server with this. If this is for private, you can use the PHP mail function by using the mail option when prompted for a driver.

This section assumes you selected mail.

  • Email address emails should originate from: noreply@yourdomain.com
  • Name that emails should be from: Pterodactyl Panel (change to your liking)
  • Encryption: TLS

Now we need to setup all of the base data for the Panel in the database you created earlier. The command below may take some time to run depending on your machine. Please DO NOT exit the process until it is completed! This command will setup the database tables and then add all of the Nests & Eggs that power Pterodactyl.

php artisan migrate --seed #Answer with yes.

Add your administrator user.

php artisan p:user:make

After your admin user has been created, we need to set permissons for NGINX.

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

Queue Listeners
Pterodactyl makes use of queues to make the application faster and handle sending emails and other actions in the background. You will need to setup the queue worker for these actions to be processed.
sudo crontab -e
Select option 1;
Scroll to the bottom, paste the following:

* * * * * php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1

CTRL + X then press y to save.

We need to setup a systemd worker to keep the process running.
nano /etc/systemd/system/pteroq.service

# 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

[Install]
WantedBy=multi-user.target"

Finish it off with enabling the redis and pteroq service.

sudo systemctl enable --now redis-server
sudo systemctl enable --now pteroq.service

Step 5 - Setting Up Our Webserver With NGINX

We need to generate some certificates for our domain using certbot. Install and run it now only if you have your A record pointing to this webserver.

sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install certbot
sudo certbot certonly -d yourdomain.com

We need to create a config for nginx at /etc/nginx/sites-available called pterodactyl.conf with this content while taking care to change all instances of here with the domain you used in the certificate.

server_tokens off;

server {
    listen 80;
    server_name <domain>;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name <domain>;

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

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

    # allow larger file uploads and longer script runtimes
    client_max_body_size 100m;
    client_body_timeout 120s;

    sendfile off;

    # SSL Configuration
    ssl_certificate /etc/letsencrypt/live/<domain>/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/<domain>/privkey.pem;
    ssl_session_cache shared:SSL:10m;
    ssl_protocols TLSv1.2;
    ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
    ssl_prefer_server_ciphers on;

    # See https://hstspreload.org/ before uncommenting the line below.
    # add_header Strict-Transport-Security "max-age=15768000; preload;";
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header Content-Security-Policy "frame-ancestors 'self'";
    add_header X-Frame-Options DENY;
    add_header Referrer-Policy same-origin;

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

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

CTRL + X then reply with Y to save.

Then run the following.

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

We can now begin installing daemons that run the servers.

Step 6 - Installing The Daemon
In order to install the Daemon, you need to check to see if your provider users the Virtualization technology of:

Virtuozzo, OpenVZ, OVZ, or LXC

Then you will most likely be unable to install the daemon on the same server. If you are running this on a OVH KVM or Dedicated Server, you will be required to install an generic linux kernel as their ovh kernel is incompatibile with docker.

Check your Virtualization Type:

sudo lscpu | grep 'vendor\|type'
sudo dmidecode -s system-manufacturer

As long as you don’t see a report of the above mention of instances, your good to continue.

Install daemon dependencies:

sudo apt install tar unzip python
curl -sSL https://get.docker.com/ | CHANNEL=stable bash
sudo systemctl enable docker
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt -y install nodejs make gcc g++

We can follow up with installing the daemon.

mkdir -p /srv/daemon /srv/daemon-data
cd /srv/daemon

curl -L https://github.com/pterodactyl/daemon/releases/download/v0.6.12/daemon.tar.gz | tar --strip-components=1 -xzv
npm install --only=production

We need to create a systemd worker for the daemon to keep it online.
nano /etc/systemd/system/wings.service

[Unit]
Description=Pterodactyl Wings Daemon
After=docker.service

[Service]
User=root
#Group=some_group
WorkingDirectory=/srv/daemon
LimitNOFILE=4096
PIDFile=/var/run/wings/daemon.pid
ExecStart=/usr/bin/node /srv/daemon/src/index.js
Restart=on-failure
StartLimitInterval=600

[Install]
WantedBy=multi-user.target

Then run

systemctl enable --now wings

To setup the daemon with your panel, we need to go to your panel and create a location for your daemon.
Create a new location with the following:

  • Short Code: local
  • Description: Local Daemon

We now can move to Nodes, and create a new node with the following settings:

  • Name: Local
  • Description: Local Node
  • Location: local
  • Node Visbility: public
  • FQDN: your domain name
  • Communicate over SSL: Use SSL Connection
  • Behind Proxy: Select Behind Proxy if your using cloudflare, if not, use not behind.
  • Daemon Server File Directory: Leave Default
  • Total Memory: Take your total memory of your VPS or Dedicated and subtract a gig and a half of memory (1536MB)
  • Memory Over-Allocation: 0
  • Total Disk Space: Half of your Disk In MB
  • Daemon Port: Use 8443 if your behind Cloudflare, Use 8080 if not.

Create The Node.
Go to the node and get your configuration.


Click “Generate Token” and you will be given a command string.

You can navigate to /srv/daemon and copy and paste the command. The panel should automatically set the configuration and you should be all good to go.

If you have an issue with this guide, contact me in the Hyper Expert discord guild and I can help you. If you are having an issue with Pterodactyl itself you can get support here.

1 Like