Skip to main content

Setup Web (Manually)

tip

You only need to follow either AutoInstaller or Manual, not both.

If you want us to install minetrax for your servers or stuck in any step and need help, Feel free to join our Discord group and ask in help section or ping Xinecraft#2139. Its free. ¯\_(ツ)_/¯

Manual Install give you flexibility to install MineTrax in more different distributions of Linux & options to choose between Apache2 or Nginx, MySQL or MariaDB, etc. Also, you can install on your existing server or a new server.

Server Requirements

note

The installation steps given in this docs consider you using debian based OS eg: Ubuntu 20.04. If your server is running any other OS then you might have to do slight adjustments as per need during the process. Feel free to contact us in Discord for any help.

MineTrax is designed to run on your web server of choice. It is recommended to use a VPS or Dedicated Server as hosting and not any shared hosting.

Web requires a VPS or Dedicated Server with atleast 1GB of RAM and 1 CPU. Ubuntu 20.04 is recommended.

Software Dependencies:

  • PHP 8.1+
  • MySQL 5.7+ or MariaDB 10.2.7+
  • Apache2 or Nginx
  • NodeJS 12+
  • Redis Server
  • Git
  • Composer
  • Supervisor
  • Sendmail
tip

It is recommended to start with a fresh server to follow along. A small Virtual Server with 1 vCPU should be fine to start with. Cloud providers like DigitalOcean & Hetzner give credit upto 100$ to get started for free.

Installing Dependencies

Update operating system to make sure all existing packages are up to date:

sudo apt update && sudo apt upgrade -y

PHP

First, install the prerequisites and PPA and update.

sudo apt install software-properties-common && sudo add-apt-repository ppa:ondrej/php -y
sudo apt update

Install PHP 8.2 and all required extensions.

sudo apt -y install curl php8.2 php8.2-{cli,gd,mysql,pdo,mbstring,tokenizer,bcmath,xml,fpm,curl,zip,intl,redis}

MySQL / MariaDB

caution

Make sure to only install one. Either MySQL or MariaDB. If installing MariaDB, make sure its version is >10.2.7.

To install MySQL run the below command in terminal.

sudo apt install mysql-server

Apache2 / Nginx

caution

Make sure to only install one. Either Nginx or Apache2.

Install Apache2 server and php extension for it.

sudo apt install apache2 libapache2-mod-php8.2
sudo systemctl restart apache2

Composer

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You'll need composer installed before continuing in this process.

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

NodeJS

Add the Node PPA and update (here we are installing version 16, you can change if you want).

curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh
sudo bash /tmp/nodesource_setup.sh

Install NodeJS from APT

sudo apt install nodejs

Redis Server, Git, Sendmail & Supervisor

sudo apt install redis-server git supervisor sendmail unzip
sudo systemctl enable --now redis-server

Installation

Cloning the codes from Github

Create a folder where the web will live and move to that folder.

mkdir -p /var/www/minetrax
cd /var/www/minetrax

Now clone the MineTrax git repo to the newly created folder and fix permissions.

