Saturday, June 06, 2009

Spell checking with FCKeditor

FCKeditor is an excellent tool for providing rich text editing experience on web. Best part is that it works almost out of the box, there is very little to configure. Spelling checking is an exception here. Though spell checking also works out of the box, but with Internet Explorer only, which is not the only browser out there. Recently I used FCKeditor in a Java web application and had to integrate the spell check functionality as well. The spellar pages + aspell + PHP combination works pretty well for this task. FCKeditor comes with perl, PHP and Cold Fusion scripts for spell checking, I used PHP. In this post I will try to outline the steps required to make spell check working in FCKeditor.

1. Install PHP
PHP installation (I did it on Fedora) is pretty simple, just download the source and execute following command sequence-

tar –xvzf php-5.2.9.tar.gz
cd php-5.2.9
./configure --prefix=/path_to_install \
         --with-apxs2=/apache_install_dir/bin/apxs \
         --disable-cli \
make install
For more details about PHP installation see PHP documentation.

2. Integrate PHP with Apache
Apache needs to be instructed to invoke PHP interpreter for all requests for PHP files ('.php' extension). First we need to include PHP module by adding following line in /apache_install_dir/conf/httpd.conf-
LoadModule php5_module modules/
In same configuration file add PHP handler-
<Directory "/apache_install_dir/htdocs">
     . . . .
     . . . .
     <FilesMatch \.php$ >
          SetHandler application/x-httpd-php
3. Install aspell and dictionaries
Aspell provides dictionaries for all major world languages. Installation of aspell and its dictionaries is fairly straightforward. After downloading aspell and dictionaries execute following command sequence for each of the downloaded archive-
tar –xvzf archive_name.tar.gz
cd archive_name
make install
4. FCKeditor Configuration
By default FCKeditor is configured to use 'ieSpell', change it to use 'SpellarPages' instead. Also make sure it uses PHP and does spell checking in FireFox. Following properties needs to be changed in 'fckconfig.js'-
FCKConfig.SpellChecker = 'SpellerPages' ;
FCKConfig.SpellerPagesServerScript = 'server-scripts/spellchecker.php' ;
FCKConfig.FirefoxSpellChecker = true ;
Now configure the language and 'aspell' path in 'spellchecker.php'-
$aspell_prog = 'aspell';
$lang = 'en_US';

Now we are ready to test the application and see spell check in action. All software versions being used for this post are outlined below-
  • Apache 2.2.11
  • PHP 5.2.9
  • FCKeditor 2.6.4 (with bundled Spellar Pages)
  • Aspell 0.60.6
  • Tomcat 6.0.18
  • Java 6 update 13
  • Fedora 9
To know more about using Apache to serve Java application see Apache in from of Tomcat and JBoss.


Unknown said...

Hi Vinod,
First of all thanks for your quick reply.
I have followed instruction given on this blog and tried to install spell checher functionality with
jboss. I have gone through following steps. I am using windows XP platform for it.
1) Installed PHP (downloded PHP zip file and unzipped in D:/PHP folder)
2)Installed apache 2.2.14 and configured it with PHP
3)now when i try to integrate apache with php i am not able to find module.
Can you please put some light on it?
It will be a great help.

Thanks & Regards,

Anonymous said...


On windows configuration in httpd.conf should look like below-

LoadModule php5_module "d:/php/php5apache2_2.dll"

May be you need to add this line as well-

PHPIniDir "d:/php"

As I have not tried this on Windows, so I could be wrong :-)