Install Invoice Ninja v5 on Enterprise Linux 8

A complementary Ubuntu 20.04 LTS version would also be fantastic.

This should work just fine. I tested it all on an Ubuntu VM tonight.

1 Like

Thanks. It’s very helpful.

Thanks for the detailed guide @TechnicallyComputers :metal:

It’s helped me perform the install on a Debian 10 (Buster) LEMP stack obviously using Debian equivalents where necessary. My Ninja setup page is redirecting back to itself on first run so I’ve got some debugging to do :hammer: :smiley:

Just a note of something I noticed while installing composer. After install you ran the update command:

$ sudo composer update

I’m new to composer but the composer documentation explains that update will install the latest available versions of all dependencies then update the lock file with the newly installed version numbers.

Now please don’t take this the wrong way, I’m merely being an inquisitive debugger in lieu of detailed documented requirements from the Invoice Ninja crew. It seems to me, the purpose of the composer.lock file is to ensure anybody deploying a project (in this case Invoice Ninja) ends up with the same suite of dependencies as when the project was successfully compiled, therefore omitting the possibility of incompatible dependencies being loaded. If the lock file is overwritten with the latest versions by the update command, we no longer have the same working environment for Ninja as when it was compiled by the Ninja devs. To quote

If there is a composer.lock file in the current directory, it will use the exact versions from there instead of resolving them. This ensures that everyone using the library will get the same versions of the dependencies.

I completely get installing the latest versions of everything by default; I’m attempting the v5 install primarily because I didn’t want to roll back my php7.4 to an older version (v4 being incompatible with 7.4). Now, you have Ninja working and so again, I’m not questioning your methods :v: :grin: but my question is I suppose, was there a reason for updating to the latest dependencies rather than abiding by the composer.lock file in the Ninja zip?

I wasn’t aware of this about composer and the lockfile to standardize dependencies. Thats very intelligent design, and I understand and support the idea for stability and standardization.

I’m going to have to research that more, and update my notes before rewriting anything yet though.

I would say this guide is for CentOS 8, and it has very different dependencies and issues than Ubuntu and probably Debian. For example, the file is not possible to install on CentOS 8. Composer may work but npm update will critically fail almost every step. CentOS 8 requires installing from exclusively. Seems the source code has this file too, so I might test that.

I’d say I only recently confirmed this to myself and didn’t update this version of the guide yet since I was making other changes as well so this wasn’t reflected when you read this guide

1 Like

I guess I wondered if you updated the dependencies beyond the .lock file versions on purpose to help with bugs. It’s my first time using any dependency managers to create ‘sandbox’ environments and I also think it’s pretty cool for standardisation.

Also, you might be interested to know that Node.js/npm has the same functionality using the .json file:

install - Installs dependencies to the dev spec in json file
update - Ignores the json file and update to latest available

There’s a short post here that explains their behaviour well if it interests you.

After I posted this I found your write up on Ubuntu :grin:

Actually both your guides helped me in different places with Debian so thank you! Now I have to fix a login screen bug :face_with_monocle:

1 Like

Login screen bug might be php-fpm related. Verify php-fpm is configured properly if you have not already. My CentOS 8 guide assumes a CentOS 8 environment, and the nginx configuration notes assume default CentOS 8 paths for php-fpm sockets. Relevant:

   fastcgi_pass unix:/var/run/php-fpm/www.sock

Configure nginx/apache to point to this socket wherever php-fpm is configured to run it on your system and ensure your web server has permissions to access it also based on the conf file for php-fpm, wherever it is installed.

I’ll make a reminder to read this stuff next weekend or something, thanks.

Thanks, PHP is ok I think, it’s pointed here in the nginx block

fastcgi_pass unix:/run/php/php7.4-fpm.sock;

I think my problem is mariadb related:

Deserializing '[data, [{permissions: , n~

It’s a server running a few other sites too so everything seems healthy

Did you try to migrate data, or clean install? Data migrations must be done through the webui on v4, running parallel to v5 with two resolvable domains, and will fail if you use SQL dump methods. If your permissions are not sticking with the defined mariadb user, you might experiment with using the root user, to try and rule out one variable. Ok good luck, I have other work. The slack chat is very active by the devs, if you need to look for a little more deeper support that’s a good resource.

It’s a clean install. Thanks for the tip that’s a good idea, I think I’ll try with root. If I solve it I’ll make a note to the solution on here as I’ve talked about it now.

Thanks for your help :+1:

