错误安装Laravel:需要Mcrypt PHP扩展 [英] Error Installing Laravel: Mcrypt PHP extension required

查看:337
本文介绍了错误安装Laravel:需要Mcrypt PHP扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在SO上对此有很多疑问,但是没有一个能解决我的问题.我检查了他们提到的所有内容,除了安装Laravel以外,其他所有内容似乎都表明mcrypt正常.显然我缺少了一些东西.

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.

按照指示(composer create-project laravel/laravel myproj --prefer-dist)安装Laravel时,似乎在安装快要结束时收到错误消息需要Mcrypt PHP扩展".

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.

据我所知mcrypt 已安装并启用.

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

Composer使用/usr/bin/env php

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 $*%   

我的PATH中的

php是MAMP的5.5.10

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

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

我也可以通过MAMP在phpinfo页面中看到mcrypt support enabled.

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

我想念什么?

:我在.bash_profile中有export PATH="/Applications/MAMP/bin/php/php5.5.10/bin:$PATH",可以用echo $PATHwhich php

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

更新:一条线索.

如果我将/usr/local/bin/composer编辑为:

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

并运行composer我得到

/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)

为什么PATH不同?

推荐答案

让Laravel在Apache上运行

PHP版本:PHP 5.5.9

PHP version : PHP 5.5.9

Ubuntu版本:14.04

Ubuntu version : 14.04

经过反复试验和四处寻找,这是我发现的.我在Windows上有一个正常的laravel项目,我将其复制到ubuntu服务器并开始收到mcrypt错误.

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.

使工匠命令正常工作

我做了很多试验和错误,所以每次我以前运行php5enmod命令时,我都会收到错误消息.但是在全新安装中,没有错误消息.完成此步骤后,我使工匠命令生效

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

修复浏览器错误

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

在php ini的动态编译扩展部分下添加以下行

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

extension=mcrypt.so

重新启动apache服务器,清除laravel缓存,一切正常

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

这篇关于错误安装Laravel:需要Mcrypt PHP扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