How to Upgrade ICU in Intl in PHP 7.0.x for Linux Ubuntu 16.04

In my last post I discussed the problem of transliteration, and how it can be implemented using PHP’s Intl extension, which is a wrapper for ICU library. Each release of the library supports more scripts, language pairs and transliteration standards, that’s why it’s so vital to use the latest version.

To find out the current ICU’s latest release, visit their official website. As of February 2018, it’s 60.2.

Now let’s check the version of ICU our PHP 7 currently uses. Run:

php -i

Scroll down to the list of installed PHP modules and find intl:

Internationalization support => enabled
version => 1.1.0
ICU version => 55.1
ICU Data version => 55.1

Now it’s time to cry your eyes out! 55.1 was released on 2015-04-01. Since then 5 new versions have been released. 55.1 has 286 possible language parameters, while 60.2 has 639 – it increased by more than twice! Let’s upgrade!

To be honest, it wasn’t an easy task whatsoever. You can spend your whole life trying to find out how to manually upgrade ICU in Intl for Linux. But I’m going to reveal the secret right away.

Basically all the magic came from a post in Sergey Stoyanov’s blog, where he describes the upgrading process to ICU v. 56.1 for PHP 5 in Ubuntu 14.04. If you want to upgrade to 60.2, and you have PHP 7 installed on Ubuntu 16.04, the process will differ drastically, but nevertheless Sergey’s solution was used as a basis. The comments to the post were highly useful and helped me as well.

So here are all the steps:

  1. Check the list of installed PHP modules, find intl, and find out its version (I bet it’s php7.0-intl):
    sudo dpkg --get-selections | grep -v deinstall | grep php
  2. Remove intl (e.g. it’s php7.0-intl):
    sudo apt-get remove php7.0-intl
  3. Install phpize:
    sudo apt install php7.0-dev
  4. If you don’t have git, install it:
    sudo apt install git
  5. Download (it’s my fork of Anton Minin’s shell script):
    git -C /tmp clone icu-install
  6. Add execute permissions to the file:
    sudo chmod +x /tmp/icu-install/
  7. Run the file and check all available ICU releases:
    sudo /tmp/icu-install/ versions
  8. Run the file and launch installation of ICU’s latest release:
    sudo /tmp/icu-install/ install 60.2
  9. Once successfully completed, add 20-intl.ini:
    sudo touch /etc/php/7.0/cli/conf.d/20-intl.ini && sudo bash -c 'echo "" > /etc/php/7.0/cli/conf.d/20-intl.ini' && sudo touch /etc/php/7.0/apache2/conf.d/20-intl.ini && sudo bash -c 'echo "" > /etc/php/7.0/apache2/conf.d/20-intl.ini'
  10. Restart Apache:
    /etc/init.d/apache2 restart
  11. Remove phpize:
    sudo apt-get purge --auto-remove php7.0-dev
  12. Remove icu-install:
    rm -rf /tmp/icu-install

Now you can check the current ICU version by running:

php -i

I bet now it’s 60.2!

Check the list of parameters you have now available:

$list = transliterator_list_ids(); // get the list
natcasesort ($list); // sort in an alphabetical order
foreach ($list as $v) // iterate
 echo $v . "\n"; // print



3 thoughts on “How to Upgrade ICU in Intl in PHP 7.0.x for Linux Ubuntu 16.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s