Ubuntu Server 18.04 LTS中缺少php-mcrypt软件包


19

php-mcryptUbuntu Server 18.04 LTS中缺少该软件包吗?

apt install php-mcrypt
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php-mcrypt is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'php-mcrypt' has no installation candidate

Ubuntu php-mcrypt:packages.ubuntu.com/… ... 18.04没有php-mcrypt。
努德·拉森

Answers:


33

Mcrypt在PHP 7.2中已被弃用,因此默认情况下不可用。

您仍然可以使用pecl安装mcrypt扩展。这些说明适用于apacheWeb服务器。

# Install prerequisites
sudo apt-get install php-dev libmcrypt-dev gcc make autoconf libc-dev pkg-config

# Compile mcrypt extension
sudo pecl install mcrypt-1.0.1
# Just press enter when it asks about libmcrypt prefix

# Enable extension for apache
echo "extension=mcrypt.so" | sudo tee -a /etc/php/7.2/apache2/conf.d/mcrypt.ini

# Restart apache
sudo service apache2 restart

那应该让你走。

从长远来看,您可能想替换mcrypt,这是有原因的。


7

我做了以下工作才能使它工作...

sudo add-apt-repository ppa:ondrej/php
sudo apt-get install php7.1-mcrypt

如果您运行的是php5.6或7.0,则可以使用以下代码

sudo apt-get install php5.6-mcrypt
sudo apt-get install php7.0-mcrypt

1
实际上,在添加ppa存储库和installet php7.1-mcrypt之后,Ubuntu 18.04实际上具有php7.2,当我执行a2enmod mcrypt时,响应为“模块mcrypt不存在”!
安德里亚·罗塞蒂

您可能使用的是php 7.2(/etc/php/7.2)-这会将其安装到7.1(/etc/php/7.1/),并且仅当您还安装/使用该版本的php时才有效apt-get install php7.1
Alvin


3

首先检查mcrypt PHP模块是否存在:

$ php -m | grep mcrypt

要安装mcrypt PHP模块,我们首先需要满足以下先决条件:

sudo apt install php-dev libmcrypt-dev php-pear

现在我们准备在Ubuntu 18.04系统上安装mcrypt PHP模块:

$ sudo pecl channel-update pecl.php.net
$ sudo pecl install mcrypt-1.0.1

打开/etc/php/7.2/cli/php.ini文件并插入:

extension=mcrypt.so

全做完了。成功后,检查mcrypt PHP模块是否存在应产生以下输出:

$ php -m | grep mcrypt
mcrypt
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.