mcrypt is not loading (even after installing) - php

I have changed mac's builtin version 5.6 of php to 7.0 which works fine but my mcrypt is not working. I have installed it using brew install mcrypt php70-mcrypt.
How I can fix this issue? I am using MacOS Sierra.

First, make sure you restarted PHP. Then, at the command line, type php -v and make sure you're actually using 7.0.
If it still doesn't work make a php file and run phpinfo() and see if the extension is loading. If not, please provide any further information you can.

Have you turned on the mcrypt after installing it? You can use the following command to activate the mcrypt.
PHP5
php5enmod mcrypt
PHP7+
phpenmod mcrypt
Also, You can do this by uncommenting the line for mcrypt in php.ini.Let me know if that helps!

You need to enable the extension by editing /etc/php.ini. If this file is not present, copy /etc/php.ini.default and rename it:
sudo cp /etc/php.ini.default /etc/php.ini
Edit the /etc/php.ini file and add the following:
extension=mcrypt.so
and Restart apache
sudo apachectl restart

Related

Enable MCrypt using MAMP

I'm using MAMP and ive installed a fresh version of Opencart, its telling me i dont have MCrypt enabled, when i go to terminal and type:
php -m | grep mcrypt
output: mcrypt
I can locate the library but it doesn't seem to be enabled.
That fact that php -m | grep mcrypt returns mcrypt, means the mcrypt library is INSTALLED and ENABLED.
Although it may just be enabled for CLI.
You can try editing the PHP.ini file and adding the following line under the ; Extensions section:
extension=mcrypt.so
Restart Apache / MAMP after saving php.ini file.
To find the correct php.ini file to edit, run the following command line:
php --info | grep php.ini
(If the line already exists, you may just need to remove the ; thats in front of it.)
I have tried so many ways but had no luck.
After a lot of trials finally came up with a solution.
Go to bin directory inside current active PHP version directory. In my case it is /Applications/MAMP/bin/php/php7.2.8/bin
It might be different in your case. Now run the below command with sudo
sudo ./pecl install channel://pecl.php.net/mcrypt-1.0.1
Now You should add extension=mcrypt.so to php.ini
Restart MAMP Service and check if it is working.
I had this issue following upgrading to MAMP 5.1 and using PHP 7.1.20...
The issue I found was not that MAMP PHP did not have mcrypt installed, it certainly does come bundled.
The issue was that the MAMP PHP configuration option "Make this version available on the command line" was NOT working and so the version of PHP I was using on the command line [in my case] was the macOS default PHP 7.1.16 without mcrypt (the version included in macOS by default)
Reverting to the old cli php alias meant the correct MAMP version of PHP was used on the command line
Added to .bash_profile
alias php='/Applications/MAMP/bin/php/php7.1.20/bin/php'
try in console
pecl install mcrypt
Using Brew:
Install mcrypt: brew install mcrypt
In Mamp: File -> Edit Template -> PHP (php.ini)-> {PHP version}
Find 'Dynamic Extensions' in the text and add the following below (after the lines starting with ';'):
extension=mcrypt.so
Save, restart and test (with php -i | grep mcrypt for example)

Call to undefined function mcrypt_get_block_size()

Call to undefined function mcrypt_get_block_size()
php version - 5.6.6
os- yosemite 10.10.2
mcrypt version- 2.5.8
Need help
You may actually have to add a symlink in /etc/php5/apache/conf.d to the mcrypt.ini file. After that, restart the webserver and inspect phpinfo().
You have to enable the mcrypt extension.
Add the following line to the php.ini:
extension=mcrypt.so
Then restart your webserver.
For people who are on OSX
php -v
will give you the php version, and if you have brew do:
brew search mcrypt
you will see things like
homebrew/php/php53-mcrypt homebrew/php/php55-mcrypt homebrew/php/php70-mcrypt
homebrew/php/php54-mcrypt homebrew/php/php56-mcrypt
install the one appropriate to your php version
then look at the /usr/local/etc/php/x.x/conf.d/ext-mcrypt.ini and add the contents to your php.ini.
restart your webserver and see the phpinfo(). you should see mcrypt loaded as a module.

