Install Invoice Ninja v5 on Ubuntu 20.04

im on my four try… so

These instructions worked for me, after about four or five attempts and I have been running the beta version for about two months. My installation failed after I tried to upgrade from beta version .26 to the .43 release version. This is running in Ubuntu in a VIrtualbox hosted on Windows 10.

The application was working great but I had noticed updating stopped, so I tried “Force Update” and from then on, I get “500: Server Error” when I attempt a login. I figured I should update before I sent my invoices out to my clients. Bad move.

Now I can’t get in. I’ve looked at error logs for nginx and syslog and not seen anything obvious. I tried to enable debugging in the .env file as suggested in other posts, but I saw no additional info.

I would (and may still) try to install a clean copy on a new instance of Ubuntu, but I have two months of detailed expenses entered into the database. I’ve been diligent about keeping the database backed up but figured—incorrectly—that the update process on the front-end application was stable. That would, after all, be part of a “stable” release, though maybe not from a beta version. Whatever. If I have to reenter these transactions with dozens of documents and attachments, it will require days of tedious data reentry.

WHen I tried stepping through the installation process here, the Composer component balked, put up an error message about being deprecated, and referred me to a new version of the app that I installed directly from the Composer source. Any production release of InvoiceNinja would ideally be compliant with the current releases of supporting components, and that would include Composer and php.

I will try a clean install in newly created Ubuntu instance and stick to these instructions, which I am suspecting are becoming out of date as components move to new versions. Anyone here have guidance about copying the SQL data already entered from an existing V5 database to a new instance? I can write and run SQL queries and dumps, but i know there are foreign-keyed tables that need to be moved together, and I probably do not want to migrate my user credentials in the new installation.

I would appreciate any suggestion on either recovering the existing installation or migrating the data to a fresh instance of the new installation (which I have yet to successfully install, and it’s a tricky process especially for people who aren’t nginx developers. I suspect most readers here would agree)

You can backup with mysqldump, here are some examples of usage:

https://www.sqlshack.com/how-to-backup-and-restore-mysql-databases-using-the-mysqldump-command/

I’ve got the sql backup already (a requirement of my day job that I bring to my side gigs). Does the current stable release, .46, have any new columns, indexes, foreign keys, constraints etc. been added or modified, since .26 beta? Is a backup of .26 be compatible with the current release?

Sounds like I should give up troubleshooting and coaxing my existing beta installation to work with the new code and spin up a new Ubuntu instance, install invoice ninja clean, and restore my dump.

I’m not sure what would be best for you, I primarily use RHEL and I update every time by installing from source code packages, because updating is only for Ubuntu. Also since the beta there have been significant changes and there were times where databases couldn’t work, in my experience. You might install an old version and export your stuff to other format, csv or something better, and import on a clean environment. It seems that from here on out major changes like that are all done. That’s what I did, and my work is very clean now and since beta has been over its been more stable than ever for me.

Hi,

I think you may want to consider changing this line:

$ sudo wget https://github.com/invoiceninja/invoiceninja/releases/download/v5.0.21-release/invoiceninja.zip

to

$ sudo wget <latest zip url>

This would prevent someone from accidentally installing a very old version.

1 Like

@TechnicallyComputers Perhaps you or someone more knowledgable can clean up this running list of installation ideas? It would be REALLY helpful. I’ve started over 5-6 times now and I don’t feel like I’m getting anywhere. I already use Nginx Proxy Manager and I’m using that to proxy traffic to the correct location when utilizing my domain. I have been able to twice (not using this tutorial, but an older one) to get to the installation screen. I connect to the DB (successful) and connect to SMTP server (successful). When I hit the button to move forward, it acts like it’s doing something for 20-30 seconds and then goes to “Whoops, something has went wrong” but displays nothing further.

Thanks in advance!

Please check for details about the error in storage/logs

Also, please create a new post if you need further help

This week I did several installations and non work direct. I used docker on windows, docker on linux and finaly I an Ubuntu install and followed this guide.

What I found in the logging is:
production.ERROR: file_put_contents(/usr/share/nginx/invoiceninja/storage/framework/cache/data/79/81/7981a4e7e9bdc02180a3c3d1a6b2adf0ba424b1c): failed to open stream: Permission denied

This was with every installation that I did. This can be solved when you set the correct permissions.

/usr/share/nginx/invoiceninja
chmod -R 775 storage
1 Like

When you download the invoiceninja.zip file (instead of the source code) the permission setting step or the storage folder shouldn’t need to be taken. I believe this was changed a long time ago, during the apps beta.

I followed your instructions very well (thanks for that). Still got the 500 error when not setting the permissions manually. I did multiple installations before and this was the issue each time. Use the Release v5.1.65-release zip.

