Tuesday, May 27, 2008

Install PHP pecl intl module for ubuntu 7.10 (PHP 5.2.3)

The "intl" extension (which gives you the ICU library, see http://www.icu-project.org and http://pecl.php.net/package/intl) requires PHP 5.2.4 or later.
Ubuntu 7.10 comes with 5.2.3. However the changes required are quite minor.

Note: all the following steps need to be done as root.

First make sure both php5 and php5-dev packages are installed.

Next go to /usr/lib/php5/build/ and replace the acinclude.m4 file with the one here:
http://cvs.php.net/viewvc.cgi/php-src/acinclude.m4?revision=1.387

(This is to get the [PHP_SETUP_ICU] macro, which was added in php 5.2.4)

Next, go to /usr/include/php5/main/ and open php_config.h and at the end add this line:

#define HAVE_PTRDIFF_T 1


Now you should be ready to do the install, which is as simple as:

pecl install intl


It will download a 150K file, and compile and install it.

At the end it says to add a line to php.ini. Assuming you want the intl extension in both the apache module and the cli version of php, then go to /etc/php5/conf.d/ and create a file called intl.ini and in that file put this single line:

extension=intl.so


A quick way to check it all worked is to type:

php -i | grep intl


If it didn't work you will see nothing. If it worked you'll see a line talking about "intl.default_locale".

3 comments:

Joshua Stewardson said...

This didn't do the trick for me (with PHP 5.3 so not really applicable anymore), but I did come across the answer to just run "sudo apt-get install php5-intl" and that did the trick! (See http://stackoverflow.com/questions/6727736/cant-get-to-install-intl-extension-for-php-on-debian)

darren said...

Hello Joshua,
Yes this (old!) blog post was just how to get the intl package on a php 5.2.3 (and possibly earlier).

NicoD. said...

Joshua saved my life with his comment. I had the same problem in order to install the Symfony framework on ubuntu.

Thank you, Darren for this post.