Installing php-enchant on Ubuntu 8.4

For the upcoming version of the online spellchecker for spellchecker.lu I decided to use a combination of enchant/hunspell as the core spellchecking engine. However, the versions of libenchant and hunspell that come with the new Ubuntu 8.4 are not really up-to-date, so I compiled my own versions. As a reference for myself, this is a small howto:

Remove old versions if they are installed:

apt-get remove --purge libenchant1c2a libenchant-dev hunspell

Install necessary development libraries

apt-get install libglib2.0-dev
apt-get install php5-dev php-pear

Installing hunspell and enchant is pretty straightforward:

# Install hunspell
tar xzvf hunspell-1.2.2.tar.gz
cd hunspell-1.2.2
./configure --libdir=/usr/lib/
make install

# Install enchant:
tar xzvf enchant-1.4.1.tar.gz
cd enchant-1.4.1
./configure --with-myspell-dir=/usr/share/myspell/dicts --libdir=/usr/lib/
make install

Now php-enchant can be installed very easily using pecl:

pecl install enchant

To enable the php extension, I did this:

echo "extension=enchant.so" > /etc/php5/conf.d/enchant.ini

That’s it. A usage example can be found in the PHP manual:
http://php.net/manual/en/enchant.examples.php

2 Responses to “Installing php-enchant on Ubuntu 8.4”


  • Great advice, I hope the guys will put the latest enchant into the package library. Also, I would mention PECL as a prerequisite.

  • Thank you very much for the excellent tutorial on installing hunspell for php!

    Instead of compiling enchant and hunspell i used the respective packages from the testing distribution of Debian. This had the disadvantage that due to dependencies, additional packages from the testing distribution were installed in my stable Debian system.

    By using hunspell for spellchecking German language, i hoped to better detect correctly spelled compound words, compared with aspell (in Debian Etch). But i am very disappointed with the recognition rate and execution speed of hunspell in php. So if anybody has a hint on which is currently the best open source spell checker for german language, this would be a great. My opinion is that aspell (pspell in php) is still the best choice.

Leave a Reply