Ubuntu 13.10 PHP 5.5.x mcrypt missing – Fatal Error: Undefined function mcrypt_encrypt()!

[原文]http://www.tuicool.com/articles/goto?id=myM7veR

 

I had updgraded my Ubuntu from 13.04 to 13.10 last week and everything went quite good. The only problems that I faced as developer are:

  1. Apache 2.4 was not working with default previous installation and configuration and I had to remove it (completely uninstall/purge and autoremove) and install it again.
  2. All the virtual host setting did not work. I did not go for opting to change the Include setting in apache2.conf instead I rewrote all the settings myself.
  3. Another annoying and very strange problem was that PHP and its libraries. First I had problems with installing apache module that connects to PHP. Secondly I had problems of missing mcrypt library which is required for couple of projects on my system. Particularly a project developed in Zend 1.11 and phpmyadmin did not work. I had the following error where I had written some methods for AES encryption with PHP’s mcrypt library.
Fatal Error: Undefined function mcrypt_encrypt()

I thought the mcrypt library was missing in my PHP installation and I simply tried to install it via command line as follows:

$ sudo apt-get install php5-mcrypt

And I got the following:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
php5-mcrypt is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.

Weird 技术分享 . If it is already there why isn’t it working with my projects? Then I Googled for sometime and could not find exact solution anywhere. I tried to look the ini in /etc/php5/conf.d/ and there was mcrypt.ini file with quite proper content in it:

; configuration for php MCrypt module
extension=mcrypt.so

Again I pulled my hair out and went out for the tea. Then I came and tried to look at the other folders inside /etc/php5 folder and saw there mods-available which had again some ini files in it but missing mcrypt.ini. Then I just tried moving that mcrypt.ini file from /etc/php5/conf.d/ to /etc/php5/mods-available/ then restarting the apache server.

$mv /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
$ sudo service apache2 restart

Then I tried phpmyadmin from the browser, amazingly it worked now !

Hope this will help others who are facing the same issue.

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。