Installing Cracklib/Crack Extension on Apache for use with PHP

If you are writing a PHP application and need to check the strength of a password, the excellent Crack extension provides the perfect solution. It checks passwords to ensure that they contain enough unique characters, are not too simplistic, and (most usefully) whether or not they are based on a dictionary word (either forwards or backwards).

Cracklib is not installed by default on Linux, and so the Crack extension is not available via PHP. Despite how useful this tool is, there are few resources which explain how to install Cracklib and the Crack extension - as such, you may have trouble getting it to work. 

Follow the simple instructions below and you will have Cracklib working on your Linux server in no time, with the Crack extension working in PHP.

Installing the Cracklib Library

Before you can use Cracklib with PHP, you will need to ensure that the library is installed on your server.

  1. Log in to your server and switch to root access.
  2. Run the command yum install cracklib.i386
  3. Run yum install cracklib-dicts.i386

Downloading and Building the Crack Extension for PHP

Once the Cracklib library is installed, you need to download and build the PHP extension.

  1. Log in to your server and switch to root access.
  2. Ensure that you have php-pear installed on your server by running yum install php-pear
  3. Run the command pecl install crack
  4. Switch to the directory to which crack was downloaded, e.g.
    cd /tmp/pear/download/crack-0.4
  5. Run phpize
  6. Run the following command:
    ./configure; make; make install

Configuring the Crack Extension for use with PHP

Finally, you will need to ensure that PHP can use the extension.

  1. Log in to your server and switch to root access.
  2. Edit the PHP ini file using your favourite text editor, e.g. vim /etc/php.ini
  3. Scroll down to the section of the ini file called "Dynamic Extensions"
  4. On a new line, add the text extension=crack.so
  5. Restart Apache, e.g. service httpd restart

Once you have followed the three sets of instructions, you will be able to use Crack with PHP, as per the documentation that can be found here.

latest news

 

powered by eazyCMS | eazyCMS & eazySiteBuilder are the property of Eazyweb Internet Services | copyright 1996-2013
Terms & Conditions | Contact us | Print this page to PDF | SiteMap | Build a website online now with eazySiteBuilder.com