7

I looked at other SO answers here and here about this error: FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function utf8_decode

Both answers say that installing php-xml will fix the error. But that didn't work. I ran sudo apt install php-xml which installed both php-xml and php7.0-xml and I restarted php-fpm and nginx. But I still get the same error.

Also checked function_exists('utf8_decode') and it returns false. So the error is obviously thrown when utf8_decode is called.

The server is Ubuntu 16.04 and PHP 7.0. Here's the phpinfo output (PDF): https://drive.google.com/file/d/0B3GpdAvwm4fOaWMwb0JkTFQyb0U/view?usp=sharing

tinkerr
  • 975
  • 2
  • 14
  • 32
  • 2
    Remember to restart apache2 after the install. I would recommend to restart the server, because i had to do it for the same issue. – LordNeo Oct 02 '17 at 18:57

3 Answers3

9

OK so I figured it out. This was related to missing files in /etc/php/7.0/mods-available/

Normally there should be an xml.ini file there but that file was missing because of how I had installed, uninstalled and re-installed PHP. That operation was not done cleanly. After installing PHP from the PPA I had uninstalled it, deleted many files from /etc/php/ (which is not recommended. Use apt-get purge instead).

So long story short, this worked:

sudo apt-get purge php-xml php7.0-xml

sudo apt-get install php-xml

tinkerr
  • 975
  • 2
  • 14
  • 32
8

Run php -v to check the version of PHP.

If you're running version is 5.6, the solution is as follows:

sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml

Otherwise, run the following:

sudo apt-get install php7.2-mbstring php7.2-mcrypt php7.2-mysql php7.2-xml
Dov Benyomin Sohacheski
  • 7,133
  • 7
  • 38
  • 64
0

looking for the modules that I have installed in php

php -m | grep -i xml

after I run this command

yum --enablerepo remi install php-xml

and restart apache

sudo service httpd restart