{"id":14130,"date":"2023-04-28T09:37:33","date_gmt":"2023-04-28T09:37:33","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=14130"},"modified":"2023-09-18T15:37:49","modified_gmt":"2023-09-18T15:37:49","slug":"how-to-enable-php-mbstring-extension-on-ubuntu","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-enable-php-mbstring-extension-on-ubuntu\/","title":{"rendered":"How to enable PHP MBString Extension on Ubuntu?"},"content":{"rendered":"<p>The PHP MBString extension is used to handle multibyte strings, which is essential for supporting different character encodings in your web applications. In this guide, we will show you how to enable the PHP MBString extension on <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-ubuntu-beginners-guide-ubuntu-linux-distro\/\">Ubuntu<\/a>.<\/p>\n<p>Note: These instructions are for Ubuntu 18.04 and 20.04. Some steps may differ for other Ubuntu versions.<\/p>\n<h2>Step 1: Update the Package List<\/h2>\n<p>Open a terminal window and run the following command to update the package list:<\/p>\n<pre>\r\nsudo apt update\r\n<\/pre>\n<p>This command fetches the latest package information from the configured repositories and updates the local package list.<\/p>\n<h2>Step 2: Install the PHP MBString Extension<\/h2>\n<p>After updating the package list, install the PHP MBString extension using the following command:<\/p>\n<pre>\r\nsudo apt install -y php-mbstring\r\n<\/pre>\n<p>If you have a specific PHP version installed, such as PHP 7.4, install the corresponding MBString extension:<\/p>\n<pre>\r\nsudo apt install -y php7.4-mbstring\r\n<\/pre>\n<pre>\r\nroot@geek:~# sudo apt install -y php7.4-mbstring\r\nReading package lists... Done\r\nBuilding dependency tree       \r\nReading state information... Done\r\nThe following NEW packages will be installed:\r\n  php7.4-mbstring\r\n0 upgraded, 1 newly installed, 0 to remove and 39 not upgraded.\r\nNeed to get 396 kB of archives.\r\nAfter this operation, 1,079 kB of additional disk space will be used.\r\nGet:1 http:\/\/ppa.launchpad.net\/ondrej\/php\/ubuntu bionic\/main amd64 php7.4-mbstring amd64 1:7.4.33-5+ubuntu18.04.1+deb.sury.org+1 [396 kB]\r\nFetched 396 kB in 0s (1,193 kB\/s)       \r\nSelecting previously unselected package php7.4-mbstring.\r\n(Reading database ... 121676 files and directories currently installed.)\r\nPreparing to unpack ...\/php7.4-mbstring_1%3a7.4.33-5+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...\r\nUnpacking php7.4-mbstring (1:7.4.33-5+ubuntu18.04.1+deb.sury.org+1) ...\r\nSetting up php7.4-mbstring (1:7.4.33-5+ubuntu18.04.1+deb.sury.org+1) ...\r\n\r\nCreating config file \/etc\/php\/7.4\/mods-available\/mbstring.ini with new version\r\nProcessing triggers for libapache2-mod-php7.4 (1:7.4.33-5+ubuntu18.04.1+deb.sury.org+1) ...\r\nProcessing triggers for php7.4-cli (1:7.4.33-5+ubuntu18.04.1+deb.sury.org+1) ...\r\n<\/pre>\n<h2>Step 3: Restart the Web Server<\/h2>\n<p>After installing the PHP MBString extension, you need to restart your web server for the changes to take effect. If you&#8217;re using Apache, restart the service with the following command:<\/p>\n<pre>\r\nsudo systemctl restart apache2\r\n<\/pre>\n<p>If you&#8217;re using Nginx, restart the Nginx and PHP-FPM services:<\/p>\n<pre>\r\nsudo systemctl restart nginx\r\nsudo systemctl restart php7.4-fpm\r\n<\/pre>\n<p>Replace php7.4-fpm with the appropriate PHP-FPM version if you&#8217;re using a different PHP version.<\/p>\n<h2>Step 4: Verify the PHP MBString Extension is Enabled<\/h2>\n<p>To verify that the PHP MBString extension is enabled, create a PHP file called info.php in your web server&#8217;s document root (e.g., \/var\/www\/html\/) with the following content:<\/p>\n<pre>\r\n&lt;?php\r\nphpinfo();\r\n?&gt;\r\n<\/pre>\n<p>Now, visit http:\/\/your_server_ip\/info.php in your web browser, and you should see the PHP information page. Look for the &#8220;mbstring&#8221; section, which confirms that the MBString extension is enabled.<\/p>\n<p>After verifying the extension is enabled, don&#8217;t forget to remove the info.php file, as it can expose sensitive information about your server:<\/p>\n<pre>\r\nsudo rm \/var\/www\/html\/info.php\r\n<\/pre>\n<h2>Conclusion<\/h2>\n<p>You have now successfully enabled the PHP MBString extension on your Ubuntu system. This extension allows your web applications to handle multibyte strings and provides better support for different character encodings.<\/p>\n<p>If you have any questions, comments, or suggestions for improvement, please feel free to share your thoughts in the comments section below. Your feedback is invaluable to us, and it helps us create better and more informative content for our users.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The PHP MBString extension is used to handle multibyte strings, which is essential for supporting different character encodings in your web applications. In this guide, we will show you how&#8230;<\/p>\n","protected":false},"author":6,"featured_media":1262,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[996,1073],"tags":[1646,1856],"class_list":["post-14130","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-ubuntu","tag-php","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/14130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=14130"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/14130\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/1262"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=14130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=14130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=14130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}