php PHP7 Laravel Mcrypt 问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34083470/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:44:02  来源:igfitidea点击:

PHP7 Laravel Mcrypt issue

phplaravellaravel-4php-7

提问by Bishal Paudel

Since Laravel4 requires mcryptextension, and PHP7 doesn't seem to have mcryptextension, is there any workaround for this to work?

由于 Laravel4 需要mcrypt扩展,而 PHP7 似乎没有mcrypt扩展,是否有任何解决方法可以解决这个问题?

回答by Ryderpro

Had the same issue - PHP7 missing mcrypt.

有同样的问题 - PHP7 缺少 mcrypt。

This worked for me. When asked, keep local PHP configuration files.

这对我有用。询问时,保留本地 PHP 配置文件。

sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade

Restart FPM (or Apache or NGINX etc.) after installation.

安装后重启 FPM(或 Apache 或 NGINX 等)。

回答by carlituxman

I'm on Mac and with laravel valet I've solved with this:

我在 Mac 上使用 laravel valet 解决了这个问题:

brew install php70-mcrypt

brew 安装 php70-mcrypt

回答by Hemantha

Even if you enable mcrypt in php.ini, this issue may occur. Try the following steps.

即使您在 php.ini 中启用了 mcrypt,也可能会出现此问题。请尝试以下步骤。

sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt

I am working in ubuntu 16.04 and the following commands also helped me.

我在 ubuntu 16.04 中工作,以下命令也对我有帮助。

whereis php  -shows the files with this name
php -v   -shows the php version
which php -shows current php version that is running on the server

回答by Sorin

On ubuntu: According to launchpad.netthe package for mcrypt is called php7.0-mcrypt.

在 ubuntu 上:根据launchpad.net,mcrypt 的包被称为 php7.0-mcrypt。

sudo apt-get install php7.0-mcryptto install

sudo apt-get install php7.0-mcrypt安装

回答by Behind Methods

Open terminal with Ctrl + Alt + T and run following commands for PHP7.0 on Ubuntu 16.4

使用 Ctrl + Alt + T 打开终端并在 Ubuntu 16.4 上为 PHP7.0 运行以下命令

sudo apt-get install mcrypt php7.0-mcrypt
sudo service apache2 restart

回答by fico7489

php7 have mcrypt, you can enable it in php.ini and then everything will work fine.

php7 有 mcrypt,您可以在 php.ini 中启用它,然后一切正常。

回答by devqin

do like this:

这样做:

  1. wget http://jp2.php.net/distributions/php-7.0.3.tar.gz
  2. tar zxf php-7.0.3.tar.gz
  3. cd php-7.0.3/ext/mcrypt
  4. /php7-path/bin/phpize(when error such as configure: error: mcrypt.h not found. Please reinstall libmcryptrun apt-get install libmcrypt-dev)
  5. ./configure --with-php-config=/php7-path/bin/php-config
  6. (sudo) make && make install.this will install the mcrypt.so in php-7.0.3/ext/mcrypt/modules
  7. cp to the /usr/lib/php/20151012/what is the shared extensions dir
  8. create a mcrypt.ini in /etc/php/mods-available/write as extension=mcrypt.so
  9. create link to this such as sudo ln -s /etc/php/mods-available/mcrypt.ini 20-mcrypt.iniin /etc/php/7.0/fpm/conf.d
  10. create link to this such as sudo ln -s /etc/php/mods-available/mcrypt.ini 20-mcrypt.iniin /etc/php/7.0/cli/conf.d
  11. sudo service nginx restart
  12. sudo service php7.0-fpm restart
  13. yes it is.
  1. wget http://jp2.php.net/distributions/php-7.0.3.tar.gz
  2. tar zxf php-7.0.3.tar.gz
  3. cd php-7.0.3/ext/mcrypt
  4. /php7-path/bin/phpize(当错误如configure: error: mcrypt.h not found. Please reinstall libmcryptrun apt-get install libmcrypt-dev
  5. ./configure --with-php-config=/php7-path/bin/php-config
  6. (sudo) make && make install.这将安装 mcrypt.so php-7.0.3/ext/mcrypt/modules
  7. cp 到/usr/lib/php/20151012/什么是共享扩展目录
  8. 创建一个 mcrypt.ini/etc/php/mods-available/写为extension=mcrypt.so
  9. 创建链接到这个功能,比如sudo ln -s /etc/php/mods-available/mcrypt.ini 20-mcrypt.ini/etc/php/7.0/fpm/conf.d
  10. 创建链接到这个功能,比如sudo ln -s /etc/php/mods-available/mcrypt.ini 20-mcrypt.ini/etc/php/7.0/cli/conf.d
  11. sudo service nginx restart
  12. sudo service php7.0-fpm restart
  13. 是的。

回答by eaglewu

PHP7 contains mcrypt extension internally (source-path/ext/mcrypt/). But it depends on Libmcrypt soft.

PHP7 内部包含 mcrypt 扩展 ( source-path/ext/mcrypt/)。但这取决于Libmcrypt软。

Step 1.

第1步。

Download libmcrypt-x.x.tar.gz from http://mcrypt.sourceforge.net/and build it.

http://mcrypt.sourceforge.net/下载 libmcrypt-xxtar.gz 并构建它。

cd libmcrypt-x.x
./configure
make
make install

Step 2.

第2步。

Rebuild PHP7 from source and add --with-mcryptoption.

从源代码重建 PHP7 并添加--with-mcrypt选项。

./configure ... --with-mcrypt

Other way without rebuilding PHP7

无需重建 PHP7 的其他方式

cd php7-source-path/ext/mcrypt/
/php7-path/bin/phpize
./configure --with-php-config=/php7-path/bin/php-config
make && make install
echo "extension=mcrypt.so" >> /php7-path/ext/php.ini

Restart php

重启php

回答by joshuamabina

I use, Dotdeb, an extra repository providing up-to-date all kinds of cool toys for your Debian servers like Nginx, PHP, MySQL, Redis etc.

我使用Dotdeb,这是一个额外的存储库,为您的 Debian 服务器(如 Nginx、PHP、MySQL、Redis 等)提供最新的各种酷玩具。

  1. Update your sources.list

    deb http://packages.dotdeb.org {distribution} all 
    deb-src http://packages.dotdeb.org {distribution} all
    
  2. GnuPG keys

    wget https://www.dotdeb.org/dotdeb.gpg
    sudo apt-key add dotdeb.gpg
    
  3. Update apt & build something amazing.

    sudo apt-get update
    
  1. 更新您的 sources.list

    deb http://packages.dotdeb.org {distribution} all 
    deb-src http://packages.dotdeb.org {distribution} all
    
  2. GnuPG 键

    wget https://www.dotdeb.org/dotdeb.gpg
    sudo apt-key add dotdeb.gpg
    
  3. 更新 apt 并构建一些惊人的东西。

    sudo apt-get update