EDIT: The issue causing Deserializing '[data, [{permissions: , n~ on the login modal appears to be fixed in the latest git v2 branch :partying_face:

1 Like

Thanks for the update, that’s great to hear!

1 Like

For those like me, looking for chrome headless dependencies in debian based OS:


firewall-cmd command is wrong and should be,

$ sudo firewall-cmd --zone=public --add-service=http --permanent
$ sudo firewall-cmd --zone=public --add-service=https --permanent
$ sudo firewall-cmd --reload

sudo -u nginx mkdir -p /usr/share/nginx/invoiceninja gets permission denied. You instead have to use chown -R after creating the folder
sudo chown -R nginx:nginx /usr/share/nginx/invoiceninja

1 Like

Excellent guide, thank you TechnicallyComputers! Just noticed a few minor things that I had to tweak to get everything working!

MariaDB refused to create a database with dashes in it, so I used ninja instead:
create database ninja;

–permanent needs to be the first command here:
sudo firewall-cmd --permanent -zone=public -add-service=http
sudo firewall-cmd --permanent -zone=public -add-service=https

Not sure if this is the same for others, but git was not installed on my system by default:
sudo yum install git

Composer needs to be installed before generating key:
sudo php artisan key:generate

When backing up, had to make the directory first:
sudo mkdir backupdir

Then I had to remove the slash before /backupdir for the following commands:
sudo cp .env backupdir/invoice-backup-envfile
sudo mysqldump -u root -p ninja > backupdir/invoice-backup-db.sql

Other than that everything worked perfectly! Now the struggle to get migration from v4 working… :rofl:

1 Like

Thanks for catching the typos. I’ve been updating the guide pretty frequently, and recently tried adding respect for the nginx user throughout the process more explicitly, which also produces fewer warnings than running as root and changing ownership after. I’ll update that this weekend.

The migration is a struggle. I have two physically separate machines running the v4 and the v5 throughout this whole beta process and that helps. I keep the old v4 offline and use hosts files to provide name resolution for it, to accommodate the migration process.

I noticed that too after trying to use the name ‘db-ninja-01’. I only put that there to match the default on the setup page, without matching the default .env.example. I’ll change that too, but fyi it will actually work as a db name if you wrap the db name in that lower case tilde key like this:

CREATE DATABASE `db-ninja-01`;

But I recommend just using a regular name like ‘ninja’ or ‘invoices’

I’ve made the relevant changes, and then some. I’ve noticed you used a relative path for the backupdir. That was not my intention. I’ve been more explicit now in the instructions, but you should be backing up those critical files to another physical storage device mounted somewhere else on the system (which can be used along with a compatible version of invoice ninja code to reinstall and reconfigure your database).

It might not really apply to VPS users, but I am sure they can just backup to any other directory on the VPS at minimum, and make their own backup solutions.

My intention is to prevent you from accidentally wiping out your encryption key while making changes to IN setup, and to protect you from filesystem or device failure of your primary storage.

1 Like

Hi @TechnicallyComputers

thanks for the tutorial… so far so fine, but the Nginx doesn’t load the invoiceninja server block. I get the default Nginx page. Do u have any suggestions to fix this?

Many Thanks

You have a fully resolvable domain? This could be a few things, you could not have DNS with for example cloudflare setup right. If you know you don’t and want it to work anyways, you could make the domain name resolvable using /etc/hosts and adding a new line for your desired website name.

The guide covers setting up OpenSSL for local encryption, but to make a public facing website with something like cloudflare dns, and letsencrypt for SSL certificates, but that’s beyond the scope of this, and it assumes you have that setup.

If you do have DNS setup and you believe it is correct, you could have to edit the .conf file for the nginx test site and change the extension to .conf.bak, and restart nginx, it may be overriding this other config.

I followed this very information guide to setup IN. And it seems to be mostly established. However, it seems as though the database tables are refusing the establish. I tried a previous walkthrough for an older version before finding this guide and it had me preform a
php artisan db:seed command.
Is there something similar missing from this guide?
I’m using a separately hosted DB.

The setup page defaults to the db-ninja-01 but if I enter my information I receive a “Success” message when testing the connection.

Error when enabling debug
# SQLSTATE[42S02]: Base table or view not found: 1146 Table 'invoices.accounts' doesn't exist (SQL: select * from accounts limit 1)

Hi @TechnicallyComputers , there is any chance for a guide like this for install V5 on FreeBSD12 ?