PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so'

£可爱£侵袭症+ 提交于 2019-12-21 18:05:11

问题


I am trying to update laravel using composer update on ubuntu 06.04 but everytime i run composer update this warning always comes up.

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

Does anyone knows how to deal it?

I am using php7.2


回答1:


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.




回答2:


For (>= PHP 7.3) you can use the following command:

sudo pecl install mcrypt-1.0.2



回答3:


İts is worked for me.

export LC_ALL="C"

export LANG="C

sudo pecl install mcrypt-1.0.1




回答4:


I faced similar issue when I installed Php7.2 on Ubuntu 18.Though I had installed mcryupt using PECL still I get the error mentioned in the question.

I did following to fix it

sudo apt-get install php-pear php7.2-dev

then uninstalled

pecl uninstall mcrypt

Now reinstall mcrypt

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

When you are shown the prompt

libmcrypt prefix? [autodetect] :

Press [Enter] to autodetect.

After success installing mcrypt trought pecl, you should add mcrypt.so extension to php.ini.

The output will look like this:

...
Build process completed successfully
Installing '/usr/lib/php/20170718/mcrypt.so'    ---->   this is our path to mcrypt extension lib
install ok: channel://pecl.php.net/mcrypt-1.0.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini

Now restart Apache

sudo service apache2 restart

Grab installing path and add to cli and apache2 php.ini configuration.

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/20170718/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"



回答5:


I faced this problem when I upgraded my PHP to 7.3

I found mcrypt.so was still present in /etc/php/7.3 that should not be as it is deprecated in php 7.3 so just deleting mcrypt.so from /etc/php/7.3 solved issue.

I used following commands:

cd /etc/php/7.3

sudo rm -rf mcrypt.so

sudo service apache2 restart




回答6:


Also, if you're using php 7.2 & are getting this error and you know do not want/need mcrypt, but do not know how to exclude it.... You need edit your php.ini file and either comment this out by using a semi-colon in front of it:

; extension=mcrypt.so

or just delete that line entirely.



来源:https://stackoverflow.com/questions/49931694/php-warning-php-startup-unable-to-load-dynamic-library-mcrypt-so

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!