Manual Install

Ubuntu Instructions

1. Install OS

Ubuntu Server 17.10 "Artful Aardvark" (64bits) Or Ubuntu Server 16.04.4 LTS "Xenial Xerus" (64bits)

2. Repositories

sudo add-apt-repository -y ppa:nginx/development sudo add-apt-repository -y ppa:ondrej/php sudo apt update

3. Required Software

Tools
sudo apt install git tmux vim curl wget zip unzip htop nano build-essential
MySQL
sudo apt install mysql-server mysql_secure_installation
Supervisor
sudo apt install supervisor
Redis
sudo apt install redis-server
Nginx
sudo apt install nginx
PHP
sudo apt install php-pear php7.3-curl php7.3-dev php7.3-gd php7.3-mbstring php7.3-zip php7.3-mysql php7.3-xml php7.3-fpm php7.3-intl php7.3-bcmath
NodeJS and NPM
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt install nodejs
Laravel Echo Server (for socket.io and broadcasting)
sudo npm install -g laravel-echo-server

4. Configure PHP

sudo nano /etc/php/7.3/fpm/php.ini - Find ;cgi.fix_pathinfo=1 - Replace with cgi.fix_pathinfo=0 - Save and close (CTRL + X) - Restart php-fpm sudo systemctl restart php7.3-fpm

5. Configure Nginx

sudo nano /etc/nginx/sites-available/default - Append server { listen 80 default_server; root /var/www/html/public; index index.html index.htm index.php; server_name yourdomain.com; location ~* .(jpg|jpeg|png|gif|ico|svg)$ { expires 365d; } location ~ .(gif|png|jpg|jpeg|svg|css|js|ico)$ { valid_referers none blocked yourdomain.com www.yourdomain.com; if ($invalid_referer) { return 403; } } location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; } } - Save and close - Restart nginx sudo systemctl reload nginx

6.1 Secure Nginx with Let's Encrypt

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04 Note : If you are using ufw or any other firewall you will need to `allow` port `8443` for the next step. - With ufw sudo ufw allow 8443 && sudo ufw allow ssh && sudo ufw enable

6.2 For HTTP only

