In this guide, I will show you how to install the Pterodactyl panel. The Pterodactyl panel is designed to run on your own web server. You need to have administrator rights to your server in order to install and use this panel.

 

1. First update your packages and repository.

sudo apt update

2. Next, we will install important requirements for the server:

# Add the "add-apt-repository" command
apt -y install software-properties-common curl apt-transport-https ca-certificates gnupg

# Add additional PHP, Redis, and MariaDB repositories
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php

# Add the official Redis 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

# Skip MariaDB repo installation script if using Ubuntu 22.04
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

# Update
apt update

# Install requirements
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

3. Installing Composer

Composer is a dependency management tool for PHP that allows us to easily deliver everything needed to use the panel.

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

4. Installing files

First we will create a new folder for Pterodactyl

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

Once you have created the directory and are inside it, we will download and extract the files using the curl tool.

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/

5. Creating a database

Now that all the important files have been downloaded, we need to configure some panel features. Let's first create a database for the panel:

mysql -u root -p

Remember to replace 'yourPassword' with your actual 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;
exit

To exit the MySQL interface, type "exit" and press ENTER. Then, we will copy the default environment configuration file, install important requirements, and generate a new application encryption key.

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

Run this command only when
installing Pterodactyl for the first time and you don't have any databases created
php artisan key:generate --force

6. Environment configuration

The Pterodactyl environment can be easily configured using a few CLI commands:

php artisan p:environment:setup
php artisan p:environment:database

7. Database configuration

Now we need to configure all the basic information of the panel in the database you previously created:

php artisan migrate --seed --force

This command will set up the database tables and then add all the Nests & Eggs that Pterodactyl uses.


8. Creating an admin user

Next, we need to create a user with administrator privileges. Set the user details using this command:

php artisan p:user:make

9. Giving privileges 

The final step of the installation is to set the correct permissions for the panel files so that the web server can access them properly.

If you are using Apache or Nginx (won't work on CentOS):
chown -R www-data:www-data /var/www/pterodactyl/*

If you are using Nginx on CentOS:
chown -R nginx:nginx /var/www/pterodactyl/*

If you are using Apache on CentOS:
chown -R apache:apache /var/www/pterodactyl/*

10. Crontab settings

The first thing we need to do is create a new cron job that runs every minute to handle certain Pterodactyl tasks, such as session cleaning and dispatching scheduled tasks.

Open the cron editor using the command: "sudo crontab -e" and add the following line at the end:

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

 


11. Creating the Queue Worker file

Create a file named "pteroq.service" in the directory "/etc/systemd/system" with the following content:

cd /etc/systemd/system
sudo nano 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
StartLimitInterval=180
StartLimitBurst=30
RestartSec=5s

[Install]
WantedBy=multi-user.target

If you are using Redis, run these commands to ensure that Redis starts automatically when the server boots and to enable Pterodactyl with the command below:

sudo systemctl enable --now redis-server

sudo systemctl enable --now pteroq.service

12. Web server configuration

First delete the default Nginx configuration

rm /etc/nginx/sites-enabled/default

Here is the content for the "pterodactyl.conf" file. Please replace "<domain>" with your actual domain name or IP address. Save the file in the directory "/etc/nginx/sites-available/":

server {
    # Replace <domain> with your actual domain or IP address
    listen 80;
    server_name <domain>;

    root /var/www/pterodactyl/public;
    index index.html index.htm index.php;
    charset utf-8;

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    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;

    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;
    }
}

Enable the configuration using this command:

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

After that restart Nginx:

sudo systemctl restart nginx

I hope this guide was helpful. If there is any problems please contact us. 

Was this answer helpful? 2 Users Found This Useful (2 Votes)