Now running into issues when creating a pdf. But will make a post if I cannot find the solution in the forum.

1 Like

What is the best update method with your installation guide? I want to download the customer export but having a 404 error. I want to be on the latest version before debugging this issue.

Can I just overwrite the files with a wget and unzip?

Yes but update from the GUI of the web app works on Ubuntu

1 Like

Yes. But use the ‘Source Code’ zip file. Not the ‘invoiceninja.zip’ file because that contains an .env file which would overwrite your .env file.

But simplest method is to update from the web UI (info-icon on the bottom).

For PDF, did you install the recommended packages like mentioned in the post? Maybe you’ll need also libgbm-dev and libxshmfence-dev

i tried that but got the message “Cannot update system because main.js is not writable”

I dont have issue with pdf. The zip file for customers in this case. I installed all the packages.

I have trimmed the instructions, removing steps for composer, since I don’t believe composer is necessary to install on Ubuntu with the invoiceninja.zip file, only with source code installations on other distros. Also removed some other dependencies that aren’t necessary.

I have also changed every instance of ‘php’ to ‘php7.4’ or ‘php7.4-*’ in order to be more explicit about which version of PHP is installed, and configured. By explicitly specifying php7.4 in every situation, your installation can be more stable and reliable. Also ensure, that php7.4 is specified not only in the nginx configuration for php-fpm socket, but also for your scheduled cron job running php artisan (* * * * * * www-data php7.4 artisan …)

Did you test your instructions in a new VM?

I reinstalled Ubuntu directly as the host and restored my configuration files for nginx and .env, and reinstalled the latest version of v5 from the packaged invoiceninja.zip release.

The only thing I did before was setup a simple php blog with php8. The conflicting versions of php led me to this php change that is more explicit and less prone to failing on more variety of systems. If a newer version comes out or is installed for another service on the system you won’t break it this way because you point at the socket directly instead of through its alias.

Composer or node are only necessary at this point if you have the source code. These packages are capable of self updating, so they don’t depend on you running composer and node to work, and all the updates are version locked per release this way, it is better.

1 Like

I’ve used you’re guide and everything works perfectly for me with a few tweaks. One suggestion or possible instruction subtopic for Proxy Users (Nginx Proxy serving Nginx InvoiceNinja) or those wishing to install behind Proxy:

On InvoiceNinja Server

Follow all instructions however omit installing SSL
Change invoiceninja.conf to listen without encryption

server {
listen       80 default_server; #Nginx doesn't support using HTTP2 from proxy to backend
listen       [::]:80 default_server;
....

and remove SSL configurations (by either deleting or commenting)

#ssl_certificate "/etc/nginx/cert/ninja.crt";
#ssl_certificate_key "/etc/nginx/cert/ninja.key";
...
#ssl_prefer_server_ciphers on;
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

On Reverse Proxy Server

Create server configuration file (either in conf.d or sites-available) and paste this into

server {
    listen 443 ssl;

    server_name invoices.example.ca; #Replace with your server name

    # Enter the path to your existing ssl certificate file & certificate private key
    # Or you can configure one with openssl or Let's Encrypt
    ssl_certificate "/etc/nginx/cert/ninja.crt";
    ssl_certificate_key "/etc/nginx/cert/ninja.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 TLSv1.1 TLSv1.2;

    # This is important or you will get 413 Server error from the proxy side 
    client_max_body_size 20M;

    location / {
                    proxy_set_header        Host $host;
                    proxy_set_header        X-Real-IP $remote_addr;
                    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header        X-Forwarded-Proto $scheme;
                    # Enter the IP or Internal DNS name of the server Invoice Ninja is installed on
                    proxy_pass              http://192.168.1.1/; # or http://host.internal.com/ 
                    proxy_redirect          off;
                    }
}

server {
    if ($host = invoices.example.ca) {
        return 301 https://$host$request_uri;
    }

    listen 80;
    server_name invoices.example.ca;
    return 404;
}

This configuration will handle all requests and force ssl on the client to the Proxy. The Proxy will decrypt all client requests and forward those off to the InvoiceNinja server and encrypt all responses before serving them back to the client (SSL Termination). If you wish for the Proxy to use SSL with the InvoiceNinja server there are tutorials that you can find for Upstream SSL. I was using it for a bit and found in my environment it was too CPU intensive on my hardware and performance was sluggish.

I have lots of changes to the NGINX configuration file and because I never knew apache well enough before I would like to test an apache configuration eventually as well. Probably as an alternative installer guide, identical except for web server instructions. Specifically I want to improve the security, and the annotation of the configuration file.

I will look over your suggestions when I eventually come around to reviewing the NGINX document more closely, which won’t be right away, but will happen sooner or later this summer.