无法创建 Laravel 项目,因为缺少 mcrypt 扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29056541/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
can't create a Laravel project because mcrypt extension is missing
提问by rogdawg
OK, I have seen many posts about this, and I have spent the entire day working through them to solve this issue, with no success.
好的,我看过很多关于这个的帖子,我花了一整天的时间来解决这个问题,但没有成功。
I am trying to create a Laravel project. I am using a Mac (Yosemite), which is running PHP 5.5.14. There is also an older version of PHP on the machine. When I try to create a project from the command line using "laravel new projectname", no errors are reported, but the command just creates an empty folder named with the project name. I get the "Crafting application..." and "Application ready! Build something amazing" messages but, again, only an empty folder.
我正在尝试创建一个 Laravel 项目。我使用的是运行 PHP 5.5.14 的 Mac (Yosemite)。机器上还有一个旧版本的PHP。当我尝试使用“laravel new projectname”从命令行创建项目时,没有报告任何错误,但该命令只是创建了一个以项目名称命名的空文件夹。我收到“正在制作应用程序...”和“应用程序准备就绪!构建一些惊人的东西”消息,但同样只有一个空文件夹。
If I try to use this command: composer create-project laravel/laravel projectname
如果我尝试使用此命令: composer create-project laravel/laravel projectname
I get this:
我明白了:
Installing laravel/laravel (v5.0.16) - Installing laravel/laravel (v5.0.16) Downloading: 100%
安装 laravel/laravel (v5.0.16) - 安装 laravel/laravel (v5.0.16) 下载:100%
Created project in projectnameLoading composer repositories with package information Installing dependencies (including require-dev) from lock file Your requirements could not be resolved to an installable set of packages.
在projectname 中创建项目 加载带有包信息的Composer存储库 从锁定文件安装依赖项(包括 require-dev) 您的需求无法解析为一组可安装的包。
Problem 1 - Installation request for laravel/framework v5.0.16 -> satisfiable by laravel/framework[v5.0.16]. - laravel/framework v5.0.16 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
问题 1 - laravel/framework v5.0.16 的安装请求 -> laravel/framework[v5.0.16] 可满足。- laravel/framework v5.0.16 需要 ext-mcrypt * -> 您的系统中缺少请求的 PHP 扩展 mcrypt。
In the terminal, if I enter this: which php I get: /usr/bin/php /usr/bin/php -v I get: PHP 5.5.14 (cli) (built: Sep 9 2014 19:09:25) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
在终端中,如果我输入:我得到哪个 php:/usr/bin/php /usr/bin/php -v 我得到:PHP 5.5.14 (cli)(构建:2014 年 9 月 9 日 19:09:25)版权所有 (c) 1997-2014 The PHP Group Zend Engine v2.5.0,版权所有 (c) 1998-2014 Zend Technologies with Xdebug v2.2.3,版权所有 (c) 2002-2013,Derick Rethans
I used homebrew to install autoconf and mcrypt with this command: brew install autoconf mcrypt
我使用自制软件通过以下命令安装 autoconf 和 mcrypt: brew install autoconf mcrypt
If I run that command again, I get: Warning: autoconf-2.69 already installed Warning: mcrypt-2.6.8 already installed
如果我再次运行该命令,我会得到:警告:已安装 autoconf-2.69 警告:已安装 mcrypt-2.6.8
Since I kept getting the error, I assumed it was installed in the wrong place so, I compiled and installed mcrypt myself using these instructions: [Install mcrypt php extension][1]. I used PHP version 5.5.14 during the install. Mcrypt was installed in this directory: /usr/lib/php/extensions/no-debug-non-zts-20121212/
由于我不断收到错误,我认为它安装在错误的位置,所以我使用以下说明编译并安装了 mcrypt:[安装 mcrypt php 扩展][1]。我在安装过程中使用了 PHP 5.5.14 版。Mcrypt安装在这个目录:/usr/lib/php/extensions/no-debug-non-zts-20121212/
I have restarted Apache. I have checked my .bash_profile to make sure /usr/bin is in my Path.
我已经重新启动了 Apache。我已经检查了我的 .bash_profile 以确保 /usr/bin 在我的路径中。
If I create a page with phpinfo() and view it in my browser, I see that mcrypt is listed in the "Module Authors" section of the page. It just lists the names of the people who created the module.
如果我使用 phpinfo() 创建一个页面并在我的浏览器中查看它,我会看到 mcrypt 列在页面的“模块作者”部分中。它仅列出创建模块的人员的姓名。
I am stumped. I look forward to any suggestions that people might offer (I really don't want to install a virtual box, or anything like that. Surely, I can get this module installed in the right place!)
我难住了。我期待着人们可能提供的任何建议(我真的不想安装虚拟盒子或类似的东西。当然,我可以在正确的位置安装这个模块!)
Thanks very much!
非常感谢!
回答by Raynal Gobel
I got this exact same problem too.
You have to find php.ini
for php cli and add extension=mcrypt.so
我也遇到了完全相同的问题。你必须找到php.ini
php cli 并添加extension=mcrypt.so
My system is running LAMPP server with preinstalled PHP. So, here's what I do:
我的系统正在运行预装 PHP 的 LAMPP 服务器。所以,这就是我要做的:
Install mcrypt extension
安装 mcrypt 扩展
I tried both:
我都试过:
sudo apt-get install mcrypt
sudo apt-get install php5-mcrypt
Configure php.ini for CLI
为 CLI 配置 php.ini
Then, edit php.ini located in /opt/lampp/etc/php5/cli/php.ini
add extension=mcrypt.so
on Dynamic Extensionsection (anywhere is fine I think). Don't forget to restart your server.
然后,位于编辑php.ini中/opt/lampp/etc/php5/cli/php.ini
添加extension=mcrypt.so
的动态扩展部分(任何地方是好的,我认为)。不要忘记重新启动服务器。
Try using composer to install laravel
尝试使用composer安装laravel
Now, you can run whatever method you want to install laravel. I download Laravel 5 manually, unzip, then install using composer install
command. I think your command composer create-project laravel/laravel projectname
would've run smoothly too.
现在,你可以运行任何你想安装 Laravel 的方法。我手动下载 Laravel 5,解压,然后使用composer install
命令安装。我认为你的命令composer create-project laravel/laravel projectname
也会顺利运行。
References: here
参考资料: 这里
回答by Muneef M
mac usersinstall brew and then enter
mac 用户安装 brew 然后输入
brew install php56-mcrypt
in terminal
在终端
EDIT
编辑
if you get any error using above line then try this command
如果您在使用上述行时遇到任何错误,请尝试此命令
brew install homebrew/php/php56-mcrypt
回答by sam
Please following the step :
请按照以下步骤操作:
cd /etc/php5/cli/conf.d
ln -s ../../mods-available/mcrypt.ini 20-mcrypt.ini
cd /etc/php5/cli/conf.d
ln -s ../../mods-available/mcrypt.ini 20-mcrypt.ini
Worked for me.
对我来说有效。
回答by Mehul Katpara
For MAC users,
对于 MAC 用户,
brew install homebrew/php/php56-mcrypt
brew 安装 homebrew/php/php56-mcrypt