can't find mcrypt => Call to undefined function Laravel\mcrypt_create_iv()

Trying to set up Laravel and keep getting hit with this error. I installed mcrypt through brew and it is located in /usr/local/Cellar. Any thoughts? .. It's not showing up in terminal command php -m either, if that matters. I'm running Mountaion Lion with macs native web server.
Ubuntu or any Debian based Linux users can install the required package with apt-get:
sudo apt-get install php5-mcrypt
Remember to restart the web server afterwards:
sudo service apache2 restart
If it still doesn't work, try to link the configuration file to the appropriate configuration folder for the web server. Thanks to dave1010 for this hint in the comments.
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/ # for Apache
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/cli/conf.d/ # for CLI
And again, restart the web server:
sudo service apache2 restart
Perhaps, if not working yet, you need also the line showed by #RahulPrasad, with php5enmod mcrypt.
You need to enable it in your php.ini file as well and probably restart Apache.
In php.ini you will find ;mcrypt.so and remove the ; from it.
Or, if it's not in there, just add mcrypt.so somewhere.
Also the salt option has been deprecated as of PHP 7.0.0. It is now preferred to simply use the salt that is generated by default.
Try sudo php5enmod mcrypt && sudo service apache2 restart
You've installed mcrypt when you actually wanted the php56-mcrypt php module.
You stated in your question that you can see mcrypt installed in /usr/local/Cellar and that you're using OSX. So, the easiest way to install the mcrypt PHP module on OSX using Homebrew is:
// assuming you have php56
brew install php56-mcrypt
If homebrew can't find the correct package you may need to tap the PHP repositories found on GitHub:
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
Now when you issue the command brew search mcrypt, you should see something like:
libtomcrypt mcrypt php53-mcrypt php54-mcrypt php55-mcrypt php56-mcrypt
Several other posters have mentioned the need to edit your php.ini file. This will be unnecessary as homebrew will take care of activating the module for you. It places the configuration file at /usr/local/etc/php/5.6/conf.d/ext-mcrypt.ini
You don't have the mcrypt PHP extension installed.
For a Mac, I followed these instructions:
mcrypt on Mac 10.7 or 10.8.
They look like a lot, but it's not, it's very easy to follow in it works!
You may have installed mycrypt but not have the php_mcrypt module installed / enabled.
Just a note for people who have recently upgraded to PHP 7 - The MCRYPT library has been deprecated. If you upgraded to PHP 7 and are now seeing this error, that is why. You should switch to an alternative library, some alternatives are mentioned in this thread.
Go to the CLI folder in your php instalation, and find php.ini in there and enable mcrypt. Terminal sometimes uses another php.ini, which is usually in the CLI folder.
I installed php and mcrypt with Homebrew, but I still experienced this error after doing brew update a few times. I think my setup has just gotten a bit borked over time.
It turns out my php was being configured from /private/etc/php.ini, not /usr/local/etc/php/5.4/php.ini as Homebrew recommends. Mcrypt is not even being included from /usr/local/etc/php/5.4/ext-mcrypt.ini which doesn't make a lot of sense considering php -i produces this for me:
Configuration File (php.ini) Path => /usr/local/etc/php/5.4
Loaded Configuration File => /usr/local/etc/php/5.4/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/5.4/conf.d
Additional .ini files parsed => /usr/local/etc/php/5.4/conf.d/ext-mcrypt.ini
My solution:
Edit /private/etc/php.ini as a superuser
Add extension="/usr/local/Cellar/php54-mcrypt/5.4.28/mcrypt.so" and save
Restart Apache with sudo apachectl restart
This is what finally worked for me:
brew reinstall --with-homebrew-curl --with-httpd php56
brew reinstall --build-from-source php56-mcrypt
I also had to do sudo chmod 777 /usr/local/etc/php/5.6/conf.d because I got errors when the second brew reinstall tried to add the ext-mcrypt.ini to that directory.

Install Tidy, PHP

