UPDATE: Some of the information posted here may be useful to persons with similar problems, and arkascha's comment gave some insight. But I threw up my hands and just nuked and repaved my system. By being careful not to install any wrong versions of php, you can avoid this kind of trap in the first place. Original question follows:
(Note: this is not a duplicate of this, though it seems similar.)
When I run a certain command line php script, I get "Call to undefined function...mb_strtolower()"
I've installed php5-mbstring, and set
zend.multibyte = On
in the appropriate php.ini, and bounced the web server.
Looking at the output from phpinfo() in the browser, I see:
PHP Version 5.5.9-1ubuntu4.16
...
Zend Multibyte Support provided by mbstring
So, all's well and good with apache. Note the version is 5.5.9-1. Now, looking for the php executable in the shell:
$ which php
/usr/bin/php
$ ls -l `which php`
/usr/bin/php -> /etc/alternatives/php
$ ls -l /etc/alternatives/php
/etc/alternatives/php -> /usr/bin/php5.6
$ ls -l /usr/bin/php*
/usr/bin/php -> /etc/alternatives/php
/usr/bin/php5.6
Okay, so obviously 5.6 != 5.5.9-1, and 5.5.9-1 isn't present in /usr/bin. The question is, how do I get my command line php to use the same php executable and modules as apache?
There's a hint here, which says to relink some stuff under /etc/php/:
rm -rf /etc/php/7.0/cli
ln -s /etc/php/7.0/fpm /etc/php/7.0/cli
Here's what /etc/php looks like on my system:
$ ls /etc/php
5.6 7.0
What I don't see is 5.5.9-1. Where the heck is that, and how do I configure my command line to use it?
Thanks to arkascha, this update:
I'm running Magento 2, which is compatible with php7. So I decided to configure both CLI and apache2 to use php7. Maybe that relink hint above will work if apache uses php7. Per Magento 2 install instructions, I did the following four commands:
sudo apt-get -y update
sudo add-apt-repository ppa:ondrej/php
sudo apt-get -y update
sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-bcmath php7.0-iconv
Apache doesn't automagically update itself to the latest php version; phpinfo() still shows php5.5.9-1. So I look to configure that and find /etc/apache2/mods-enabled/php5.load which looks like this:
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
And I check:
$ ls /usr/lib/apache2/modules/libphp*
/usr/lib/apache2/modules/libphp5.so /usr/lib/apache2/modules/libphp7.0.so
Now I'm stuck again. It seems I could just update /etc/apache2/mods-enabled/php5.load, but the file name itself is called "php5*". Should I just delete php5* and replace with php7* with similar content? Is there a utility to update this configuration without making a mistake?