The PHP mcrypt extension is not installed properly

Detail

Errors can include the following:

exception 'Exception' with message 'PHP Warning:   <span term-uuid="bf703ab1-ca4b-48f9-b2b7-16a81fd46e02" class="glossary-term" data-toggle="popover">PHP</span>
 Startup: Unable to load dynamic   <span term-uuid="08968dbb-2eeb-45c7-ae95-ffca228a7575" class="glossary-term" data-toggle="popover">library</span>
 '/usr/lib/php5/20121212/mcrypt.so' - /usr/lib/php5/20121212/mcrypt.so: cannot open shared object file: No such file or directory
Installing data fixtures:
/usr/bin/php -f '/Users/username/www/magento/dev/shell/run_data_fixtures.php' -- --bootstrap='MAGE_DIRS[base][path]=/Users/username/www/magento' 2>&1
[ERROR]   <span term-uuid="53da11f1-d0b8-4a7e-b078-1e099462b409" class="glossary-term" data-toggle="popover">exception</span>
 'Exception' with message '
Fatal error: Uncaught exception 'Exception' with message 'Module 'Magento_Core' depends on 'mcrypt' PHP   <span term-uuid="55774db9-bf9d-40f3-83db-b10cc5ae3b68" class="glossary-term" data-toggle="popover">extension</span>
 that is not loaded.'
======================================================================
   The application has thrown an exception!
======================================================================
 Magento\Framework\Exception
 Command returned non-zero exit code:
`/usr/bin/php5 -f '/var/www/magento2/dev/shell/run_data_fixtures.php' -- --bootstrap='MAGE_DIRS[base][path]=/var/www/magento2' 2>&1`

Description

Particularly on developer systems that include a Linux/Apache/MySQL/PHP (LAMP) “stack” that is separate from the operating system, it’s possible that mcrypt is either not installed at all or it’s installed in the LAMP stack’s path but not the operating system’s path.

As a result, the Magento installer cannot locate the extension and the installation fails.

Suggestion

Determine if the mcrypt extension is loaded in any of the following ways:

  • Set up a phpinfo.php file in the web server’s root directory and examine the output in a web browser.
  • Run the following command:
  php -r "phpinfo();" | grep mcrypt
If mycrypt is *not* installed, messages similar to the following display:
  PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/mcrypt.so' - /usr/lib/php5/20121212/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0

In some cases, you might need to install the Magento software from the command line and specify the full path to the LAMP stack that has mcrypt installed.