Install Invoice Ninja v5 on Ubuntu 20.04

update 2021-10-15: Updates are working well now through 5.3.23, though I make sure I clone my Ubuntu instance before each just in case, especially as Iā€™m up to several hundred expense entries. This is EXACTLY the product I need.

Thanks to hurricane evacuations and a death in family I have not run my local instance of InvoiceNinja since last August.

Today I ran it and was notified of Update Available, from 5.2.19 to 5.3.0, after sudo-apt-upgrading Ubuntu 20.04 I have been running updates from the installed web app successfully all summer.

Today the update completes but login errors out with a ā€œ500 Server Errorā€ notification. I am not finding any errors in the log files, I have learned to clone my Ubuntu instance as the updating process was fraught with pitfalls. Those seemed to go away in July but here I am again with a "500 Server Errorā€™ after upgrade.

Finally I did a full reinstall of the packages via

apt install php7.4 php7.4-{fpm,bcmath,ctype,fileinfo,json,mbstring,pdo,tokenizer,xml,curl,zip,gmp,gd,mysqli} mariadb-server mariadb-client curl git nginx vim composer -y

and then also

sudo php artisan optimize
and
https://invning.local.lan/update?secret=?

and finally took care to choose the upgrade from the info icon instead of the triangle notice.

Not sure which of this did the trick, but it was hours of work just to get back to my invoices.

Honestly, despite the onerous prospect of transferring all this data, particularly the attachments, I was ready to start looking at other solutions. I do appreciate the rapid improvement and enhancement of the InvoiceNinja application, but a simple update should not require this level of experimentation. Self-hosting is not something that the average user would ever need to understand, but if thereā€™s an ā€œupdate nowā€ button, it oughta work without a whole day spent searching for workarounds.

Also, the app upgraded to 5.3.17, which is the current level on Github and not the 5.3.0 shown in the upgrade box. Not important, but not confidence-inspiiring, either.

i am trying to setup v5 on debian on apache2 but i get this error ā€œComposer detected issues in your platform: Your Composer dependencies require a PHP version ā€œ>= 7.4.0ā€.ā€ and i already have php7.4

I would use
CREATE SCHEMA db-ninja-01 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
instead, just to be sure and because this is the official documentation.

Like maxwellsmartconstinc you I have ninja behind a reverse proxy.

I had to add the proxyip to the .env file

nano /usr/share/nginx/invoiceninja/.env
TRUSTED_PROXIES=your proxy ip

1 Like

@TechnicallyComputers

You might want to have a look at

nginx was set up according to your guide.

My DNS service provides protection of my direct IP address automatically, so I cannot test this myself, but can you add to your NGINX conf file these lines, where invoice.example.com is your domain name:

 if ($host != $server_name) {
   return 301 https://$server_name$request_uri;
 }

If you add this line anywhere in the NGINX server block listening on 443, it should force redirect any attempted connections into using the specified domain for access, regardless of what addressing they used before.

Note that you must reset NGINX service after the change to the conf file with

 systemctl restart nginx

If you can please verify that it does work, I will add this line to the server block in my notes.

Hello,
thank your for the installation guide but Iā€™m having trouble to get it working.
Yesterday Iā€™ve tried the installation using Debian11 and after it failed several times Iā€™ve tried Ubuntu Server 20.04 today. But the problem is still the same. :frowning:

After Iā€™ve done all steps I open the browser with the url and setup starts. But here is the problem: the setup page is having errors. I think something is missing there :slight_smile:

The storage/logs/laravel.log had only one entry which is caused by a wrong db name. Server error log ā€œ/var/log/nginx/error.logā€ is empty.
I have no idea whats wrong.

Thank you for your input!

Hello Tim

What error do you get?
The screenshot you posted looks normal to me. What happens when you typ in the URL and click on ā€˜Test PDFā€™? Normal behavior is that in the next step you should be asked for your database info.

