woheras
woheras

Reputation: 109

Fatal error: Call to undefined function mb_internal_encoding() in /home/blabla/blabla.php on line 2

When I run a php script over ssh like:

php /home/blabla/blabla.php

it says:

Fatal error: Call to undefined function mb_internal_encoding() in /home/blabla/blabla.php on line 2

but when I run it over browser like http://blabla.com/blabla.php it works.

I already installed mbstring using (--enable-mbstring) and it is activated in php.ini (otherwise it cannot work over browser too)

mbstring

Multibyte Support   enabled
Multibyte string engine libmbfl
HTTP input encoding translation disabled
libmbfl version 1.3.2

What is the reason for this situation ?

Why does it give that error when I want to run my php over ssh ?

Upvotes: 4

Views: 12498

Answers (2)

Thabet Marwa
Thabet Marwa

Reputation: 1

Put phpinfo(); in a .php file and run it on the server.

If 'Zend Multibyte Support' is disabled:

  1. Go to the PHP configuration 'php.ini' file
    • In Ubuntu, they will be in "/etc/php/{php version}/apache2/php.ini"
      (e.g. "/etc/php/7.0/apache2/php.ini")
  2. Set: zend.multibyte = On
  3. Restart the server.
    • In Ubuntu, run the shell command: sudo service apache2 restart

Upvotes: 0

Tim Penner
Tim Penner

Reputation: 3541

It isn't that strange that it is working through the webserver but not from the command line. The two could very well be using different config files.

You can put <? phpinfo(); ?> in a .php file and run the same php file through both the webserver and the CLI to get a better understanding. Then you could double check the config file and make sure extension is enabled.

Another alternative (yet drastic) would be rebuilding PHP and Apache.

Upvotes: 1

Related Questions