@anristudio The working directory where the Invoice Ninja files are at, what are the permissions set to?
For example, if I have all my Invoice Ninja files located at /var/www/html/invoiceninja/ the permissions would need to be set there and for the sub directories under it. You can see the owner and permissions set by using the list command
ls -la /var/www/html/invoiceninja/
To set the permissions correctly first I take ownership of the directory and the sub directories under it with the CHOWN command for the www-data owner and www-data group
sudo chown -R www-data:www-data /var/www/html/invoiceninja/
Then set the permissions for the directory and sub directories using the CHMOD command
sudo chmod -R 755 /var/www/html/invoiceninja/
When completed the permissions will be set correctly and using the list command again should look like this
──╼ $ls -la /var/www/html/invoiceninja/
total 1280
drwxr-xr-x 14 www-data www-data 4096 Jul 21 15:44 .
drwxr-xr-x 3 root root 4096 Jun 2 11:05 ..
drwxr-xr-x 27 www-data www-data 4096 Aug 31 20:39 app
-rwxr-xr-x 1 www-data www-data 1686 Oct 5 17:39 artisan
-rwxr-xr-x 1 www-data www-data 63 Oct 5 17:39 .babelrc
drwxr-xr-x 3 www-data www-data 4096 May 12 05:02 bootstrap
-rwxr-xr-x 1 www-data www-data 2008 May 12 05:02 CHANGELOG.md
-rwxr-xr-x 1 www-data www-data 99 Oct 5 17:39 .codacy.yml
-rwxr-xr-x 1 www-data www-data 55 Oct 5 17:39 codecov.yml
-rwxr-xr-x 1 www-data www-data 358 Oct 5 17:39 CODE_OF_CONDUCT.md
-rwxr-xr-x 1 www-data www-data 4912 Oct 5 17:39 composer.json
-rwxr-xr-x 1 www-data www-data 4412 Jun 3 00:54 composer.json.oem.bak
-rwxr-xr-x 1 www-data www-data 582225 Oct 5 17:39 composer.lock
-rwxr-xr-x 1 www-data www-data 58460 May 21 12:23 composer-setup.php
drwxr-xr-x 2 www-data www-data 4096 Sep 10 08:31 config
drwxr-xr-x 7 www-data www-data 4096 May 12 05:02 cypress
-rwxr-xr-x 1 www-data www-data 209 Jul 6 04:10 cypress.json
drwxr-xr-x 6 www-data www-data 4096 May 12 05:02 database
Final step is to run the artisan optimize command from the Invoice Ninja working directory as the www-data user
Go to the directory
cd /var/www/html/invoiceninja/
Run the command from the directory as the www-data user
sudo -u www-data php artisan optimize