I guess when php was installed on my box --with-tidy arg was not included.
When browsing my php.ini the line:
;extension=php_tidy.dll
is missing.
How can I add the module to my php install? Note I tried adding:
extension=php_tidy.dll
but with no luck.
I checked the docs but all they say is:
This extension is bundled with PHP 5 and greater, and is installed using the --with-tidy configure option.
On Ubuntu, you can add tidy to your php5 installation by running this command in a terminal:
$ sudo apt-get install php5-tidy
If you want to check if it is already installed or validate that the command above worked:
$ php -i | grep libTidy
libTidy Release => 25 March 2009 // means tidy is installed
To install both php5 and tidy at the same time, use this command (as an alternative to the "--with-tidy" configuration option):
$ sudo apt-get install php5 php5-tidy
For PHP 7 just run
sudo apt-get install php-tidy
And restart Apache, That's it :)
Update: Thanks to #Arnis Juraga
For the version above PHP 7, you can mention the version code as follows.
apt-get install php7.4-tidy
I was having the same trouble, and wrote up my solution here:
Installing Tidy 2.0 PHP extension on Ubuntu 10.10
http://web.onassar.com/blog/2010/11/16/installing-tidy-2-0-php-extension-on-ubuntu-10-10/
It works on newer versions of Ubuntu as well.
While it may not be the most direct route, it works well.
I hope it helps others.
Put that line in php.ini next to the other extension=...dll lines and make sure php_tidy.dll is in the directory configured in php.ini under extension_dir.
In ubuntu: you need to run the following command in terminal
sudo apt-get install php5-tidy
and the restart the server
sudo service apache2 restart.
For those who are having trouble enabling Tidy extension for PHP (using PHP handler for Apache server) on Windows (WAMP server), please note that you may be editing the wrong php.ini file. Assuming that WAMP server is installed in C:\wamp[ver]\ where [ver] is a variable version number.
File that you're probably editing:
C:\wamp[ver]\bin\php\php[ver]\php.ini
File that you must edit:
C:\wamp[ver]\bin\apache\apache[ver]\bin\php.ini
You also might want to make sure what's the correct php.ini file to edit by creating an info php file and add this code to it:
<?php phpinfo();
Then look for Loaded Configuration File string.
Finally make sure you uncomment this line within the correct php.ini file:
extension=tidy

What's needed for PHP's mcrypt_decrypt()?

I have a script that uses mcrypt_decrypt() function, but I get the following error
Fatal error: Call to undefined function mcrypt_decrypt()
What modules/libraries do I need to include to use this function? Or is there another reason I'm getting the error?
Thanks
sudo apt-get install php5-mcrypt
works on ubuntu.
Please see:
Mcrypt Requirements
Mcrypt Installation
You need to compile your PHP with --with-mcrypt[=DIR] and have libmcrypt Version 2.5.6 or greater on your machine.
Configure php5-mcrypt with php5-fpm (Ubuntu 14.04)
I’m going to assume you already have nginx and php-fpm installed and running.
php5-mcrypt should be installed already (it comes bundled with php5-fpm). Just for safety,
apt-get install php5-mcrypt
Create symlink to mods-avaliable,
ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini
Enable it.
php5enmod mcrypt
Restart php-fpm,
service php5-fpm restart
Restart nginx,
service nginx restart
Done!
From the manual:
You need to compile PHP with the
--with-mcrypt[=DIR] parameter to enable this extension. DIR is the
mcrypt install directory. Make sure
you compile libmcrypt with the option
--disable-posix-threads.
Generally if PHP says a function is undefined, it means you need to compile in some library.
I above doesn't work, you can try this:
create mcrypt.ini file in /etc/php5/conf.d with content
extension=mcrypt.so
I upgraded PHP to 5.4 via http://php-osx.liip.ch/ and it worked.
for php 5.3.X
depends on availability of yum mcrypt package , you could use yum packeages
like this :
yum install php53-mcrypt
and restart httpd
And be carefull about the folder in the phpinfo page : "Scan this dir for additional .ini files" and the next : "Additional .ini files parsed ".
After upgrading to php 5.4 running (Works)
sudo php5enmod mcrypt
sudo service apache2 restart

Categories