What is the PHP mbstring extension, and what is the best way to install it on Ubuntu 14.04?
8 Answers
EDIT: Dylan Pierce has confirmed that you can already install some PHP 7.2 extensions in the same way you would for PHP 5. For mbstring in particular, you can execute:
sudo apt-get install php7.2-mbstringTo complement sparkmood's answer, this now works for PHP 7.2 if you already imported ondrej's PPA for it.
sudo apt-get install libapache2-mod-php7.2Don't forget, either PHP 7 is available through ubuntu's official repositories or you will need an external PPA.
8sudo apt-get install php-mbstringI have installed mbstring in php7.0-fpm (7.0.15-0ubuntu0.16.04.4)
6mbstring is built in libapache2-mod-php5 package, so you can use this command for installing :
sudo apt-get install libapache2-mod-php5As described in package details :
dba dom ereg exif fileinfo filter ftp gettext hash iconv json libxml mbstring mhash openssl pcre Phar posix Reflection session shmop SimpleXML soap sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter zip zlib. 3 If you're using php 5.6
Install php 5.6 mbstring package:
sudo apt-get install php5.6-mbstringThen add the following line to the bottom of your php.ini file:
extension=php5.6-mbstring.soRestart apache:
sudo service apache2 restartTo find your php.ini file, create a file and insert the following line:
<?php phpinfo(); ?>Then open with a browser to see where your php.ini file is located.
In my case it was already installed, but I just needed to do phpenmod mbstring, followed by apachectl graceful.
For Ubuntu 14.04 extension mbstring should be built in.
For Ubuntu 16.04:
sudo apt-get install php7.0-mbstringSee also Introduction to Multibyte String
It requires adding another source for apt for install in 18.04..
Download Page for php7.2-mbstring_7.2.7-0ubuntu0.18.04.2_amd64.deb on AMD64 machines
If you are running Ubuntu, it is strongly suggested to use a package manager like aptitude or synaptic to download and install packages, instead of doing so manually via this website.
You should be able to use any of the listed mirrors by adding a line to your /etc/apt/sources.list like this:
deb bionic-security main universe
1Since the mcrypt itself (the package that php-mcrypt uses to do its crypt stuff) is no longer supported after PHP7.2, As of today, to install it specifically for php7.2, you'll need to make sure when installing to prefix all php7.2 extensions with php7.2-.
While initially the commands suggested by others to just install it work, when using it with an framework version that requires mcrypt (such as Laravel4.2), it will require you to install mcrypt using pecl. Follow the fix here