1. Backup your data: Before you start, it’s a good idea to backup your Invoice Ninja data, including the database and any custom files.
  2. Set up a new LXC container with the temporary IP address (172.16.0.203).
  3. Install the required software on the new container:
sudo apt update 
sudo apt install nginx php8.1 php8.1-fpm php8.1-common php8.1-mysql php8.1-gmp php8.1-curl php8.1-intl php8.1-mbstring php8.1-xmlrpc php8.1-gd php8.1-xml php8.1-cli php8.1-zip mysql-server unzip wget
  1. Configure MySQL and create a new database for Invoice Ninja v5:
sudo mysql_secure_installation
sudo mysql -u root -p

# Run these SQL commands to create a new database and user for Invoice Ninja v5:
CREATE DATABASE invoiceninja_v5;
CREATE USER 'ininja_v5'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON invoiceninja_v5.* TO 'ininja_v5'@'localhost';
FLUSH PRIVILEGES;
EXIT;
  1. Download and install Invoice Ninja v5:
wget https://github.com/invoiceninja/invoiceninja/releases/download/v5.x.x/invoiceninja.zip
sudo unzip invoiceninja.zip -d /usr/share/nginx/invoiceninja
sudo chown -R www-data:www-data /usr/share/nginx/invoiceninja
  1. Configure Nginx:
  • Replace the existing /etc/nginx/conf.d/invoiceninja.conf with the content you provided.
  • Update the server_name in your Nginx configuration to clients.servici.ch to match your v4.5 configuration.
  1. Test and reload Nginx configuration:
bashCopy codesudo nginx -t
sudo systemctl reload nginx
  1. Configure PHP-FPM:
  • Edit /etc/php/8.1/fpm/pool.d/www.conf and set the user and group to www-data.
  • Restart PHP-FPM: sudo systemctl restart php8.1-fpm
  1. Run the Invoice Ninja v5 setup by visiting http://172.16.0.203/setup
  2. During the setup, make sure to use the new database and user credentials you created in step 4.
  3. Migrate your data from v4.5 to v5:
  1. Once the migration is successful, and you have verified that everything works as expected, you can switch the IP addresses between the old and the new containers:
  • Power off the old container.
  • Change the IP address of the new container to 172.16.0.18.
  • Update the DNS record for clients.servici.ch to point to the new container’s IP address.
  1. You should now have successfully updated your Invoice Ninja from v4.5 to v5 on an Ubuntu LXC container.

  228  systemctl stop nginx
  229  mysql -u root -p
  230  rm -R /usr/share/nginx/invoiceninja/
  231  unzip invoiceninja.zip -d /usr/share/nginx/invoiceninja
  232  cp /usr/share/nginx/.env /usr/share/nginx/invoiceninja/.env
  233  chown -R www-data:www-data /usr/share/nginx/invoiceninja
  234  systemctl restart nginx
  235  less /usr/share/nginx/invoiceninja/storage/logs/laravel.log