git clone https://github.com/MineTrax/minetrax.git .
sudo chmod -R 775 storage/* bootstrap/cache/

Setup the Database

You need to create a MySQL/MariaDB database and a user with all permission to that database.

// If below command ask for password just press enter. If not work then try sudo mysql
mysql -u root -p

// Create the database
CREATE DATABASE minetrax;
// Create the user, change 'randomStrongPassword' to any strong password of your choice.
CREATE USER 'minetrax'@'localhost' IDENTIFIED BY 'randomStrongPassword';
// Give permission of the DB to user
GRANT ALL PRIVILEGES ON minetrax.* TO 'minetrax'@'localhost' WITH GRANT OPTION;
exit

Environment and Migration

Now that the database is up we need to go back to the minetrax folder and copy .env.example file to .env.

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

Install the composer dependencies.

composer install

Now generate a new key using.

# Only run the if you are doing fresh install and don't have data in the database.
php artisan key:generate --force

Next, change the database related variables in the .env file to match your database user credentials

.env
APP_URL=http://your_domain.com # Change this to the URL which you wanna setup minetrax on.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=minetrax
DB_USERNAME=minetrax
DB_PASSWORD=randomStrongPassword

Migration and Seed the database, run the below command in terminal:

php artisan migrate --seed

Create symlink for storage

php artisan storage:link
IMPORTANT

It is highly recommended to copy .env file and backup it somewhere safe. It contain very important information like APP_KEY which is used to encrypt critical data before storing in database (eg: api keys and server credentials). Without that key recovering data won't be possible.

Also, always keep that key secret.

Fix permissions

Fix permissions for the web folder so webserver can access the files.

# If using Apache (not on CentOS):
chown -R $USER:www-data /var/www/minetrax/*

# or, If using Apache on CentOS
chown -R $USER:apache /var/www/minetrax/*

Setup Queue Listeners

Queue are used to run long running task like sending email, clearing stale data and importing data from servers. Queue workers in need to setup for these tasks to run.

Add the cron

Firstly, need to add the scheduler runner command to cron. Open crontab sudo crontab -e and add then following in a new line there.

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

Create queue worker:

We use supervisor for running of queue worker so incase they crash supervisor will automatically restart them.

Configuration file for supervisor are stored in folder /etc/supervisor/conf.d. All supervisor conf file we create will be in there.

Default queue:

Create a new file called minetrax-worker-default.conf and put below context in there.

/etc/supervisor/conf.d/minetrax-worker-default.conf
[program:minetrax-worker-default]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/minetrax/artisan queue:work --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=2
redirect_stderr=true
stopwaitsecs=3660

Long queue:

Create a new file called minetrax-worker-long.conf and put below context in there.

/etc/supervisor/conf.d/minetrax-worker-long.conf
[program:minetrax-worker-long]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/minetrax/artisan queue:work --queue=longtask,default redis-longtask --timeout=0 --sleep=3 --tries=3 --max-jobs=500
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=2
redirect_stderr=true
stopwaitsecs=3660

Start the supervisor workers:

sudo supervisorctl reread
sudo supervisorctl update

sudo supervisorctl start minetrax-worker-default:*
sudo supervisorctl start minetrax-worker-long:*
Restart the queue

Whenever any change is made to code, queue worker don't pick them up as they are long running. To make laravel queue restart we run:

php artisan queue:restart

WebSocket setup (optional)

Recommendation

This step is optional but recommended. By default minetrax will use polling to fetch and reload data from server without reloading. (eg: every 5 seconds).

If you want your site to feel more responsive and instant or you have a large audience and want to reduce the load on your server then you should setup websocket.

In this step we are going to setup Pusher as our websocket server.

  1. Go to pusher.com and create a account.
  2. In dashboard select "Channels" and then click "Create app" option to create a new app.
  3. Name your app anything you like and choose a location closest to your server location. Choose Vue.js in Frontend and Laravel in Backend dropdowns.
  4. Click Create App.
  5. Now go to App Keys section and note down the app_id, key, secret and cluster variables. Eg:
app_id = "1367909";
key = "4b48b850682acb371c34";
secret = "41cc8be68c0d57fea4f3";
cluster = "ap2";

After this open your .env file and replace the pusher related credentials to match above.

.env
PUSHER_APP_ID=1367909
PUSHER_APP_KEY=4b48b850682acb371c34
PUSHER_APP_SECRET=41cc8be68c0d57fea4f3
PUSHER_APP_CLUSTER=ap2

Also change broadcast driver to pusher.

.env
BROADCAST_DRIVER=pusher

Next, restart the queue workers:

cd /var/www/minetrax
php artisan queue:restart
pusher alternatives

Pusher provide 200k messages per day in free tier, which is more than enough for most cases, but if you have a very large userbase that might not be enough. In that case please check Websocket Options page to learn how to setup Pusher alternatives.

It is recommended to go for alternatives only after giving Pusher a try and its limit runs out.

Web Server Configuration

Finally lets setup the web server to access the web. Make sure your domain name is pointing to the IP address of the VPS/Dedicated server in which we are setting up the web. To do that you need to create an A record for your domain to the webserver IP from your domain DNS Provider.

caution

Follow either Nginx or Apache2 steps as per your installation.

Apache2 Setup

First, Create a new file with any name(eg: minetrax.conf) in the Apache2 sites directory /etc/apache2/sites-available with context provided below replacing highlighted section as per your installation.

sudo nano /etc/apache2/sites-available/minetrax.conf
/etc/apache2/sites-available/minetrax.conf
<VirtualHost *:80>
ServerName your_domain.com
ServerAlias www.your_domain.com
DocumentRoot "/var/www/minetrax/public"

AllowEncodedSlashes On

<Directory "/var/www/minetrax/public">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>

Next, enable rewrite mod & the site, and finally restart apache2 to reflect the changes.

sudo a2enmod rewrite
sudo a2ensite minetrax.conf

sudo systemctl restart apache2
caution

You should disable default site /etc/apache2/sites-enabled/000-default.conf.

sudo a2dissite 000-default.conf
sudo systemctl restart apache2

Finalize

Now minetrax should be up and running on your domain http://your_domain.com.

A SuperAdmin user is created already for you, you can login and change the password:

Username: superadmin
Password: admin123
CHANGE PASSWORD & EMAIL

It is very important that you change the password & email of the superadmin user after logging in.

You can change password from Edit Profile section and email from Admin > Users section

After checking your site is up and running, make sure to change APP_ENV=production and APP_DEBUG=false in the .env file.

.env
APP_NAME="YOUR_DESIRED_APP_NAME"
APP_ENV=production
APP_DEBUG=false
DISABLE DEBUG MODE

It is very important that you change your APP_ENV to production and APP_DEBUG to false in the .env file when you are done testing and setting up the site.

Keeping APP_ENV to local or APP_DEBUG to true might expose sensitive information to end users.

What's Next?

Now you are all set to go, you can start using minetrax and add your servers to it. Below are some steps to follow next:

  1. Secure your Web with SSL Certificate
  2. Add your First Minecraft Server to Web
  3. Install Plugin on your Minecraft Server