Note : Getting an SSL certificate is free and easy with Let's encrypt. You are higly encouraged to setup HTTPS in your website.
- Edit config/session.php (HTTPS Only Cookies -> false) 'secure' => env('SESSION_SECURE_COOKIE', false), - Edit config/secure-headers.php (HTTP Strict Transport Security -> false) 'hsts' => [ 'enable' => false, - Edit config/secure-headers.php (Content Security Policy -> disabled) 'custom-csp' => "",

7. Installation

UNIT3D
cd /var/www/html/ git clone https://github.com/HDInnovations/UNIT3D sudo chown -R www-data: storage bootstrap public config && sudo find . -type d -exec chmod 0755 '{}' + -or -type f -exec chmod 0644 '{}' + - Copy .env.example to .env and fill it with your APP, DB, REDIS, API KEYS and MAIL info
Composer
php -r "readfile('http://getcomposer.org/installer');" | sudo php --install-dir=/usr/bin/ --filename=composer composer install && composer require predis/predis && npm install && npm install --save-dev socket.io-client && npm run prod
Note : If you recieve a error during npm install regarding pngquant-bin@4.0.0 Or an error similar to ... binary doesn't seem to work correctly please run the following commands wget -q -O /tmp/libpng12.deb http://mirrors.kernel.org/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1_amd64.deb sudo dpkg -i /tmp/libpng12.deb && rm /tmp/libpng12.deb && npm install && npm run prod
Setup CRON
sudo crontab -e - Append * * * * * php /var/www/html/artisan schedule:run >> /dev/null 2>&1 /var/www/html/artisan becomes whatever directory you've set in your nginx config file
Set up UNIT3D
php artisan key:generate php artisan migrate --seed sudo chown -R www-data: storage bootstrap public config laravel-echo-server init The cli tool will help you setup a laravel-echo-server.json file in the root directory of your project (/usr/share/nginx/html). This file will be loaded by the server during start up. You may edit this file later on to manage the configuration of your server.
  • ? Do you want to run this server in development mode? = No (Yes for debug or developement)
  • ? Which port would you like to serve from? = 8443
  • ? Which database would you like to use to store presence channel members? = redis
  • ? Enter the host of your Laravel authentication server. = https://yourdomain.com
  • ? Will you be serving on http or https? = https
  • ? Do you want to generate a client ID/Key for HTTP API? = Yes
  • ? Do you want to setup cross domain access to the API? = No
You should see something like the following : appId: 73e82e6e1122cb58 key: 95eacbe008a722b247653afba0247c44 Note : Do not run the start command; the server should start automatically after loaded into Supervisor in the next section.

8. Configure Supervisor

sudo nano /etc/supervisor/conf.d/unit3d.conf
-Append [program:unit3d-queue] process_name=%(program_name)s_%(process_num)02d command=php /var/www/html/artisan queue:work --sleep=3 --tries=3 startsecs = 0 autostart=true autorestart=true user=www-data numprocs=2 [program:unit3d-socket-io] process_name=%(program_name)s_%(process_num)02d command=/usr/bin/node /usr/bin/laravel-echo-server start --dir=/var/www/html autostart=true autorestart=true user=www-data numprocs=1
Note : Adapt /var/www/html to the root directory of your server
- Save and close - Load new config and start the process sudo supervisorctl reread && sudo supervisorctl update && sudo supervisorctl reload sudo supervisorctl
You should see something like the following :
unit3d-queue:unit3d-queue_00 RUNNING pid 12838, uptime 0:00:10 unit3d-queue:unit3d-queue_01 RUNNING pid 12833, uptime 0:00:10 unit3d-socket-io:unit3d-socket-io_01 RUNNING pid 12828, uptime 0:00:10
Note : type exit at the prompt to exit supervisorctl
- Run sudo supervisorctl reload

9. Enjoy

You can now go to your site's URL
Note : The default username and password for admin is UNIT3D (set in .env)
Note : You can edit files in the config/ folder manually or via the config manager in the dashboard

Enjoy using UNIT3D !


Arch Linux Instructions

1. Required Software

Tools
sudo pacman -S git vim curl zip unzip
Supervisor
sudo pacman -S supervisor
Redis
sudo pacman -S redis
Nginx
sudo pacman -S nginx
PHP
sudo pacman -S php-fpm php-gd php-intl php-pear (aur)
MariaDB
sudo pacman -S mariadb
NodeJS and NPM
sudo pacman -S nodejs npm
Laravel Echo Server (for socket.io and broadcasting)
sudo npm install -g laravel-echo-server

2. Configure PHP

sudo vim /etc/php/php.ini
- Uncomment ;extension=bcmath ;extension=gd ;extension=intl ;extension=mysqli ;extension=pdo_mysql - Find ;cgi.fix_pathinfo=1 - Replace with cgi.fix_pathinfo=0 - Save & close (:wq on vim)

3. Configure MariaDB

mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql sudo systemctl enable mariadb && sudo systemctl start mariadb mysql_secure_installation

4. Configure Nginx

Debian like structure
sudo mkdir /etc/nginx/sites-available sudo mkdir /etc/nginx/sites-enabled - Edit config file : sudo vim /etc/nginx/nginx.conf
- Append to the end of the http block : http { ... include sites-enabled/*; }
UNIT3D configuration
sudo vim /etc/nginx/sites-available/unit3d.conf - Copy / paste server { listen 80 default_server; root /usr/share/nginx/html/UNIT3D/public; index index.html index.htm index.php; server_name yourdomain.com; error_log /var/log/nginx/error.log; location ~* .(jpg|jpeg|png|gif|ico|svg)$ { expires 365d; } location ~ .(gif|png|jpg|jpeg|svg|css|js|ico)$ { valid_referers none blocked yourdomain.com www.yourdomain.com; if ($invalid_referer) { return 403; } } location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { include fastcgi.conf; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; } }
Note : Replace yourdomain.com with your FQDN - Save & close - Activate this entry sudo ln -s /etc/nginx/sites-available/unit3d.conf /etc/nginx/sites-enabled/unit3d.conf - Test the configuration sudo nginx -t
Note : If you get the error could not build optimal types_hash append types_hash_max_size 4096; to your http block in /etc/nginx/nginx.conf

5. Start / enable newly installed daemons

sudo systemctl enable ufw cronie supervisord redis nginx php-fpm sudo systemctl start ufw cronie supervisord redis nginx php-fpm

6. Configure the firewall

- Enable the firewall sudo ufw enable - Allow HTTPS traffic sudo ufw allow https - For HTTP only traffic sudo ufw allow http - For the chatbox sudo ufw allow 8443

7. Installation

UNIT3D
cd /usr/share/nginx/html sudo git clone https://github.com/HDInnovations/UNIT3D sudo chown -R current-user: UNIT3D/ (replace current-user) cd UNIT3D/
Composer
- Copy .env.example to .env and fill it with your APP, DB, REDIS, API KEYS and MAIL info php -r "readfile('http://getcomposer.org/installer');" | sudo php --install-dir=/usr/bin/ --filename=composer composer install && composer require predis/predis && npm install && npm install --save-dev socket.io-client && npm run prod sudo chown -R http: storage bootstrap public config && sudo find . -type d -exec chmod 0755 '{}' + -or -type f -exec chmod 0644 '{}' +
Setup CRON
sudo crontab -e - Append * * * * * php /usr/share/nginx/html/UNIT3D/artisan schedule:run >> /dev/null 2>&1 /usr/share/nginx/html/UNIT3D/artisan becomes whatever directory you've set in your nginx config file
Set up UNIT3D
php artisan key:generate php artisan migrate --seed laravel-echo-server init The cli tool will help you setup a laravel-echo-server.json file in the root directory of your project (/usr/share/nginx/html). This file will be loaded by the server during start up. You may edit this file later on to manage the configuration of your server.
  • ? Do you want to run this server in development mode? = No (Yes for debug or developement)
  • ? Which port would you like to serve from? = 8443
  • ? Which database would you like to use to store presence channel members? = redis
  • ? Enter the host of your Laravel authentication server. = https://yourdomain.com
  • ? Will you be serving on http or https? = https
  • ? Do you want to generate a client ID/Key for HTTP API? = Yes
  • ? Do you want to setup cross domain access to the API? = No
You should see something like the following : appId: 73e82e6e1122cb58 key: 95eacbe008a722b247653afba0247c44
Note : Do not run the start command; the server should start automatically after loaded into Supervisor in the next section.
sudo chown -R http: .

8.1 Secure Nginx with Let's Encrypt

- Install Certbot sudo pacman -S certbot certbot-nginx - Create the certificates sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com - Enable auto-renewal sudo vim /etc/cron.daily/certbot-renew.sh - Append #!/bin/bash certbot renew --pre-hook "systemctl stop nginx" --post-hook "systemctl reload nginx" - Save & close
Note : If you are using SSL (HTTPS), you will want to make sure that the certificate files are readable by the user running the echo server. For example if you are using LetsEncrypt for SSL, you may need to run a command like : sudo chown http /etc/letsencrypt -R

8.1 For HTTP only

Note : Getting an SSL certificate is free and easy with Let's encrypt. You are higly encouraged to setup HTTPS in your website.
- Edit config/session.php (HTTPS Only Cookies -> false) 'secure' => env('SESSION_SECURE_COOKIE', false), - Edit config/secure-headers.php (HTTP Strict Transport Security -> false) 'hsts' => [ 'enable' => false, - Edit config/secure-headers.php (Content Security Policy -> disabled) 'custom-csp' => "",

9. Configure Supervisor

sudo vim /etc/supervisor.d/unit3d.ini [program:unit3d-queue] process_name=%(program_name)s_%(process_num)02d command=php /usr/share/nginx/html/UNIT3D/artisan queue:work --sleep=3 --tries=3 startsecs = 0 autostart=true autorestart=true user=http numprocs=2 [program:unit3d-socket-io] process_name=%(program_name)s_%(process_num)02d command=/usr/bin/node /usr/bin/laravel-echo-server start --dir=/usr/share/nginx/html/UNIT3D autostart=true autorestart=true user=http numprocs=1 Note : Adapt /var/www/html to the root directory of your server
- Save and close - Load new config and start the process sudo supervisorctl reread && sudo supervisorctl update && sudo supervisorctl reload sudo supervisorctl You should see something like the following :
unit3d-queue:unit3d-queue_00 RUNNING pid 12838, uptime 0:00:10 unit3d-queue:unit3d-queue_01 RUNNING pid 12833, uptime 0:00:10 unit3d-socket-io:unit3d-socket-io_01 RUNNING pid 12828, uptime 0:00:10
Note : type exit at the prompt to exit supervisorctl
- Run sudo supervisorctl reload

10. Enjoy

You can now go to your site's URL
Note : The default username and password for admin is UNIT3D (set in .env)
Note : You can edit files in the config/ folder manually or via the config manager in the dashboard

Enjoy using UNIT3D !