Setup Web (Manually)
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
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 2GB 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
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
Make sure to only install one. Either MySQL or MariaDB. If installing MariaDB, make sure its version is >10.2.7.
- MySQL
- MariaDB
To install MySQL run the below command in terminal.
sudo apt install mysql-server
To install MariaDB run the below command in terminal.
sudo apt install mariadb-server
Apache2 / Nginx
Make sure to only install one. Either Nginx or Apache2.
- Apache2
- Nginx
Install Apache2 server and php extension for it.
sudo apt install apache2 libapache2-mod-php8.2
sudo systemctl restart apache2
Install Nginx server and php-fpm runner.
sudo apt install nginx php8.2-fpm
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
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
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.
- Apache2
- Nginx
# 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/*
# If using NGINX (not on CentOS):
chown -R $USER:www-data /var/www/minetrax/*
# or, If using NGINX on CentOS:
chown -R $USER:nginx /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.
[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.
[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:*
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)
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.
- Go to pusher.com and create a account.
- In dashboard select "Channels" and then click "Create app" option to create a new app.
- Name your app anything you like and choose a location closest to your server location. Choose
Vue.js
in Frontend andLaravel
in Backend dropdowns. - Click
Create App
. - Now go to
App Keys
section and note down theapp_id
,key
,secret
andcluster
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.
PUSHER_APP_ID=1367909
PUSHER_APP_KEY=4b48b850682acb371c34
PUSHER_APP_SECRET=41cc8be68c0d57fea4f3
PUSHER_APP_CLUSTER=ap2
Also change broadcast driver to pusher.
BROADCAST_DRIVER=pusher
Next, restart the queue workers:
cd /var/www/minetrax
php artisan queue:restart
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.
Follow either Nginx or Apache2 steps as per your installation.
- Apache2
- Nginx
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
<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
You should disable default site /etc/apache2/sites-enabled/000-default.conf
.
sudo a2dissite 000-default.conf
sudo systemctl restart apache2
First, Create a new file with any name(eg: minetrax.conf
) in the Nginx sites directory /etc/nginx/sites-available
with context provided below replacing highlighted section as per your installation.
sudo nano /etc/nginx/sites-available/minetrax.conf
server {
listen 80;
listen [::]:80;
server_name your_domain.com www.your_domain.com;
root /var/www/minetrax/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index 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; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Now create a symlink of the file created to sites-enabled
folder.
sudo ln -s /etc/nginx/sites-available/minetrax.conf /etc/nginx/sites-enabled/
and finally reload your Nginx server to reflect the changes.
sudo systemctl reload nginx
If this is a new VPS, you should disable default site /etc/nginx/sites-enabled/default
by removing it.
sudo rm /etc/nginx/sites-enabled/default
sudo systemctl reload nginx
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
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.
APP_NAME="YOUR_DESIRED_APP_NAME"
APP_ENV=production
APP_DEBUG=false
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: