在Ubuntu 14.04上安装Laravel时出现了ext-mcrypt错误。

12

我是在Ubuntu 14.04中学习Laravel的初学者。 我尝试运行以下命令来安装Laravel。

composer create-project laravel/laravel --prefer-dist

我遇到了以下错误。 我也尝试安装ncrypt但是遇到了相同的错误。

Installing laravel/laravel (v5.0.1)
      - Installing laravel/laravel (v5.0.1)
        Loading from cache

    Created project in /opt/lampp/htdocs/laravel
    Loading composer repositories with package information
    Installing dependencies (including require-dev)
    Your requirements could not be resolved to an installable set of packages.

      Problem 1
        - laravel/framework v5.0.2 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
        - laravel/framework v5.0.1 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
        - laravel/framework v5.0.0 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
        - Installation request for laravel/framework 5.0.* -> satisfiable by laravel/framework[v5.0.0, v5.0.1, v5.0.2].

我也尝试运行这个命令,但是遇到了同样的错误。

sudo apt-get install mcrypt php5-mcrypt
sudo php5enmod mcrypt
sudo service apache2 restart

提前感谢您的帮助。


你使用的是哪个PHP版本? - Laurence
http://laravel.io/forum/02-08-2014-difficulty-installing-laravel-getting-error-mcrypt-php-extension-required - Kalhan.Toress
3个回答

16

我正在打开这个文件

gedit /etc/php5/cli/php.ini

将一行文本添加到这个文件中

extension=mcrypt.so

并且这个成功地运行了。

无论如何,再次感谢。


Windows应该怎么做? - Pratik Butani

4
这是我在Mac Yosemite上解决的方法。我在 /etc/ 中有一个 php. ini,并且已经安装了mcrypt,但我遇到了相同的问题。
运行此命令来查找另一个php.ini。
php -i|grep ini

它返回了以下结果。
System => Darwin Myname-MacBook-Pro.local 14.1.0 Darwin Kernel Version 14.1.0: Mon Dec 22 23:10:38 PST 2014; root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64
Configuration File (php.ini) Path => /usr/local/etc/php/5.5
Loaded Configuration File => /usr/local/etc/php/5.5/php.ini
....

我打开了/usr/local/etc/php/5.5/php.ini并在文件中添加了extension=mcrypt.so

希望这能帮助未来的某个人。


1
若要在 Mac 上使用 brew 运行,请在 CLI 中运行:
brew install php56-mcrypt

领主戒指。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接