Skip to content

Instantly share code, notes, and snippets.

@x86-39
Last active June 19, 2024 21:21
Show Gist options
  • Save x86-39/3292327448840346246df7b9811d2255 to your computer and use it in GitHub Desktop.
Save x86-39/3292327448840346246df7b9811d2255 to your computer and use it in GitHub Desktop.
random notes on Pterodactyl install on CentOS 9

i was taking notes on this on the expectation to like the app

i did not

i hate it

rough draft of everything i dont want to just delete:

Pterodactyl setup CentOS Stream 9

yum install mariadb-server mariadb php php-cli php-openssl php-gd php-mbstring php-tokenizer php-bcmath php-curl php-zip php-fpm php-dom php-mysqlnd redis curl tar unzip git nginx

yum install libsodium libsodium-devel
yum install php-sodium

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

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

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/

systemctl enable --now mariadb
systemctl enable --now redis


CREATE USER 'pterodactyl'@'127.0.0.1' IDENTIFIED BY 'password';

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

FLUSH PRIVILEGES;

exit

php artisan key:generate --force

php artisan p:environment:setup
Enter your Email
Enter the URL the panel will be accessible from
Enter your timezone

Enter redis for the following 3 questions ("Cache Driver", "Session Driver", "Queue Driver")
Enter "yes" when prompted to enable the UI based settings editor

Keep the default values for the Redis questions (Press enter 3 times)

php artisan p:environment:database

Enter 127.0.0.1 for Database Host

Enter 3306 for Database Port

Enter pterodactyl for Database Name

Enter pterodactyl for Database Username

Enter the password you used earlier when creating the user in SQL.

php artisan p:environment:mail

Run php artisan migrate --seed --force to populate the database

Add an admin user with php artisan p:user:make

Say "yes" when asked if this user is an administrator
Enter your desired details (Email, username, first name and last name)
Enter a password.

chown -R nginx:nginx /var/www/pterodactyl/*

Add the following to your crontab (Run sudo crontab -e)

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

Create the file /etc/systemd/system/pteroq.service with the content:

# Pterodactyl Queue Worker File
# ----------------------------------

[Unit]
Description=Pterodactyl Queue Worker
After=redis.service

[Service]
# On some systems the user and group might be different.
# Some systems use `apache` or `nginx` as the user and group.
User=nginx
Group=nginx
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

Run systemctl daemon-reload

Run systemctl enable --now pteroq.service

We're going to configure the web server without SSL since I will be running this behind a reverse proxy. (Traefik IngressRoute in Kubernetes. See definitions below)

Create a file /etc/nginx/conf.d/php-fpm.conf with the content:

# PHP-FPM FastCGI server
# network or unix domain socket configuration

upstream php-fpm {
        server unix:/run/php-fpm/www.sock;
}

Create a file /etc/nginx/conf.d/pterodactyl.conf with the content:

server {
    listen 80;
    server_name ptero.example.com;

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

}

Replace the ptero.example.com with your domain name

In /etc/php-fpm.d/www.conf, replace:
user = apache with user = nginx
group = apache with group = nginx

Now run the following commands to configure SELinux:

setsebool -P httpd_can_network_connect 1
setsebool -P httpd_execmem 1
setsebool -P httpd_unified 1

Open the firewall at 80/TCP:
firewall-cmd --permanent --add-service=http
firewall-cmd --reload

Enable & start NGINX:
systemctl enable --now nginx

Install Docker with the Docker install script
curl -sSL https://get.docker.com/ | CHANNEL=stable bash
(If you get dependency errors, uninstall the buildah package. This conflicts with Docker)

Start & enable Docker:
systemctl enable --now docker
Download wings:

mkdir -p /etc/pterodactyl
curl -L -o /usr/local/bin/wings "https://github.com/pterodactyl/wings/releases/latest/download/wings_linux_$([[ "$(uname -m)" == "x86_64" ]] && echo "amd64" || echo "arm64")"
chmod u+x /usr/local/bin/wings

[Unit]
Description=Pterodactyl Wings Daemon
After=docker.service
Requires=docker.service
PartOf=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=180
StartLimitBurst=30
RestartSec=5s

[Install]
WantedBy=multi-user.target```

Traefik IngressRoute setup

---
apiVersion: v1
kind: Service
metadata:
  name: pterodactyl
  namespace: default
spec:
  ports:
  - name: pterodactyl
    port: 80
    protocol: TCP
    targetPort: 80
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}
---
apiVersion: v1
kind: Endpoints
metadata:
  name: pterodactyl
  namespace: default
subsets:
- addresses:
  - ip: 192.168.100.132
  ports:
  - name: pterodactyl
    port: 80
    protocol: TCP
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: pterodactyl
  namespace: default
spec:
  entryPoints:
  - websecure
  routes:
  - kind: Rule
    match: Host(`ptero.example.com`)
    services:
    - name: pterodactyl
      port: 80
  tls:
    secretName: domain-wildcard-certificate
@joelra
Copy link

joelra commented Jun 22, 2023

Curious for your reason for hating pterodactyl? Did you move to a different panel?

Edit: P.S. thanks for not deleting this. I was missing the changes needed in /etc/php-fpm.d/www.conf. This was helpful for me. Though I'll be curious if I'll enjoy Pterodactyl or not.

@Kn1az
Copy link

Kn1az commented Mar 6, 2024

Thanks for sharing this. All the other install guides are for Debian/Ubuntu. This helped a lot on RHEL8. Was stuck on getting 500 error when trying to access my panel for the first time. The changes in /etc/php-fpm.d/www.conf as well as chown -R nginx:nginx /var/www/pterodactyl/* helped with this issue. Please do not delete this and remove the comments from the top that you hate ptero lol.

@Kn1az
Copy link

Kn1az commented Mar 8, 2024

Also the SELINUX commands helped to get rid of the "GET / HTTP/2.0" 500 error which is not mentioned in the pterodactyl official installation guide.

setsebool -P httpd_can_network_connect 1
setsebool -P httpd_execmem 1
setsebool -P httpd_unified 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment