Install PHP, MariaDB, Radis, NGINX, cURL, tar, unzip, GIT
apt install -y php8.2-{cli,gd,mysql,mbstring,bcmath,xml,fpm,curl,zip} redis-server nginx curl tar unzip git mariadb-server
Create a new user for Pterodactyl
CREATE USER 'pterodactyl_panel'@'127.0.0.1' IDENTIFIED BY '************';
Create a new database
CREATE DATABASE pterodactyl_panel;
Grant privileges on the new database for the new user
GRANT ALL ON pterodactyl_panel.* TO 'pterodactyl_panel'@'127.0.0.1';
Create the web directory for Pterodactyl Panel
mkdir -p /var/www/pterodactyl && \
cd /var/www/pterodactyl
Download Panel, unpack the archive, change permissions
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/ && \
chown www-data:www-data -R /var/www/pterodactyl
Copy the default ENV file. Modify accordingly.
cp .env.example .env
Use Composer to install core dependencies (do not run composer as root!)
sudo -u www-data composer install --no-dev --optimize-autoloader
Configure Panel's ENV parameters with the built-in CLI tools
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
Setup the database
php artisan migrate --seed --force
Add a new Panel user
php artisan p:user:make
Set the ownership of the Panel web directory
chown -R www-data:www-data /var/www/pterodactyl
Configure the following cron
job to ensure that certain Pterodactyl tasks are run
bash -c "cat > /etc/cron.d/pterodactyl_panel" << 'EOF'
* * * * * www-data php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1
EOF
Create a systemd
Queue Worker
bash -c "cat > /etc/systemd/system/pteroq.service" << 'EOF'
# Pterodactyl Queue Worker File
# ----------------------------------
[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=30s
[Install]
WantedBy=multi-user.target
EOF
Enable the Reddis server to start at boot
systemctl enable --now redis-server
Enable the new Pterodactyl Queue Worker
systemctl enable --now pteroq.service
Disable the default config
rm /etc/nginx/sites-enabled/default
Create a new config for Panel
bash -c "cat > /etc/nginx/sites-available/pterodactyl.conf" <<'EOF'
server {
# Replace the example <domain> with your domain name 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;
}
}
EOF
SymLink the new config to the enabled-sites directory
ln -s /etc/nginx/sites-available/pterodactyl.conf /etc/nginx/sites-enabled/pterodactyl.conf
Restart Nginx
systemctl restart nginx.service