Home » Php » php – Error installing php5-mcrypt

php – Error installing php5-mcrypt

Posted by: admin July 12, 2020 Leave a comment

Questions:

Just today I signed up with Google Cloud Compute Engine. I did everything but then I stuck into an error while installing php5-mcrypt extension.
Error:

[email protected]:~# sudo apt-get install php5-mcrypt
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php5-mcrypt : Depends: phpapi-20121212
               Depends: php5-common (= 5.5.24+dfsg-1+deb.sury.org~vivid+1) but 5.6.4+dfsg-4ubuntu6 is to be installed
E: Unable to correct problems, you have held broken packages.

I searched everywhere and then I came here. Please help.

How to&Answers:

sudo service apache2 restar

apt-get install php5-common 

Or, if you dont need to keep configurations:

apt-get purge php5-common
apt-get install php5-common

Do you get any output from apt-mark showhold?

If it does not solve your problem, you should try install it with aptitude:

sudo apt-get install aptitude
sudo aptitude install php5-mcrypt

Finally reatast the server

sudo service apache2 restart

Answer:

Had exactly the same problem. The accepted solution did not work for me. Took me eternities to figure a way.

sudo add-apt-repository -r ppa:ondrej/php5
sudo add-apt-repository -r ppa:ondrej/php5-oldstable
sudo add-apt-repository -r ppa:ondrej/php5-5.6
sudo apt-get purge php5* apache2* mcrypt*
sudo apt-get update
sudo apt-get upgrade

(WARNING: You’ll lose all settings for your PHP and Apache installation!)

reinstall:

sudo apt-get install php5 php5-mcrypt php5-curl apache2

and enable the extensions

sudo php5enmod mcrypt
sudo php5enmod curl

Magic.

Answer:

This is horrible, horrible, horrible. Adding ppa:ondrej/php5-5.6 together with ppa:ondrej/php5 and ppa:ondrej/php5-oldstable will bring you nothing at all, as you need exactly one of these (as one contains PHP 5.4, second PHP 5.5 and third PHP 5.6). Purging php5* and apache2* is also not necessary, you might want to purge apache2.2-common if you encounter an error upgrading, but that’s it. And then mcrypt and curl modules will get enabled automatically (unless you have disabled them in the past), so php5enmod mcrypt and php5enmod curl is extra (but not harmful).