- Установка
- How to enable mbstring in PHP?
- Why mbstring is required?
- MBstring Installation
- Installation on Linux Server
- Installation on Windows Server
- MBstring Configuration
- PHP solve mbstring extension missing
- Install mbstring for Linux
- Install mbstring for Windows
- Install mbstring for macOS
- Take your skills to the next level ⚡️
- About
- Search
- Tags
- Quick ways to enable mbstring in php.ini
- How does mbstring error look?
- How we enable mbstring in php.ini?
- 1. mbstring in Linux
- 2. In Windows
- 3. Enabling mbstring in cPanel
- Conclusion
- PREVENT YOUR SERVER FROM CRASHING!
Установка
mbstring не входит в список расширений, устанавливаемых по умолчанию. Это значит, что изначально это расширение отключено. Для использования функций этого расширения необходимо явно включить модуль в настройке configure. За дополнительной информацией обращайтесь в раздел Инсталляция.
Следующие настройки относятся к модулю mbstring.
- —enable-mbstring : Включение mbstring функций. Эта настройка необходима для использования mbstring функций. libmbfl необходима для работы mbstring. libmbfl поставляется вместе с mbstring. Если libmbfl уже установлена в системе, то, чтобы использовать именно ее, можно задать настройку —with-libmbfl[=DIR] . В версии PHP 4.3.0 расширение mbstring предоставляет расширенную поддержку кодировок Упрощенного Китайского, Традиционного Китайского, Корейского и Русского языков в дополнение к кодировке Японского языка. Для версий PHP 4.3.3 и ниже, чтобы добавить эту поддержку, необходимо задать одно или несколько значений параметра LANG в настройке —enable-mbstring=LANG ; следующим образом: —enable-mbstring=cn для поддержки Упрощенного Китайского, —enable-mbstring=tw для поддержки Традиционного Китайского, —enable-mbstring=kr для поддержки Корейского, —enable-mbstring=ru для поддержки Русского, и —enable-mbstring=ja для поддержки Японского (по умолчанию). Для включения всех поддерживаемых кодировок используйте настройку —enable-mbstring=all .
Замечание: C версии PHP 4.3.4, все поддерживаемые библиотекой libmbfl кодировки включаются настройкой —enable-mbstring .
Замечание: В версии PHP 4.3.0 настройка —enable-mbstr-enc-trans была исключена и заменена на установку времени выполнения mbstring.encoding_translation. Преобразование кодировок входных символов HTTP включено, когда этой установке задано значение On (значение по умолчанию Off).
How to enable mbstring in PHP?
It is required to have PHP enabled with mbstring (multi-byte string) support for storing and displaying multi-byte characters in PHPKB software. The installation wizard of the multi-language editions of PHPKB knowledge base software will automatically detect if you have PHP enabled with mbstring support. If it is not enabled, you may get an error that says:
Please refer to the tutorial below on how to enable mbstring on your server.
Why mbstring is required?
When we manipulate (trim, split, splice, etc.) strings encoded in a multi-byte encoding, we need to use special functions since two or more consecutive bytes may represent a single character in such encoding schemes. Otherwise, if we apply a non-multibyte-aware string function to the string, it probably fails to detect the beginning or end of the multibyte character and ends up with a corrupted garbage string that most likely loses its original meaning.
So, mbstring provides multibyte-specific string functions that help us deal with multibyte encodings in PHP. In addition to that, mbstring handles character encoding conversion between the possible encoding pairs. mbstring is designed to handle Unicode-based encodings such as UTF-8 and UCS-2 and many single-byte encodings for convenience.
MBstring Installation
Please note that «mbstring» is a non-default PHP extension. This means it is not enabled by default.
Installation on Linux Server
You can find out if this module is installed or not by looking at the list that is produced by this command
If you don’t have this installed on a Linux machine and if you have installed PHP from yum then run this command as a superuser. The command depends on your operating system.
sudo yum install php-mbstring
This command is true for all Red Hat Linux-based distributions using RPM and the ’yum’ package manager; this includes RHEL, Fedora, CentOS, Mandriva, and Intrinsic Linux, among others.
For Debian, Ubuntu distributions, please use the following command.
sudo apt-get install php-mbstring
After that, you will need to restart your Apache service using the following command:
Installation on Windows Server
If you have access to the php.ini, just remove the semicolon character (;) in front of the line below.
Once you have made the changes, don’t forget to restart your web server for the change to take effect.
Note: PHP extensions are not just enabled from php.ini file. First, you need to install that specific extension, i.e. place its DLL file «php-mbstring.dll» into the «/php/ext/» directory if it is not already present there. When you do that, make sure you have the correct build of DLL file. 32-bit, thread-safe PHP binary, built using VC9 for example, would only work with DLL files built using exact same tools and configuration: 32-bit, using VC9, with thread-safety turned on. And of course PHP API version also needs to match. If it doesn’t, once you restart the web server, you will receive ’Error 500 — Server error’ message.
MBstring Configuration
Below is a sample excerpt from php.ini file which contains the configuration of mbstring variables.
[mbstring]
mbstring.language = all
mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.http_output = UTF-8
mbstring.encoding_translation = On
mbstring.detect_order = UTF-8
mbstring.substitute_character = none;
mbstring.func_overload = 0
mbstring.strict_encoding = Off
- Applicable To: Standard (Multi-Language) Edition, Enterprise Multi-Language Edition (MySQL), Enterprise Multi-Language Edition (SQL Server)
35 people found this article helpful what about you?
PHP solve mbstring extension missing
Posted on Aug 08, 2022
When running phpMyAdmin, you may see an error that says the mbstring extension is missing as follows:
This error prevents you from opening phpMyAdmin and accessing your database.
To solve this error, you need to have mbstring installed and activated in your PHP configuration.
Depending on your Operating System, there are different ways to install and enable the mbstring extension:
Install mbstring for Linux
For Linux systems, you can install mbstring using apt-get or yum depending on your Linux distribution.
Here’s the command to install mbstring for Debian / Ubuntu or Red Hat Linux:
The package manager should install the right mbstring version based on your PHP version.
If not, you need to specify the version as follows:
Once the extenson is installed, you need to restart your PHP server.
For Apache, run the following command:
Now you can check if the mbstring extension is enabled by running phpinfo() function to see the mbstring enabled:
You can also run the php -m | grep mbstring command to see the extension from the command line:
Now that the mbstring extension is available, you should be able to access phpMyAdmin.
Install mbstring for Windows
For Windows system, you need to enable the mbstring extension from the php.ini file.
Look for the line extension=php_mbstring.dll in your php.ini file as follows:
You need to remove the semicolon before the extension config to enable php_mbstring.dll for Windows.
Once you enable the extension, restart your PHP server. The mbstring extension should now be available on your Windows computer.
If that doesn’t work, search your php.ini file for the extension_dir config.
You should see where PHP look for the extensions as shown below:
You need to see if the php_mbstring.dll exists inside the D:\XAMPP\php\ext path. Copy the extension directory value and paste it to your explorer windows.
If the .dll file is not present, you need to download the PHP Windows build from windows.php.net as shown below:
Extract the downloaded zip file, then look for the php_mbstring.dll file from the ext/ folder. Copy the file to your extension_dir path.
I don’t recommend downloading dll files from the Internet because you may get a virus on your computer.
Restart your PHP server, and now the mbstring extension should be available.
And that’s how you enable mbstring on Windows computers.
Install mbstring for macOS
For macOS, the PHP formula from Homebrew already enabled the mbstring extension during the installation process.
You should have mbstring enabled by default when you install PHP using Homebrew.
But if you install PHP using MacPorts, then you may need to install mbstring separately.
The following command should work when you’re using MacPorts:
You can see the available mbstring version from macports.org.
Now you’ve learned how to enable the PHP mbstring extension on macOS. Good work! 👍
Take your skills to the next level ⚡️
I’m sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I’ll send new stuff straight into your inbox!
About
Hello! This website is dedicated to help you learn tech and data science skills with its step-by-step, beginner-friendly tutorials.
Learn statistics, JavaScript and other programming languages using clear examples written for people.
Search
Type the keyword below and hit enter
Tags
Click to see all tutorials tagged with:
Quick ways to enable mbstring in php.ini
Usually, mbstring extension in web servers helps to manage the non-ASCII codes easily.
At Bobcares, we often get requests to enable mbstring extension, as a part of our Server Management Services.
Today, let’s see how our Support Engineers enable the mbstring extension for our customers.
How does mbstring error look?
Let’s begin by checking more details on mbstring and how the error appears on any website.
By default, mbstring makes multibyte encoding possible in PHP. This PHP extension helps in managing non-ASCII string. A typical example would be a website that handles musical quotes. It helps to manipulate strings encoded in a multi-byte encoding.
In many situations, customers get an error message related to missing PHP extensions. This particularly happens after enabling PHP function for wrong version of PHP. Or when the website uses an alternate PHP version.
For instance, while trying to enter phpMyAdmin and the mbstring module is missing on the server, it results in an error:
How we enable mbstring in php.ini?
Usually, adding the extension in the php.ini file enables mbstring. But, this procedure varies with different platforms.
With the expertise in Server Management, our Dedicated Engineers enable the mbsting module for our customers.
Let’s see the multiple ways that we use to enable mbstring on various platforms.
1. mbstring in Linux
Linux servers provide an easy way to enable PHP extensions.
Firstly, our Support Team check for the mbstring module using the command,
If there is no such module, then we install it using the command,
yum install php7x-mbstring
Afterward, we make sure the presence of necessary extension in the PHP include file. A sample entry looks like:
[root@xxx ~]# cat /etc/php.d/mbstring.ini ; Enable mbstring extension module extension=mbstring.so
Later we ensure to restart the webserver to save the changes. This enables PHP mbstring on the server. Finally, we verify the same by adding a web page that dispaly the results of the phpinfo() function.
2. In Windows
In the Windows server, the addition of the .dll files holds multiple codes and procedures. So, the Support Team first makes sure that the .dll file is present in the server.
Usually, php.ini is the file that contains all the PHP parameters. Thus, we access the php.ini file.
We check for the entry regarding the mbstring extension in the configuration file. We uncomment the line,
Later, we save the changes and restart the webserver.
3. Enabling mbstring in cPanel
In servers having a cPanel, it is easier to enable mbstring. So, for cPanel customers we enable mbstring as follows:
- Firstly, we login to the cPanel account.
- Next, we go to the Software section.
- Here, we click the drop-down to Select the PHP version.
- Now, select the PHP extension mbstring.
- Finally, click the save button.
[Having difficulty in enabling PHP mbstring? – We will do it for you.]
Conclusion
In short, to manage non-ASCII strings, we enable mbstring in php.ini. Today, we saw how to enable mbstring on different server platforms. We also saw how our Support Engineers fix the mbstring error in phpMyAdmin.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.