简体   繁体   中英

Error Installing Laravel: Mcrypt PHP extension required

I know there are a lot of questions about this on SO but none of them address my problem. I've checked everything they mention everything seems to indicate mcrypt is ok except when installing Laravel. Clearly I'm missing something.

When installing Laravel as directed ( composer create-project laravel/laravel myproj --prefer-dist ) I get the error "Mcrypt PHP extension required" at what seems to be near the end of installation.

As far as I can tell mcrypt is installed and enabled.

Composer uses /usr/bin/env php

$ which composer       
/usr/local/bin/composer

$ cat /usr/local/bin/composer
#!/usr/bin/env bash
/usr/bin/env php -d allow_url_fopen=On -d detect_unicode=Off /usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar $*%   

php on my PATH is 5.5.10 from MAMP

$ php --version
PHP 5.5.10 (cli) (built: Apr 10 2014 17:49:22)

$ which php
/Applications/MAMP/bin/php/php5.5.10/bin/php   

Mcrypt is installed and enabled

$ php -m | grep mcrypt
mcrypt

$ php --info | grep mcrypt                  
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

$ php --ini                                 
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.5.10/conf
Loaded Configuration File:         /Applications/MAMP/bin/php/php5.5.10/conf/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

$grep mcrypt /Applications/MAMP/bin/php/php5.5.10/conf/php.ini      
extension=mcrypt.so

I can see mcrypt support enabled in a phpinfo page via MAMP too.

What am I missing?

edit: I have export PATH="/Applications/MAMP/bin/php/php5.5.10/bin:$PATH" in .bash_profile and can confirm with echo $PATH and which php

update: a clue.

If I edit /usr/local/bin/composer to be:

#!/usr/bin/env bash
echo $PATH
/usr/bin/env php --ini

and run composer I get

/usr/bin:/bin:/usr/sbin:/sbin
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         (none)
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed:      (none)

Why is that PATH different?

Getting Laravel working on Apache

PHP version : PHP 5.5.9

Ubuntu version : 14.04

After a lot of trial and error and searching around , this is what i discovered . i had a working laravel project on windows, i copied it to ubuntu server and started getting the mcrypt error.

getting artisan command working

i did a lot of trial and error so each time i run the php5enmod command before, i had error messages. but on fresh install there was no error messages. after this step i got artisan command working

sudo rm /etc/php5/mods-available/mcrypt.ini
sudo apt-get purge php5-mcrypt
sudo apt-get install mcrypt
sudo apt-get install php5-mcrypt
sudo php5enmod mcrypt

fixing the browser error

sudo nano /etc/php5/apache2/php.ini

add the following line under the dynamically compiled extensions section of php ini

extension=mcrypt.so

restart the apache server , purge the laravel cache and everything working

From what you've posted, it looks like composer is using a different PHP installation than your MAMP version. One workaround would be using the PHAR version instead:

wget https://getcomposer.org/composer.phar
php composer.phar create-project laravel/laravel myproj --prefer-dist

If your CLI php is registering mcrypt as an installed module, this will resolve your installation issue.

The only thing I can find to make this work is to edit /usr/local/bin/composer and set the PATH in there like so:

#!/usr/bin/env bash
export PATH="/Applications/MAMP/bin/php/php5.5.10/bin:$PATH"
/usr/bin/env php -d allow_url_fopen=On -d detect_unicode=Off /usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar $*

It's hacky and I'd still like to know what's up with my env but it works!

i had also encounter similar problem, and following command worked for me.

sudo apt-get install php5-mcrypt

Hope it will works your too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM