I killed my invoice ninja trying update to the latest v4 version

After I ran the update script from GitHub. I get the following error

Composer detected issues in your platform: Your Composer dependencies require a PHP version “>= 7.4.0”. You are running 7.2.34-32+ubuntu20.04.1+deb.sury.org+1.

Up updated to PHP but ended up with PHP v8.1.8. I guess it’s not backwards compatible.

Not sure what to do about this exactly.

Leave 8.1.8 installed
Make sure you backup, especially your .env file and database. Download and unpack the latest release zip file manually over the old install.
Edit your nginx config to make sure it is pointing to fpm8.1 socket.
Edit your cronjob to make sure it is using php8.1
Restart nginx or reboot the server.

Visit the app url, it should run the update.

I already ran the script to install the most current release of Version4

My bad, didn’t realize you were running v4.

Yes you would have to remove all php 8 stuff and downgrade to 7.4.

I don’t see a line in the nginx.conf file that points to fpm socket anything at all. Is this something I need to add?
If so, what is the correct syntax

No ignore that, I thought you had v5

Did you downgrade to php 7.4?

I remember having a similar issue in our migration tests with v4. Running composer comands manually was erroring out. And causing white screen.
We got around it by visiting the url after zip unpack, or www.appurl.com/update.

We did have to restore from backup when we had the white screen.

Are you getting anything in the error logs?

What script did you run? I’m only aware of one and as far as I know it is outdated…

So from my notes here for our own planned migration.

V4 manual update goes as follows:

(these are not step by step, just our own notes on certain steps that were having issues, may only apply to our environment but may help you as well.)

  • Remove vendor folder, as it causes conflicts with compose.
  • Download latest v4 with wget --no-check-certificate https://download.invoiceninja.com -O ninja.zip
  • Unzip ninja.zip overwriting the existing files.
  • Change owner of the files chown -R webuser:webuser /path/to/ninja/instance replace webuser with the user running apache/nginx
  • remove PHP 7.2 + all dependencies
  • install PHP 7.4 and required dependencies
  • reboot
  • Do not run compose/artisan etc manually. Visit app url/update isntead www.appurl.com/update wait for a few minutes untill you are redirected to login page with Successfully completed update - check to see whats new above the login. (You will have to use /update=yourUpdateSecret if your .env has an update secret variable set.)

Please check the Server and Laravel logs if you are still having issues and post here.

I ran the shell script noted in this.

@froglevelmc no link in your post :slight_smile:

  • Could you get the logs?
  • Did you try suggestions in my last post?
  • Can you restore from backup and try manual update?

I did not look at the logs yet.
I did try all the suggestions from your last post. Now I just get a “502 Bad Gateway Error”
I had not looked at by backup in quite a while. Tried… it was corrupted.

I can’t ever seem to remember where to find the logs for this.

The app logs are in storage/logs/

I pulled these errors from the logs. I can’t make sense of them though