Hello KrisL,

the log says: production.INFO: db fails
I had a look to the youtube video and there the setup was only on one page and not separate steps. The ā€œTest PDFā€ shows an error: Oops, looks like something isnā€™t correct!
After I pressed the button a new message appeared in the log: production.INFO: account table not found

The setup has evolved since then and it is now a page that expands as you progress through all the steps. The video you watched is older.

You should verify you have the dependencies installed, and are using the invoiceninja.zip package from the releases on the github page for the project, that is prebuilt, and has the dependencies for generating PDF baked into it.

Mind you the PDF generation is a web service, you must have a FQDN (fully qualified domain name) and a secure https address, with valid ssl certificate, or the PDF web service will not work.

Iā€™ve never setup the software on Debian, and I know there are differences on debian from Ubuntu, so you may be running into issues beause of that also. If that is not something you can or want to fight with, you can try simply running the docker container that comes built with an ubuntu base:
https://hub.docker.com/r/invoiceninja/invoiceninja/
There are links in the docker page documentation to a list of all the environment variables you can use to setup the docker instance with, which is used to configure your instance instead of modifying a .env file.

Some users have gotten it to work on Debian in these forums, I donā€™t know what steps they had to take differently though.

1 Like

Thank you for the information! Iā€™ve installed the docker version with an external DB. It working now :slight_smile:

1 Like

I am glad it is working for you now. So you know, though I saw no issues with my existing setup after updating, I had an error with setting up self host server with v 5.3.25, and testing PDF step, consistent to what you reported. It may be you just ran into a bug with that. Not sure why or what cause, but running setup on 5.3.21 then updating worked around it, and the current versions (now 5.3.28) have resolved the issue altogether. As long as you have it installed tidy and self updating without issues, that is great though. I havenā€™t tried living with the container image before, and Iā€™d be curious as to how it is if the experience requires more or less maintenance than the local install.

It seems this is no longer necessary and done by the setup?

1 Like

Thanks for notifying me. I will try to make time this weekend to verify the process has been updated and make the change.

Is it possible to install with just apache on Ubuntu (or does someone have solid directions)? Iā€™ve tried several times, different ways with youtube, and I canā€™t get it to work. I already have an Nginx server setup. my mind is shot and iā€™m probably missing or doing something stupid. Iā€™m not a Linux person, so a little lost. Trying to learn, but ive just been burned out from work. Thanks!

@smartkid808 If you talking separated web, sql, etc. Yes. On small deployments having the LAMP stack on one machine is common but in larger environments I like the LAMP stack separated out in separate servers(VMā€™s). This is how I do it.

Iā€™m trying to do a clean install but the following command doesnā€™t work:

# apt install php7.4 php7.4-{fpm,bcmath,ctype,fileinfo,json,mbstring,pdo,tokenizer,xml,curl,zip,gmp,gd,mysqli} mariadb-server mariadb-client curl git nginx vim composer -y

Gives me this following error:

image

@SecureCPU

This error means your system cannot find the PHP 7.4 packages.

Here is a guide to get PHP7.4 installed, please note Ubuntu 20.04 has 7.4 by default, so i am guessing you are using a different version? Also not, you can replace PHP 7.4 with PHP 8.0 as they are both compatible with Invoice Ninja.

I have a new install, and trying to do the setup, but keep getting error 500 after I submit the setup form.

I already tried sudo chown -R www-data:www-data /usr/share/nginx/invoiceninja for permissions.

and this is the error I see in the logs:

[2022-07-25 16:26:34] production.ERROR: Attempt to assign property ā€œformat_momentā€ on null {ā€œexceptionā€:"[object] (Error(code: 0): Attempt to assign property ā€œformat_momentā€ on null at /usr/share/nginx/invoiceninja/database/migrations/2022_07_18_033756_fixes_for_date_formats_table_react.php:17)

Would anyone be able to help me?