Hello.
I’ve been successfully using a self-hosted version of InvoiceNinja for my own business for about one year now and it’s been brilliant. The one caveat to that has been updates. Until now, every time I attempted to update either via web UI or on the command line, the process would fail horribly with 500 errors or 503 errors and several other web errors. After extensive searching and experimenting, I finally have the process set and it has successfully worked multiple times now.
Similarly to how I found this guide helpful, I thought I might share this and hopefully help a few others as well. This process only takes a few minutes (depending on the size of installation).
Base assumptions. All steps below assume you have sudo access via SSH. My installation is in production and is directly installed inside a VM (i.e. NO DOCKER) with nothing else installed, using Ubuntu 22.04, nginx, and mariadb; using the invoiceninja.zip file method of installation. These directions should work for CentOS, Fedora (I previously had it installed in Fedora), etc.; just use your relevant commands to do so. I have my installation located in /var/www/invoiceninja
; however, you should use the path to wherever you have your instance installed, as locations may vary depending on which directions you followed and if you are using Apache2 or Nginx and other factors.
InvoiceNinja VM Update
Backup Database
sudo mysqldump -u root ninjadb > ninjadb.(date).sql
- replace (date) with the current date. Ex:
ninjadb.19.02.2024.sql
- make sure you use the correct name for your active database, mine is
ninjadb
, yours may be different. The backup will fail without the correct db name. - Over time, you may wish to delete or move older versions of the back up and only keep the most recent one or two, as they can be large and take up lots of valuable space on the server.
- replace (date) with the current date. Ex:
Backup Web Files
sudo tar -cpzvf invoiceninja.(date).tar.gz /path/to/invoiceninja/
- replace (date) with the current date. Ex:
invoiceninja.19.02.2024.tar.gz
- Similarly to above, over time, you may wish to delete or move older versions of the back up and only keep the most recent one or two, as they can be large and take up lots of valuable space on the server.
- replace (date) with the current date. Ex:
Download & Install Update
cd /path/to/invoiceninja
sudo wget https://github.com/invoiceninja/invoiceninja/releases/download/v5.9.6/invoiceninja.tar
- (select and copy the link for the tarball of the latest release from Github - that is the latest as of writing this guide. You could also download the react only version instead of the full version with Flutter.)
sudo tar -xf invoiceninja.tar
- delete zip file:
sudo rm /path/to/invoiceninja/invoiceninja.tar
Update ownership
sudo chown www-data:www-data /path/to/invoiceninja -R
Install Update
sudo -u www-data composer install
Migrate
sudo -u www-data php artisan migrate
- Application in production. Are you sure you want to run this command?
Yes
- Application in production. Are you sure you want to run this command?
Optimize
sudo -u www-data php artisan optimize
FINISHED! Login to your updated system.
I hope this helps someone as I had not previously found any clear documentation on how to manually update my installation.
Edits: Various clarifications on assumptions.
Edit 2: Updated to reflect that as of 5.9.2, the ZIP file is no longer available and only tarballs are used.