I have updated cli and nginx to use php 7.2 using the follow commands:

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
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20190902/mcrypt > /etc/php/7.2/mods-available/mcrypt.ini"

However when I run:

php -i | grep "mcrypt" 

I get the following response:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20190902/mcrypt' (tried: /usr/lib/php/20190902/mcrypt (/usr/lib/php/20190902/mcrypt: cannot open shared object file: No such file or directory), /usr/lib/php/20170718//usr/lib/php/20190902/mcrypt.so (/usr/lib/php/20170718//usr/lib/php/20190902/mcrypt.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
/etc/php/7.2/cli/conf.d/mcrypt.ini

phpinfo() doesn’t display mcrypt info either, I’m guessing for the same reason.

I’ve tried changing the path in /etc/php/7.2/cli/php.ini; ‘extension_dir’ is actually commented out, but if I uncomment it, whatever I update it to, it gets appended to ’/usr/lib/php/20170718/’.

Why does my system insist on using ’/usr/lib/php/20170718/’ as the path?

How do I get mcrypt working for cli and nginx?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hello, @ecell100

As you can see from the warning message, the problem is with the actual path of the library:

(/usr/lib/php/20190902/mcrypt: cannot open shared object file: No such file or directory), /usr/lib/php/20170718//usr/lib/php/20190902/mcrypt.so (/usr/lib/php/20170718//usr/lib/php/20190902/mcrypt.so: cannot open shared object file: No such file or directory)) in Unknown on line 

You can either try running these two commands:

sudo bash -c "echo extension=/usr/lib/php/20190902/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20190902/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"

or change the path manually by editing the ini files directly. You can then again test if everything is loaded correctly:

php -i | grep "mcrypt"

Keep in mind that you need to restart Nginx as well in order to make sure the new library is loaded.

Let me know how it goes.

Regards,
Alex

  • Apologies I should have double checked what I posted, I have already run the two sudo bash echo commands exactly as you have put them.

    I get the ‘Unable to load dynamic library’ for all libraries including mcrypt.

    • Hello, @ecell100

      Thanks for confirming this.

      Can you provide me with the output of the following command:

      php -m | grep mcrypt
      

      Regards,
      Alex

      • Thanks for replying, I rolled the server back to php7.0 to get this working

        • Hello, @ecell100

          I’m glad that you’ve sorted this. What you can do is to spin up another droplet (dev environment) when you want to upgrade to PHP 7.2 and test if everything is working on the new droplet. Once you’re happy with the result you can replicate the changes on your live droplet.

          Regards,
          Alex

Submit an Answer