Update: Ignore this guide. It is already out of date again and the PDF creation does not work.
I will come back and Update this guide, when v5 is ready for production. For now I will stay on v4.
Beginners guide to install InvoiceNinja5 on Ubuntu.
I found the official not very noob friendly and after my 4th try installing I wrote my own
I have not tested it in production yet!
Any recommendations to make this better are highly appreciated!
Let us make sure we are on the latest patches
apt update
apt upgrade
apt dist-upgrade -y
install mariadb and nginx
apt install mariadb-server nginx
install php stuff
apt install php-{fpm,bcmath,ctype,fileinfo,json,mbstring,pdo,tokenizer,xml,curl,zip,gmp,gd,mysqli}
change the default site for testing
sudo nano /etc/nginx/sites-enabled/default
Here is how the location section should look like. Watch out for #. At the time of writing, php7.4-fpm.sock is default for ubuntu 20.04.2 LTS.
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
This should give no error, if you wrote everything correct
nginx -t
create a php test file
sudo nano /var/www/html/info.php
insert this
<?php phpinfo(); ?>restart nginx
systemctl restart nginx
with a browser go to
http://your_server_domain_or_IP/info.php
Look if it is using FPM at the line Server API. Should look like this:
Server API FPM/FastCGI
install stuff for snappdf
apt install ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils libgbm-dev libxshmfence-dev
Remove default NGINX sites:
sudo rm rm /var/www/html/*
sudo rm /etc/nginx/sites-enabled/default
I am planning on putting it behind a NGINX Proxy so I have a pretty simple configuration without SSL. If you wanne use SSL on this machine, you can use the same but run certbot afterwards.
sudo nano /etc/nginx/sites-available/invoiceninja.conf
paste this
server {
listen 80 ;
listen [::]:80;
root /var/www/invoiceninja/public;
index index.php index.html index.htm;
client_max_body_size 50M;
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;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q= last;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
Configure Mysql. Use the defaults.
mysql_secure_installation
login into mysql with the password you just set
sudo mysql -p
#create DB. I use the same password here again, ideally you use a different one
create database ninjadb;
create user 'ninja'@'localhost' identified by 'samepassword';
grant all privileges on ninjadb.* to 'ninja'@'localhost';
flush privileges;
exit;
Create the folders and download the files:
mkdir /var/www/invoiceninja
cd /var/www/invoiceninja
Here you should input the latest zipfile from Releases ยท invoiceninja/invoiceninja ยท GitHub. Just right click on it and copy the download path.
sudo wget https://github.com/invoiceninja/invoiceninja/releases/download/v5.1.37-release/invoiceninja.zip
Unpack and delete
apt install unzip
unzip invoiceninja.zip
rm invoiceninja.zip
chown -R www-data:www-data /var/www
disable PhantomJS_PDF
nano .env
adjust this line
PHANTOMJS_PDF_GENERATION=false
add the crontab
sudo -u www-data crontab -e
press 1 and insert this
* * * * * cd /var/www/invoiceninja/ && php artisan schedule:run >> /dev/null 2>&1
this enables the site
ln -s /etc/nginx/sites-available/invoiceninja.conf /etc/nginx/sites-enabled/
just to be sure, not really needed
sudo systemctl stop apache2
sudo systemctl disable apache2
sudo systemctl enable nginx
reboot the machine.
Visit http://ip_of_your_System/setup
#setup config
http://ipofyourserver/setup
https disable (because it is behind a proxy that does this.
Test PDF gives back success!
Database connection we input the credentials we created in the MySQL Part before.
Database ninjadb, user ninja, Password samepassword.
Everything should work. Ignore the cron warning, it should go away after 5min