As of PHP 7.1, the php-mcrypt was deprecated. And as of PHP 7.2 it was completely removed. This is a problem, since a number of server software titles still depend upon this encryption tool. And because software like Nextcloud, ownCloud, and many more have yet to shift that dependency, you might find yourself unable to install without mcrypt on the system. What do you do? No matter how many times you run either apt-get install php-mcrypt or yum install php-mcrypt, it won’t work.
Fortunately, there’s a solution. Said solution falls onto the shoulders of the pecl command. PECL is the PHP Extension Community Library, which serves as a repository for PHP extensions. Through this repository, you can install mcrypt.
What is mcrypt?
The mcrypt extension is a replacement for the UNIX crypt command. These commands serve as a means to encrypt files on UNIX and Linux systems. The php-mcrypt extension serves as an interface between PHP and mcrypt.
SEE: Securing Linux policy (Tech Pro Research)
Getting mcrypt installed
I’m going to walk you through the process of getting mcrypt installed on Ubuntu Server 16.04. It’s not challenging once you have the necessary dependencies added to your system. With mcrypt installed, you can continue with the installation of the software that depends upon this extension.
With that said, how do we install mcrypt? First, open up a terminal window and install the necessary dependencies with the commands:
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
Once the dependencies have been installed, you can install mcrypt with the command:
sudo pecl install mcrypt-1.0.1
And there you go. Mcrypt is now installed. Go back to the process of installing whatever server software that depends upon this extension and you should be good to go.
Not gone, just moved
Don’t worry: mcrypt is not gone. It’s just been moved out of PHP and into PECL. But for those who have been installing via php-mcrypt for years, this makes for a pretty big shift. Now, instead of being able to install mcrypt with a single command, you have four to deal with. Even so, at least you still have mcrypt available. Eventually, however, I believe the mcrypt dependency will be migrated to another tool (such as OpenSSL).
- How to install ownCloud on Ubuntu 18.04 (TechRepublic)
- How to install nextCloud 13 on Ubuntu 18.04 (TechRepublic)
- How to install Ubuntu Server 18.04 (TechRepublic)
- How to encrypt files on a Ubuntu server with Tomb (TechRepublic)
- Open source’s big German win: 300,000 users shift to Nextcloud for file sharing (ZDNet)