In this document the process is explained to install SoloDB on Linux server. To run SoloDB the following services will be installed. This document is based on Debian but can also be used on Ubuntu

Service Role
PHP 8.2 (fpm and cli) SoloDB is written in PHP 8.2. FPM is used to render the application and CLI for cronjobs
Nginx Nginx will handle the incoming requests and forward to PHP. In this setup Nginx acts mainly as proxy server
GIT Git is used as code management system and for updates on SoloDB
Redis SoloDB users caching to speed up the application
Solr Search engine using SoloDB search configuration
MySQL Database server

Pre requirements

For this install a (virtual) server running Debian is required

  • Disk: minimal 64 GB
  • CPU: 4 Cores
  • Memory: 8192 MiB

Software installation

Install GIT, PHP, NGINX and Redis

sudo apt-get update && apt-get upgrade

sudo sudo apt-get install \
    ca-certificates \
    curl \
    gnupg2 \
    wget \
    lsb-release

For PHP, we use the sources of Oerdnj Sury

On Ubuntu

sudo add-apt-repository ppa:ondrej/php
sudo apt update

On Debian

curl -sSL https://packages.sury.org/php/README.txt | sudo bash -x
sudo apt update

Install packages

apt-get install git nginx-full rsync redis-server php8.2-fpm php8.2-cli php8.2-common php8.2-intl php-redis php8.2-gd php-igbinary php8.2-mysql php8.2-mbstring php8.2-zip php8.2-xml php8.2-curl php8.2-opcache php8.2-readline php8.2-soap php8.2-bcmath php8.2-redis php8.2-gmp

Set the default PHP version to PHP 8.2

sudo update-alternatives --set php /usr/bin/php8.2

Login and log out to reload the permissions

Install MySQL, using the installation package of MySQL. Debian will install MariaDB as default database server when no extra sources are added. The latest version can be found on the APT pages of MySQL

wget https://dev.mysql.com/get/mysql-apt-config_0.8.23-1_all.deb
sudo apt install ./mysql-apt-config_0.8.23-1_all.deb

sudo apt-get update
sudo apt-get install mysql-server

sudo mysql_secure_installation

Create a dedicated user for SoloDB

CREATE USER 'solodb_admin'@'172.%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON `solodb_production`.* TO 'solodb_admin'@'172.%';
FLUSH PRIVILEGES;

Install SOLR (version number might be higher, can be checked on the Solr Download page)

sudo apt-get install default-jdk default-jre
wget https://www.apache.org/dyn/closer.lua/solr/solr/9.6.0/solr-9.6.0.tgz?action=download
mv solr-9.6.0.tgz?action=download solr-9.6.0.tgz
tar xzf solr-9.6.0.tgz solr-9.6.0/bin/install_solr_service.sh --strip-components=2
sudo ./install_solr_service.sh solr-9.6.0.tgz

Clone SoloDB SOLR docker repository and reload SOLR (as solr user)

sudo su && su solr
ssh-keygen #Upload the key to Github to prevent API rate limits
git clone https://github.com/jield-webdev/solodb-solr /var/solr/data
exit
sudo service solr restart

Create database and import the basic database into the mysql-server

mysql -u root -p

Download a copy of an empty database

create database solodb_production;
use databse source ./emtpy_solodb_database.sql

NGINX Configuration

SoloDB requires a few changes to NGINX, which are described here

Create a vhost with the following settings, or replace /etc/nginx/default with the following file

server {
        listen 80 default_server;
        server_name _;

        client_max_body_size 30M;
        root /var/www/solodb/public;
        index index.php index.html;
        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_read_timeout 300;
                include fastcgi_params;

        fastcgi_param SOLODB_ENVIRONMENT production;
        fastcgi_param SOLODB_HOST host;
    }
}

Use nginx -t to test the configuration and restart nginx using service nginx restart when the config is OK

PHP Configuration

Edit /etc/php/fpm/8.2/fpm/php.ini and change the following settings

; How many GET/POST/COOKIE input variables may be accepted
max_input_vars = 10000

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 1024M
upload_max_filesize = 64M
post_max_size = 64M

Restart PHP with service php8.2-fpm restart

Clone SoloDB repository

Upload the generated public key to GitHub and clone the SoloDB repository in /var/www/solodb

Create a new file called production.local.php and save in /var/www/solodb/config/<organisation> folder and the following content

<?php

declare(strict_types=1);

use Doctrine\DBAL\Driver\PDO\MySQL\Driver;

return [
    'doctrine' => [
        'connection' => [
            'orm_default' => [
                'driverClass' => Driver::class,
                'params' => [
                    'host' => '172.17.0.1',
                    'port' => '3306',
                    'user' => 'solodb_admin',
                    'password' => 'PASSWORD',
                    'dbname' => 'solodb_production',
                    'driverOptions' => [
                        PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'",
                    ],
                ],
            ],
        ],
    ],
    'solr' => [
        'host' => '172.17.0.1',
    ],
    'cache' => [
        'options' => [
            'server' => [
                'host' => 'localhost',
                'port' => 6379,
            ],
            'database' => 1,
            'namespace' => 'solodb',
        ],
    ],
    'application_options' => [
        'serverUrl' => 'https://hostname.solodb.net',
    ],
    'admin_options' => [
        'clientId' => '1234', //Equipage GraphAPI version
        'clientSecret' => '5e67',
        'tenantId' => 'test',
    ],
    'lmc_cors' => [
        'allowed_origins' => [
            'https://hostname.solodb.net',
        ],
        'allowed_methods' => ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'],
        'allowed_headers' => ['Authorization', 'Content-Type', 'Accept'],
    ],
];

Run Composer to install all dependencies

php composer.phar install --no-dev --prefer-dist

Optional install of Certbot

```shell
sudo apt-get install certbot python3-certbot-nginx