PHP7 Laravel Mcrypt issue

2019-01-10 18:40发布

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

9条回答
够拽才男人
2楼-- · 2019-01-10 19:12

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

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

查看更多
Bombasti
3楼-- · 2019-01-10 19:13

Had the same issue - PHP7 missing mcrypt.

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

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.

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-01-10 19:18

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

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.

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
查看更多
啃猪蹄的小仙女
5楼-- · 2019-01-10 19:24

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

sudo apt-get install mcrypt php7.0-mcrypt
sudo service apache2 restart
查看更多
我欲成王,谁敢阻挡
6楼-- · 2019-01-10 19:29

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 libmcrypt run 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.ini in /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.ini in /etc/php/7.0/cli/conf.d
  11. sudo service nginx restart
  12. sudo service php7.0-fpm restart
  13. yes it is.
查看更多
做个烂人
7楼-- · 2019-01-10 19:29

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

Step 1.

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

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

Step 2.

Rebuild PHP7 from source and add --with-mcrypt option.

./configure ... --with-mcrypt

Other way without rebuilding 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

查看更多
登录 后发表回答