Home > development > Install MCrypt for PHP on Windows

Install MCrypt for PHP on Windows

November 18th, 2010

There are many sites around explaining how to install MCrypt for windows but none seem very straight forward.
I have PHP installed on a windows development machine and I need MCrypt installed.

The default installation might not have mcrypt or you might have missed it shomehow…

If that happens all you need to do it

  1. Go to the php download website and download the windows binary package, (not the installer).
  2. Unzip the file in a folder, (it should create a folder called something like php-5.x.yy-Win32, depending on the version number of php you got.
  3. In that folder there should be a file called “libmcrypt.dll”, copy the file to your php extension folder, (see below if you don’t know where that is).
  4. In that folder there should also be another folder called “ext”, open it and copy the file “php_mcrypt.dll” to your php extension folder.
  5. edit your php.ini file, (see below if you don’t know where that is), and add the line:

    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;

    extension=php_mcrypt.dll

    Look for other “
    extension=…” to find where to add this line.
  6. Restart your web server, with Apache for example click on the icon on the task bar and select ‘restart’.

Where are my php extensions?

Normally they are located in your program files directory, something like “C:\Program Files\PHP\“, if you are using a non english version of Windows then the name might be different.

If it is not there then create a phpinfo.php test file and look for the path in the various variables, (look for the variables extension_dir as well as PHPRC).

Where is my php.ini file?

Same as above, normally they are located in your program files directory, something like “C:\Program Files\PHP\“, if you are using a non english version of Windows then the name might be different.

If it is not there then create a phpinfo.php test file and look for the path in the various variables, (look for the value “Loaded Configuration File).

What should my phpinfo.php file look like?

Open a blank file with your favourite text editor and type.

<?php
phpinfo();
?>

Save the file as phpinfo.php in your web folder and it should show you all the information you need about your php installation.

Categories: development Tags: , , , , ,
  1. admin
    January 7th, 2011 at 17:33 | #1

    Just a few small extra points
    – When you install Apache, select ‘Localhost’ as the server.
    – Leave the default values, the Apache server might not start after the install, but move on to step 2 anyway.
    – When you view the site and you don’t get the expected result pre ‘Shift+F5’ or restart your browser, otherwise the result might be cached.

  2. May 27th, 2012 at 22:15 | #2

    Should place “libmcrypt.dll” to php installation folder~!

  3. September 15th, 2012 at 15:37 | #3

    I looked in php.ini there was no extension=php_mcrypt.dll so I Followed your clear instructions (thank you) but in the latest version 5.3.16 ther was nothing in the ext folder, so I used the phpinfo.php and to my supprise it was installed, So the extension is already built in to windows releases.
    So Guys double check create an text file with this statement, save as phpinfo.php (see below) save to your localhost root, navigate to it using your browser and see which extensions are installed.

Comments are closed.