chris@server1:/var/www/html/invoiceninja/storage/logs$ tail -f laravel-error.log | grep error
[2020-09-21 02:09:22] production.ERROR: {“context”:“JavaScript”,“user_id”:0,“account_id”:0,“user_name”:"",“method”:“GET”,“user_agent”:“Mozilla/5.0 ((Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36)”,“locale”:“en”,“ip”:“18.237.199.243”,“count”:1,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“log_error”} []
[2022-01-10 20:21:01] production.ERROR: TypeError: t is undefined {“context”:“JavaScript”,“user_id”:0,“account_id”:0,“user_name”:"",“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0”,“locale”:“en”,“ip”:“192.168.100.1”,“count”:1,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“log_error”} []

These 2 errors are from Sept 2020 and Jan 2022 :smile:

Can we see the server logs, those should be in /var/log/httpd/ or /var/log/apache2/ if you are running apache and /var/log/nginx if you are using nginx, look at the latest error log if there are multiple.

Also check that your .env file in the invoice ninja directory didn’t get overwritten (check you DB credentials etc)

Could you also tell us more about your environment, OS, Webserver, or is it hosting, was the original install from zip or git clone etc?

It still looks like it’s trying to use phpv7.2 I purged out version 7.2 already. and the new version requires version 7.4 or newer. I can’t figure out how to make it use php7.4

chris@server1:/var/log/nginx$ tail -4 error.log
2022/08/01 11:09:31 [crit] 1161#1161: *170 connect() to unix:/var/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: ###.###.###.###, server: ininja.site.com, request: “GET /.git/config HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php/php7.2-fpm.sock:”, host: “###.###.###.###”
2022/08/01 11:09:32 [crit] 1161#1161: *172 connect() to unix:/var/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: ###.###.###.###, server: ininja.site.com, request: “POST / HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php/php7.2-fpm.sock:”, host: “###.###.###.###”
2022/08/01 11:33:58 [crit] 1161#1161: *176 connect() to unix:/var/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: ###.###.###.###, server: ininja.site.com, request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php/php7.2-fpm.sock:”, host: “###.###.###.###”
2022/08/01 13:42:23 [crit] 1161#1161: *182 connect() to unix:/var/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: ###.###.###.###, server: ininja.site.com, request: “GET /login HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php/php7.2-fpm.sock:”, host: “ininja.site.com
chris@server1:/var/log/nginx$

@froglevelmc you need to edit nginx config for invoice ninja to point to php7.4-fpm.sock: instead.
It should be somewhere under /etc/nginx probably in sites-enabled subfolder. Can’t tell you exactly, without knowing your config…

P.S. you might want to edit the above logs to hide your ip and url, for security.

So I changed that to point both php8.1 and then to php7.4. Now I get “This site isn’t working right not error 500.”

This is the new log file:

2022/08/01 18:20:20 [error] 1181#1181: *2 FastCGI sent in stderr: “PHP message: PHP Warning: require(/var/www/html/invoiceninja/bootstrap/…/vendor/autoload.ph p): failed to open stream: No such file or directory in /var/www/html/invoicenin ja/bootstrap/autoload.php on line 20PHP message: PHP Fatal error: require(): Fa iled opening required ‘/var/www/html/invoiceninja/bootstrap/…/vendor/autoload.p hp’ (include_path=’.:/usr/share/php’) in /var/www/html/invoiceninja/bootstrap/au toload.php on line 20” while reading response header from upstream, client: ###. ###.###.###, server: ininja.site.com, request: “GET /update HTTP/1.1”, ups tream: “fastcgi://unix:/var/run/php/php7.4-fpm.sock:”, host: “ininja.portcitydat a.com

Ok it is complaining that it cant find a file. So either permissions are incorrect or you didn’t unzip a new install after deleting vendor folder.

Make sure you do a backup.

  • Redownload the zip again, unpack the contents into the current invoice ninja folder, overwriting files. (Do not delete the current folder, just overwrite files as it asks)

  • Change file owner recursively to the same user as the one running nginx (either nginx:nginx, www-data:www-data or similar)

  • Visit appurl.com/update and give it a few minutes.

Let us know if it helps and provide Laravel and server logs if it doesn’t.

Here are the permissions after running chown -R www-dat:www-data /var/www/html/invoiceninja

chris@server1:/var/www/html/invoiceninja$ ls -lah
total 172M
drwxrwxr-x 15 chris www-data 4.0K Jul 31 13:41 .
drwxr-xr-x 3 root root 4.0K Apr 13 06:15 …
drwxrwxr-x 20 chris www-data 4.0K Mar 20 02:46 app
-rwxrwxr-x 1 chris root 1.6K Mar 20 02:46 artisan
drwxrwxr-x 3 chris www-data 4.0K Mar 20 02:46 bootstrap
-rwxrwxr-x 1 chris root 1.3K Mar 20 02:46 bower.json
-rwxrwxr-x 1 chris root 45 Mar 20 02:46 .bowerrc
-rwxrwxr-x 1 chris www-data 14K Dec 28 2018 c3.php
-rwxrwxr-x 1 chris root 646 Mar 20 02:46 codeception.yml
-rwxrwxr-x 1 chris root 504 Mar 20 02:46 .codeclimate.yml
-rw-r–r-- 1 chris root 358 Mar 20 02:46 CODE_OF_CONDUCT.md
-rwxrwxr-x 1 chris root 7.0K Mar 20 02:46 composer.json
-rwxrwxr-x 1 chris root 626K Mar 20 02:46 composer.lock
drwxrwxr-x 3 chris www-data 4.0K Aug 1 14:03 config
-rwxrwxr-x 1 chris root 1.9K Mar 20 02:46 CONTRIBUTING.md
drwxrwxr-x 5 chris www-data 4.0K Mar 20 02:46 database
drwxrwxr-x 3 chris www-data 4.0K Mar 20 02:46 docs
-rw-r–r-- 1 chris www-data 704 Aug 28 2020 .env
-rw-r–r-- 1 chris root 704 Jul 31 11:10 .env.bak
-rwxrwxr-x 1 chris root 2.3K Mar 20 02:46 .env.example
-rwxrwxr-x 1 chris root 471 Mar 20 02:46 .env.travis
drwxrwxr-x 8 chris www-data 4.0K Dec 28 2018 .git
-rwxrwxr-x 1 chris root 199 Mar 20 02:46 .gitattributes
drwxr-xr-x 3 chris root 4.0K Mar 20 02:46 .github
-rwxrwxr-x 1 chris root 731 Mar 20 02:46 .gitignore
-rwxrwxr-x 1 chris root 1.2K Mar 20 02:46 Gruntfile.js
-rwxrwxr-x 1 chris root 6.6K Mar 20 02:46 gulpfile.js
-rwxrwxr-x 1 chris root 6.1K Mar 20 02:46 .htaccess
-rwxrwxr-x 1 chris root 3.8K Mar 20 02:46 LICENSE
drwxrwxr-x 14 chris root 4.0K Aug 1 19:08 ninja
-rw-r–r-- 1 chris root 3.3K Jul 29 10:49 ninjaupdate.sh
-rw-r–r-- 1 chris root 171M Jul 31 11:11 ninja.zip
-rwxrwxr-x 1 chris root 371 Mar 20 02:46 package.json
-rwxrwxr-x 1 chris root 3.7K Mar 20 02:46 .php_cs.dist
-rwxrwxr-x 1 chris root 87 Mar 20 02:46 phpspec.yml
-rwxrwxr-x 1 chris root 777 Mar 20 02:46 phpunit.xml
drwxrwxr-x 7 chris www-data 4.0K Mar 20 02:46 public
-rwxrwxr-x 1 chris root 5.0K Mar 20 02:46 README.md
drwxrwxr-x 5 chris www-data 4.0K Mar 20 02:46 resources
drwxrwxr-x 2 chris www-data 4.0K Mar 20 02:46 routes
-rw-r–r-- 1 chris root 149 Mar 20 02:46 SECURITY.md
-rwxrwxr-x 1 chris root 560 Mar 20 02:46 server.php
drwxrwxr-x 9 chris www-data 4.0K Mar 20 02:46 storage
-rwxrwxr-x 1 chris root 247 Mar 20 02:46 .styleci.yml
drwxrwxr-x 8 chris www-data 4.0K Mar 20 02:46 tests
-rwxrwxr-x 1 chris root 6.2K Mar 20 02:46 .travis.yml

I looked at the permissions for the file it can’t find.

chris@server1:/var/www/html/invoiceninja/bootstrap$ ls -lah
total 24K
drwxrwxr-x 3 chris www-data 4.0K Mar 20 02:46 .
drwxrwxr-x 15 chris www-data 4.0K Jul 31 13:41 …
-rwxrwxr-x 1 chris root 1.8K Mar 20 02:46 app.php
-rwxrwxr-x 1 chris root 1.3K Mar 20 02:46 autoload.php
drwxrwxr-x 2 chris www-data 4.0K Mar 20 02:46 cache
-rwxrwxr-x 1 chris root 26 Mar 20 02:46 environment.php
chris@server1:/var/www/html/invoiceninja/bootstrap$
The log also mentions the vendor folder. The vender folder was deleted per your instructions was a new one supposed to be created from the ZIP?

The laravel-error.log does not show anything new. The nginx log shows the same error.

2022/08/01 19:33:58 [error] 1154#1154: *5 FastCGI sent in stderr: “PHP message: PHP Warning: require(/var/www/html/invoiceninja/bootstrap/…/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/invoiceninja/bootstrap/autoload.php on line 20PHP message: PHP Fatal error: require(): Failed opening required ‘/var/www/html/invoiceninja/bootstrap/…/vendor/autoload.php’ (include_path=’.:/usr/share/php’) in /var/www/html/invoiceninja/bootstrap/autoload.php on line 20” while reading response header from upstream, client: IP Address, server: ininja.site.com, request: “GET /actuator/health HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php/php7.4-fpm.sock:”, host: “IP address”

Here are the permissions f

@froglevelmc
Permissions are all over the place… Can you do the following exactly as is.

  1. cd /var/www/html/invoiceninja

Make sure you are actually there otherwise next command will mess up your whole OS!!!

Then run

  1. sudo chown -R www-data:www-data *
    Note the space before *

  2. Reboot server

  3. Try the update url