apt install php8.1-{bcmath,gmp,gd,mbstring,xml,curl,zip,gmp,mysql,fpm}
Create a new DB
CREATE DATABASE ninjadb;
Create a DB user
CREATE USER 'invoiceninja'@'192.168.1.88' IDENTIFIED BY '*************';
Set permissions
GRANT ALL PRIVILEGES ON ninjadb.* TO 'invoiceninja'@'192.168.1.88';
Remove the default configuration
rm /etc/nginx/sites-available/default
Create a new site config
vim /etc/nginx/sites-available/invoice-ninja.conf
Use the following baseline config
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name invoice-ninja.example.com;
client_max_body_size 20M;
if ($host != $server_name) {
return 301 https://$server_name$request_uri;
}
root /usr/share/nginx/invoice-ninja/public;
gzip on;
gzip_types application/javascript application/x-javascript text/javascript text/plain application/xml application/json;
gzip_proxied no-cache no-store private expired auth;
gzip_min_length 1000;
index index.php index.html index.htm;
ssl_certificate /etc/ssl/private/invoice-ninja.example.com.crt;
ssl_certificate_key /etc/ssl/private/invoice-ninja.example.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1.2;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q= last;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log /var/log/nginx/ininja.access.log;
error_log /var/log/nginx/ininja.error.log;
sendfile off;
}
Enable the site
ln -s /etc/nginx/sites-available/invoice-ninja.conf /etc/nginx/sites-enabled/invoice-ninja.conf
Create a new installation directory
mkdir /usr/share/nginx/invoice-ninja
Move into the new directory
cd /usr/share/nginx/invoice-ninja
Download the latest release zip file
wget https://github.com/invoiceninja/invoiceninja/releases/download/v5.8.32/invoiceninja.zip
Unzip the downloaded zip
unzip invoiceninja.zip
Remove the zip file
rm invoiceninja.zip
Copy the example .env
file
cp .env.example .env
Set file permissions
chown -R www-data:www-data /usr/share/nginx/invoice-ninja/
Setup a cronjob to run regular cleaning tasks
echo "* * * * * root /usr/bin/php /usr/share/nginx/invoice-ninja/artisan schedule:run >> /dev/null 2>&1" > /etc/cron.d/invoice-ninja