[SOLVED] Updated to latest ee - server error 500 - php json(decode) problem

Hi there! just updated my ee and now I am getting server error 500 on my ticketsystem…

let me check error.log. one sec

error log for this vhost says:

2016/04/19 15:56:38 [error] 6796#6796: *19 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Call to undefined function json_decode() in /var/www/mydomain.de/htdocs/application/libraries/Applib.php on line 1201
PHP message: PHP Stack trace:
PHP message: PHP   1. {main}() /var/www/mydomain.de/htdocs/index.php:0
PHP message: PHP   2. require_once() /var/www/mydomain.de/htdocs/index.php:210
PHP message: PHP   3. call_user_func_array:{/var/www/mydomain.de/htdocs/system/core/CodeIgniter.php:359}() /var/www/mydomain.de/htdocs/system/core/CodeIgniter.php:359
PHP message: PHP   4. Welcome->index() /var/www/mydomain/htdocs/system/core/CodeIgniter.php:359
PHP message: PHP   5. AppLib->get_xrates() /var/www/mydomain.de/htdocs/application/modules/welcome/controllers/welcome.php:46" while reading response header from upstream, client: 77.20.51.5, server: mydomain.de, request: "GET / HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "mydomain.de"
```

Seems there is something missing agina in the php compilation that ee installed during update... *sigh

Does your “php-fpm” listen on Port 9000? Check this with the command

netstat -tlpn

That should show something like this:

root@master:~# netstat -tlpn
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      20919/php-fpm.conf)
tcp        0      0 127.0.0.1:9001          0.0.0.0:*               LISTEN      20919/php-fpm.conf)
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      -

What does

ee stack status

say? Should be something like that:

Nginx is not installed
PHP7.0-FPM is not installed
MySQL is not installed
Postfix is not installed
HHVM is not installed
php5.6-fpm:  Running

Kind regards, -Ingo

Sorry I was to fast… overlooked the php-error:

Call to undefined function json_decode()

Try to install

apt-get install php5.6-json

or if you need other version:

apt search php | grep json

php-json/trusty,now 1:7.0+36+deb.sury.org~trusty+1 all [installed,automatic]
php-services-json/trusty 1.0.3-1 all
  PHP implementaion of json_encode/decode
php5-json/trusty 1.3.2-2build1 amd64
php5.6-json/trusty,now 1.3.9-2+deb.sury.org~trusty+1 amd64 [installed,automatic]
php7.0-json/trusty,now 7.0.5-3+donate.sury.org~trusty+1 amd64 [installed,automatic]

Hi thanks for your reply!

This is the output of netstat -tlpn for php-fpm

tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      7007/php-fpm.conf)
tcp        0      0 127.0.0.1:10024         0.0.0.0:*               LISTEN      15017/amavisd-new (
tcp        0      0 127.0.0.1:9001          0.0.0.0:*               LISTEN      7007/php-fpm.conf)

not so sure about these brackets that appear at line end though.

ee stack status says this:

PHP7.0-FPM is not installed
HHVM is not installed
nginx     :  Running
php5.6-fpm:  Running
mysql     :  Running
postfix   :  Running

I am not using php7 or hhvm.

All other vhosts are running without any problems. It is just this one site that went down after ee upgrade.

Hi ingobaab,

yes that is what I did try out to solve this error in the first place.

However the output is that this is already intalled in latest version. I will check the grep though, maybe it is just not php5.6-json which needs to be installed to get this to work here.

this is the grep output:

php-json/trusty 1:7.0+36+deb.sury.org~trusty+1 all [upgradable from: 1:7.0+5.6+32+deb.sury.org~trusty+1]
php-services-json/trusty 1.0.3-1 all
  PHP-Implementierung von json_encode/decode
php5-json/now 1.3.7-1+deb.sury.org~trusty+1 amd64 [installed,local]
php5.6-json/trusty,now 1.3.9-2+deb.sury.org~trusty+1 amd64 [installed]
php7.0-json/trusty 7.0.5-3+donate.sury.org~trusty+1 amd64 [upgradable from: 7.0.3-9+deb.sury.org~trusty+2]

Anyone help pls?

The site that is down after update is my ticket- and projectmanagement system :head_bandage:

Really I need some help from ee devs… which setting has been changed during update, that made the site go down? It worked just fine before updating.

@harshadyeola @Prabuddha

Hi Saskia,

We had similar problems with one of our servers. In the end we had to purge everything related to the stack with ee AND apt purge commands and start over with the stack. So first ee purge then apt purge anything related to the stack, nginx, php-fpm, php, etc

It seems like something got confused a few updates back and the custom configs were ignored and php7 links / settings started stepping over 5.6 – the only way we could solve it was purge everything. It just kept running down the rabbit hole, we’d fix one thing and find another.

That server seems stable now and updates via ee and apt don’t step on each other anymore.

Note, in this case php7 installed when we didn’t want it, and we removed it. I think I saw a thread a while back where you may have had something similar?

Thanks for your reply, David!

Weird issue is, that this only affects one vhost site. All other sites are up and running and everything is fine. There are no errors in error log whatsoever for any other site.

I had an issue with the php cimpilation that has been installed when upgrading to ee 3.something a while back, but I could solve it by adding the missing modules via apt-get.

So I am a bit doubtful that this needs a purge in total. What exactl yhappens when purging the ee stack? Will my vhosts be deleted?? Or does this only affect the nginx webserver config files?

How did you exactly go about, when doing the purge?

Hey,

Honestly don’t recall, it was on a live production server in crisis mode, so we were going through a lot at the time. The funny thing is our testing on the dev mirror didn’t have the issue, so we were a little blind.

What you could try is ee purge php7 and ee purge php5.6 (or whatever possible versions you have). Then apt purge them as well just to be sure

Then ee stack install php

You may be running into it just on that one site because it is the only one using json_decode, although that’s pretty common function.

Interestingly on the site / server that had issues, multibye and jason_encode are used on a heavily custom page. It think it was your thread that helped us solve the multibye / json issue at first, the one where you where installing sub components via apt-get. But in the end we decided to flush everything to get the server to a known and stable state so we didn’t keep finding missing packages.

Hi again David,

thanks once more for your help.

Ok, I thought… let’s just give it a try. I purged php via ee stack command and tried the apt-get purge as well however apt-get could’nt find any php anymore after I already purged the packages via ee.

Then reinstalled the php stack via ee. restarted nginx, memcached and php. Howver still my ticketsystem vhost didn’t load due to same error: json(decode) in error log. I remembered that I had a few issues with missing dependencies - you also mentioned that other thread. So I checked my phpmyadmin: and couldn’t access it anymore. json extension missing.

This error wasn’t present before I purged the php stack.

But it helped me solve this issue: I check the php.ini in php/php5.6 directory. Added extension=json.so at the very end of file, reloaded php et voilá: phpmyadmin as well as my ticket system went back to normal and started working again.

So in the first place, there was just a missing line in php.ini whilst the extension itself was installed all the time.

So this thread can be marked as solved!