问题
I tried to follow: PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so'
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install php7.2-dev
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.1
I get:
pecl/mcrypt requires PHP (version >= 7.2.0, version <= 7.3.0, excluded versions: 7.3.0), installed version is 7.3.3-1+ubuntu14.04.1+deb.sury.org+1
No valid packages found
install failed
I use prestashop which require this
回答1:
If anyone is using an AWS bitnami install w/ php7.3.10, the following is a layout with appropriate file paths (references listed below)
Check your PHP version
$ php -version
Install mcrypt
extension
$ sudo apt-get -y install gcc make autoconf libc-dev pkg-config
$ sudo apt-get -y install libmcrypt-dev
If php version > 7.3.0
$ sudo pecl install mcrypt-1.0.2
Or the newest version: https://pecl.php.net/package/mcrypt
If php version <= 7.3.0
$ sudo pecl install mcrypt-1.0.1
When you are shown the prompt (Press [Enter] to autodetect)
> libmcrypt prefix? [autodetect] :
enable mcrypt
in php.ini -> check if mcrypt
is already in php.ini and maybe just needs to be uncommented
$ more /opt/bitnami/php/etc/php.ini | grep mcrypt
;extension=mcrypt.so
Add or uncomment extension=mcrypt.so
in php.ini
$ emacs /opt/bitnami/php/etc/php.ini
REFERENCES...
https://lukasmestan.com/install-mcrypt-extension-in-php7-2/
How to install mcrypt on PHP 7.3.3 ubuntu
https://stackoverflow.com/a/55678046/2298002
回答2:
You have to install version 1.0.2.
The error message clearly tells you 1.0.1 supports only PHP 7.2, not 7.3.
It's all documented on the official pecl/mcrypt page.
Release 1.0.2:
PHP Version: PHP version 7.4.0 or older
PHP Version: PHP 7.2.0 or newer
PEAR Package: PEAR 1.4.0 or newer
Release 1.0.1:
PHP Version: PHP version 7.3.0 or older
PHP Version: PHP 7.2.0 or newer
PEAR Package: PEAR 1.4.0 or newer
回答3:
Use this, it's working perfectly in php-7.3:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.1
Autodetect: HIT ENTER
sudo bash -c "echo extension=/usr/lib/php/[folder in your pc]/mcrypt.so > /etc/php/7.3/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/[folder in your pc]/mcrypt.so > /etc/php/7.3/apache2/conf.d/mcrypt.ini"
php -i | grep mcrypt
来源:https://stackoverflow.com/questions/55678023/how-to-install-mcrypt-on-php-7-3-3-ubuntu