Basic configuration

Now that the files have been installed, let's configure the core aspects of PteroCA.


Pterodactyl Configuration

To enable server management features like console access, statistics monitoring, and server startup configuration, you need to first configure Pterodactyl's allowed origins. This is a crucial security setting that controls which domains can interact with your Pterodactyl installation.

Configure Allowed Origins

Open the Pterodactyl configuration file:

nano /etc/pterodactyl/config.yml

Find or add the allowed_origins parameter and set it to your PteroCA domain or IP address:

allowed_origins:
- '127.0.0.1'  # Replace with your domain or IP where PteroCA is hosted
- '*'          # Optional: Or add wildcard rule to allow connections from any host (less secure)

Save the file and exit the editor.

Security Considerations

Install PteroCA Plugin

Navigate to Pterodactyl's root directory and install the required PteroCA plugin using Composer:

cd /var/www/pterodactyl
composer require pteroca-com/pterodactyl-addon

This plugin is essential as it enables the creation of Client API Keys through the API interface, which is not possible with standard Pterodactyl installation. Client API Keys are required for proper server management functionality.

Create Pterodactyl API Key

To integrate PteroCA with your Pterodactyl installation, you need to generate an API key in the Pterodactyl panel. This API key is essential for enabling seamless server management and interaction between PteroCA and Pterodactyl.

Steps to Create an API Key:

  1. Log in to your Pterodactyl panel.

  2. Navigate to Admin -> Application API.

  3. Click on Create New.

  4. Select all read & write permissions to ensure PteroCA has the necessary access.

  5. Set a description for the API key to help identify its purpose.

  6. Click Create Credentials.

  7. Copy and securely store the generated API key. You will need this key during the configuration of PteroCA.


Web Server Configuration

To configure your web server, you will need to create a configuration file and add your domain. Below is an example of how to configure NGINX for PteroCA.

Create the configuration file pteroca.conf and place it in /etc/nginx/sites-available/.

cd /etc/nginx/sites-available/
nano pteroca.conf

Example NGINX Configuration

server {
    listen 80;
    root /var/www/pteroca/public;
    index index.php index.html index.htm;
    server_name YOUR.DOMAIN.COM;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

Enable Configuration

After configuring your web server, you will need to enable the NGINX configuration and restart the service.

# Enable NGINX configuration
sudo ln -s /etc/nginx/sites-available/pteroca.conf /etc/nginx/sites-enabled/pteroca.conf

# Check for errors in NGINX configuration
sudo nginx -t

# Restart NGINX to apply changes
sudo systemctl restart nginx

Adding SSL

For SSL, a simple solution is using Certbot from Let's Encrypt. Certbot will automatically manage your SSL certificates and keep them up to date.

sudo apt update
# Install Certbot for NGINX
sudo apt install -y certbot python3-certbot-nginx
# Install SSL certificates
sudo certbot --nginx -d yourdomain.com

Database Setup

Create database and user with privileges

To create a database and a database user, follow the example below. This guide is for MariaDB. Remember to replace YOUR_PASSWORD with your own secure password. Also, 127.0.0.1 refers to localhost. We recommend having basic Linux knowledge before attempting this.

mysql -u root -p
CREATE DATABASE pteroca;
CREATE USER 'pterocauser'@'127.0.0.1' IDENTIFIED BY 'YOUR_PASSWORD';
GRANT ALL PRIVILEGES ON pteroca.* TO 'pterocauser'@'127.0.0.1';
FLUSH PRIVILEGES;
EXIT;

Configure connection

Run the command

To begin configuring your database, execute the following command from the root directory of your project:

cd /var/www/pteroca
php bin/console app:configure-database

Follow the Interactive Prompts

The command will ask a series of questions to help configure your database:

  1. Configure Database: The first question asks if you want to configure the database. By answering "yes", you will proceed to set up the database credentials.

  2. Set Database Credentials: You will be prompted to enter the following details:

    • Database host (default: localhost)

    • Database port (default: 3306)

    • Database name

    • Database user

    • Database password

    These values will be written to your .env file under the DATABASE_URL parameter.

  3. Run Migrations: After configuring the database credentials, the command will ask if you want to run migrations. By answering "yes", the system will execute migrations automatically in your database.


System configuration

Now that you've successfully configured the database, it's time to configure the system settings. This step is essential to ensure that the system functions smoothly, including setting up the site’s basic settings, email configuration, Pterodactyl panel credentials, payment settings, and creating the initial admin user.

This configuration can be managed through a built-in Symfony console command, which will guide you interactively through the setup process.

Configuration with Command

To streamline the system configuration process, use the following Symfony console command from your project root directory:

cd /var/www/pteroca
php bin/console app:configure-system

This command will guide you through the following steps:

  1. System Settings Configuration: You will be prompted to configure core system settings such as:

    • Site URL: This defines the base URL of your application.

    • Site Title: The title of your site, which will be used throughout the application.

    • Locale: Set the default locale for the application (e.g., en, fr, de).

  2. Email Configuration: Next, the command will ask you to set up email-related settings. These settings are essential for the system to send emails such as notifications and password resets:

    • SMTP Server: The address of your SMTP server (e.g., smtp.mailtrap.io).

    • SMTP Port: The port to be used by the SMTP server (typically 587 or 465 for secure connections).

    • SMTP Username and Password: Credentials for authentication with the SMTP server.

    • SMTP From (Email): The email address from which system emails will be sent.

  3. Pterodactyl Panel Integration: Application integrates with Pterodactyl (a game server management panel). The command will prompt you to enter:

    • Pterodactyl Panel URL: The URL where your Pterodactyl panel is hosted.

    • Pterodactyl API Key: The API key that allows your application to communicate with the Pterodactyl panel. Paste the API key you created in the previous section here.

  4. Payment Configuration: Application handles payments and transactions. You will be asked to configure payment settings:

    • Stripe Secret Key: The secret key for interacting with the Stripe API.

    • Currency Name: The primary currency for your transactions (e.g., USD, EUR).

    • Internal Currency Name: The name of the internal currency, which could be used for managing user balances within the system.

  5. User Account Creation: After configuring the system settings, you will be prompted to create an initial admin user for the client area. This admin user will have full access to the system and can manage users, settings, and other aspects of the application:

    • Admin Email: The email address for the admin user.

    • Admin Password: A secure password for the admin user.

    The system will automatically create this user and ensure that you have immediate access to the client area.

  6. Default Settings: The system will automatically apply some default settings based on your inputs. If needed, you can customize these settings later by accessing the admin panel or modifying the database directly.

Example workflow

Here’s an example of what the system configuration process might look like:

Extend to show example workflow

$ php bin/console app:configure-system

Do you want to configure system settings? (yes/no) [yes]:

yes

--- Site settings --- Site URL [http://localhost]:

http://example.com

Site Title [My App]:

My Awesome App

Locale [en]:

en

--- Email settings ---

SMTP Server [smtp.mailtrap.io]:

smtp.example.com

SMTP Port [587]:

587

SMTP Username [username]:

myuser@example.com

SMTP Password:

*****

SMTP From (E-mail) [noreply@example.com]:

noreply@myawesomeapp.com

--- Pterodactyl panel credentials ---

Pterodactyl Panel URL [https://panel.example.com]:

https://pteropanel.example.com

Pterodactyl Panel API Key [***]:

*****

--- Payment settings ---

Stripe Secret Key [sk_test_***]:

sk_live_********

Currency [USD]:

USD

Internal Currency Name (balance) [USD]:

USD

--- User configuration ---

User e-mail [admin@example.com]:

admin@myawesomeapp.com

User password:

****

System configured successfully!


Important notes

Last updated