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)
I am trying to use the migrate function in Laravel 4 on OSX. However, I am getting the following error:
Laravel requires the Mcrypt PHP extension.
As far as I understand, it's already enabled (see the image below).
What is wrong, and how can I fix it?
Do you have MAMP installed?
Use which php in the terminal to see which version of PHP you are using.
If it's not the PHP version from MAMP, you should edit or add .bash_profile in the user's home directory, that is : cd ~
In .bash_profile, add following line:
export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
Edited: First you should use command cd /Applications/MAMP/bin/php to check which PHP version from MAMP you are using and then replace with the PHP version above.
Then restart the terminal to see which PHP you are using now.
And it should be working now.
The web enabled extensions and command line enabled extensions can differ. Run php -m in your terminal and check to see if mcrypt is listed. If it's not then check where the command line is loading your php.ini file from by running php --ini from your terminal.
In this php.ini file you can enable the extension.
OSX
I have heard of people on OSX running in to problems due to the terminal pointing to the native PHP shipped with OSX. You should instead update your bash profile to include the actual path to your PHP. Something like this (I don't actually use OSX so this might not be 100%):
export PATH=/usr/local/php5/bin:$PATH
Ubuntu
On earlier versions of Ubuntu (prior to 14.04) when you run sudo apt-get install php5-mcrypt it doesn't actually install the extension into the mods-available. You'll need to symlink it.
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini
On all Ubuntu versions you'll need to enable the mod once it's installed. You can do that with php5enmod.
sudo php5enmod mcrypt
sudo service apache2 restart
NOTES
PHP 7.1 deprecated mcrypt and 7.2 has removed the mcrypt extension entirely
Laravel 5.1 and later removed the need for mcrypt
To those that uses XAMPP 1.7.3 and Mac
Go to Terminal
Enter which php
If it says /usr/bin/php, then proceed to 3.
Enter sudo nano ~/.bash_profile (or sudo vim ~/.bash_profile if you know how to use it)
Then paste this export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH"
Ctrl+O then enter to save, then Ctrl+X to exit.
Type cd ~
type . .bash_profile
restart terminal.
Enter which php. If you did it right, it should be the same as the path in #4.
The reason for the mcrypt error is because your Mac uses its native php, you need to change it to the one xampp has.
P.S.
I'd recommend using MAMP for Laravel 4 for Mac users, this issue will get resolved along with the php file info error without a sweat, and the php version of xampp is so outdated.
For non MAMP or XAMPP users on OSX (with homebrew installed):
brew install homebrew/php/php56-mcrypt
Cheers!
Using Ubuntu, just
sudo php5enmod mcrypt
did the trick for me. You don't need to restart Apache since you need to use PHP just from the CLI.
In Ubuntu (PHP-FPM,Nginx)
sudo apt-get install php5-mcrypt
After installing php5-mcrypt
you have to make a symlink to ini files in mods-available:
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini
enable:
sudo php5enmod mcrypt
restart php5-fpm:
sudo service php5-fpm restart
More detail
Getting Laravel working on Apache
PHP version : PHP 5.5.9
Ubuntu version : 14.04
i had a working laravel project on windows. when i copied it to ubuntu server , i started getting the mcrypt error. this after a lot of hours of trial and error
getting artisan command working
(if you are having mcrypt error while using artisan command line tool)
i did a lot of trial and error so each time i run the php5enmod command before, i had error messages. but on fresh install there was no error messages. after this step i got artisan command working
sudo rm /etc/php5/mods-available/mcrypt.ini
sudo apt-get purge php5-mcrypt
sudo apt-get install mcrypt
sudo apt-get install php5-mcrypt
sudo php5enmod mcrypt
fixing the browser error
(if you are having mcrypt error in browser when accessing local laravel index page)
sudo nano /etc/php5/apache2/php.ini
add the following line under the dynamically compiled extensions section of php ini
extension=mcrypt.so
restart the apache server , purge the laravel cache and everything working
For php-fpm installations on Ubuntu 14.04, the following worked for me :
sudo apt-get install php5-mcrypt
This will create mcrypt.ini file inside /etc/php5/mods-available/
Then
sudo php5enmod mcrypt
will create a symlink in: /etc/php5/fpm/conf.d/
Just restart php-fpm services
sudo service php5-fpm restart
For ubuntu try these steps if others are not working :
cd ~
sudo apt-get remove php5-mcrypt
sudo apt-get install php5-mcrypt
sudo php5enmod mcrypt
sudo service apache2 restart
Hope that will help. Thanks !
Or, use:
sudo apt-get install php5-mcrypt
not sure if this will work on standard PHP installs - I installed php 5.5.7 using the package from :
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
This solved it for me on my Linux Mint local enviroment https://askubuntu.com/questions/350942/cannot-get-mcrypt-for-php5
I needed to make a symlink to my /etc/php5/conf.d/mcrypt.ini file in the following folders /etc/php5/apache2/conf.d/mcrypt.ini and /etc/php5/cli/conf.d/mcrypt.ini
My OS is Yosemite.
I resolve this issue, by finding configuration paths:
php --ini
Example output:
Configuration File (php.ini) Path: /usr/local/etc/php/5.5
Loaded Configuration File: /usr/local/etc/php/5.5/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.5/conf.d
Additional .ini files parsed: (none)
Next steps:
Rename or Delete php55 ini file
Create symlink
Restart Apache server
Commands:
mv /usr/local/etc/php/5.5/php.ini /usr/local/etc/php/5.5/php.ini.default
ln -s /etc/php.ini /usr/local/etc/php/5.5/php.ini
sudo apachectl restart
Then you can check your php modules via:
php -m
Just for yumers,
yum install php-mcrypt
service httpd restart
chown -R apache:apache apppath
Maybe you need install remi repo
You need an all in one environment. You may use MAMP or XAMPP or any other tools. After installing one of these tools you will need to edit(create) your .bash_profile(Assuming that you use bash).
Or even simple and more professional you can use Laravel Homestead.
Here is a link to official documentation: http://laravel.com/docs/5.0/homestead
Also Jeffrey has a free tutorial about it:
https://laracasts.com/series/laravel-5-fundamentals/episodes/2
I advice you to go with homestead because you will preinstall all of the following tools.
Ubuntu 14.04
PHP 5.6
HHVM
Nginx
MySQL
Postgres
Node (With Bower, Grunt, and Gulp)
Redis
Memcached
Beanstalkd
Laravel Envoy
Fabric + HipChat Extension
For those who still come here today:
Laravel does not need mcrypt extension anymore. mcrypt is obsolete, the last update to libmcrypt was in 2007. Laravel 4.2 is obsolete too and has no more support. The best (=secure) solution is to update to Laravel 9.x+ (Laravel 8.x is still okay. But if you are upgrading, then upgrade to the latest version).
Mcrypt was removed from Laravel in June 2015: https://github.com/laravel/framework/pull/9041
Expanding on #JetLaggy:
After trying again and again to modify .bash_profile with the MAMP directory, I changed the file permissions for the MAMP php directory and was able to get 'which php' to show the proper directory. Trouble was that other functions didn't work, such as 'php -v'.
So I updated MAMP. http://documentation.mamp.info/en/mamp/installation/updating-mamp
This did the trick for my particular setup. I had to adjust my PATH to reflect the updated version of PHP, but once I did, everything worked!
On OS X
Using MAMP
Enter the command which php in the terminal to see which version of PHP you are using. If it's not the PHP version from MAMP, the $PATH variable used by Bash will need to be updated.
First, you should use command "cd /Applications/MAMP/bin/php" to check which php version from MAMP and take note of the version (eg, php5.6.7).
Once you know the version, you should edit the ~/.bash_profile file (that is, the .bash_profile that is in your home directory) and add an export line:
export PATH=/Applications/MAMP/bin/php/php5.6.7/bin:$PATH
Make sure that you replace php5.6.7 with the version of PHP that you have selected in MAMP.
Once the file has been saved, make sure that you close close your Terminal and open it again. Once that has been done, you will be using the PHP that ships with MAMP.
One way to easily find what the line should be that you need to put inside your .bash_profile is to run the following command inside your terminal:
echo export PATH=`cat /Applications/MAMP/conf/apache/httpd.conf \
| grep php | grep -i LoadModule | head -n1 \
| sed -e 's/^[^\/]*\/\(.*\)\/mod.*/\/\1/'`/bin:\$PATH
Copying and pasting those three lines into your terminal will correctly output the PHP version that has been selected inside the MAMP control panel.
Using Homebrew/MacPorts
Make sure that your path contains /usr/local/bin/ (Homebrew) or /opt/local/bin (MacPorts) if you are using PHP that comes with either of these two package managers.
Checking the PHP path with MacPorts
You can find the exact location of PHP using MacPorts with the following command:
port contents php70 | grep bin/php
Note that you should replace php70 with the version of PHP that you have installed.
Check the PHP path with Homebrew-php
Homebrew-php (https://github.com/Homebrew/homebrew-php) is a tap that has various different versions of PHP.
You can find the exact location of PHP using Homebrew with the following command:
brew --prefix homebrew/php/php56
Note that you should replace php56 with the version of PHP that you have installed.
in Ubuntu 14.04
sudo apt-get install php5-mcrypt
sudo php5enmod mcrypt
Ubuntu 16.04
sudo apt-get install php-mcrypt
sudo phpenmod mcrypt
Ubuntu 18.04
sudo apt install php7.0-mcrypt
sudo phpenmod mcrypt
or
sudo apt install php7.2-mcrypt
sudo phpenmod mcrypt
If you are using Z Shell, just do the following:
Open terminal
sudo nano ~/.zshrc
Paste this; export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH
Save
Run source ~/.zshrc
Run which php - you should get the MAMP 5.6.10 path
5.6.10 is the version of PHP you set in your MAMP.
OSX with brew
$ brew install mcrypt php70-mcrypt
I am running PHP 7.0.x, so change "php70" to your version, if you are using a different version.
As stated in other answers, you can see your php version with $ php -v.
sudo php install mcrypt
sudo php5enmod mcrypt
I am trying to make postgresql work with apache on my Mac OSX. I use homebrew to manage all my dev features, so I replace the default php version provided by apache and download a homebrew version, this part works really fine. The problem is when I want to install the postgresql extension..
I have done this :
brew install postgresql
brew install php55 --with-postgresql
brew install php55-pdo-pgsql
And then edit the /etc/apache2/httpd.conf file to replace LoadModule php5_module libexec/apache2/libphp5.so by LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so.
Then when I exec the phpinfo() command, I can't see the postgresql extension installed in the PDO section. I only have this :
If anyone can help ;) Thank you all !
Possible solution :
- First install all packets like this : brew install postgresql php55 php55-pdo-pgsql
- Then brew reinstall php55 --with-postgresql
And it works.. I did this before (maybe not the same order) and it didn't work, I do not know why it works now !
Solution
When you watch the phpinfo() result, you should see something something like Loaded Configuration File and *Scan this dir for additional .ini files *. The thing is there is a global php.ini file and a .ini file per extension you install.
The value for *Scan this dir for additional .ini files * is where the .ini file for the extension must be located. So just need to create a ext-pdo_pgsql.ini and load the extension with extension="path to your/pdo_pgsql.so" (mine was /usr/local/opt/php55-pdo-pgsql/pdo_pgsql.so).
And for the installation just need brew install php55 php55-pdo-pgsql postgresql
Run php -m | grep pgsql to know if pgsql exists
Follow the example in this answer. Jump to note if you have a problem with the instruction there corresponding to number 4 here.
Enter ./configure --with-pdo-pgsql="path to postgres" and return. Mine is at "/usr/local/bin".
Enter make && sudo make install and return.
Add the extension to php.ini with sudo echo "extension=pdo_pgsql.so" >> path to php.ini. Find the path using php -i | grep php.ini
That should install pdo driver for postgres
Note
It is possible that sudo make install doesn't work. It might be due to an OSX feature known as csrutil. Reboot your machine and hold down cmd + R. From the recovery inteface run csrutil disable from terminal.
Reboot again and perform the make install. Repeat same process as in the paragraph above to enable csrutil by running csrutil enable at the recovery interface's terminal.
Dumb question I think, but I have PHP 5.6.14 running on El Capitan.
I have installed xdebug with
brew install php56-xdebug
But there is no mention of xdebug in phpinfo
phpinfo reveals:
Configuration File (php.ini) Path: /etc
When I run brew install php56-xdebug again, I get
homebrew/php/php56-xdebug-2.3.3 already installed
So I'm guessing that brew has installed xdebug on a path (where?) which is for a different version of PHP which I'm not actually running.
Can somebody help me understand what brew has done, and how I can configure the version of PHP that I'm running to include xdebug.
OK, so I fixed this. Any comments welcome on whether I did it right.
1) Found where the brew install of php is using
brew info php56
This reports:
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
Update version of php loaded by apache:
sudo nano /etc/apache2/httpd.conf
Replaced
LoadModule php5_module libexec/apache2/libphp5.so
with
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
For those who use different version of php type in terminal
--> brew search xdebug
and choose yours version.
after installing your version of xdebug you've to active it by placing the installed extension path to your php.ini file.
print your phpinfo() and look for "Loaded Configuration File".
Open the file shown for "Loaded Configuration File" ( mine is /etc/php.ini ) and paste extension path anywhere you like.
for me the xdebug installed extension path is "/usr/local/Cellar/php56-xdebug/2.5.1/xdebug.so"
so i pasted {zend_extension="/usr/local/Cellar/php56-xdebug/2.5.1/xdebug.so"}.
restart your apache server and check your phpinfo() for xdebug, thats all.
I am using mac 10.8 and I have installed php 5.5. At command line php -v show version 5.5. but when I starts mac's apache server with phpinfo(), it show version 5.4.
Can anyone please help me how to make apache to use version 5.5
Thanks
find out the conf/httpd.conf and conf.d/*.conf
find the tag like this: LoadModule php5_module modules/libphp5.so
make the change to correct php installation folder like this:
LoadModule php5_module /usr/local/Cellar/php54/5.4.8/libexec/apache2/libphp5.so
This will change your php model (php version) in Apache
Search on your local desk: find / -name "libphp5.so"
Regarding the correct so file: libphp5.so not being created after compiling and prefix directory not created
[update]
http://www.howtoforge.com/centos-5.6-php53-common-conflicts-with-php-common
1) update yum to include latest php
2)
For 64bit systems, you can find the correct packages here: http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/
For 32bit systems, the correct packages are here: http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/
3)
(replace to the correct URL and file name which you want to have, check it from step "2)")
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-11.ius.el5.noarch.rpm
4) rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY
5) yum install yum-plugin-replace
6)
You can now replace your PHP old version packages with the PHP new version packages from IUS like this:
yum replace php --replace-with php55w
You can search for further php55w packages like this:
yum search php53u
If you uncommented the line LoadModule php5_module /usr/local/php5/libphp5.so in httpd.conf comment it again, then add the line export PATH=~/bin:/usr/local/php5/bin:$PATH in .bash_profile
This did the trick for me. Note: i have installed php5.5.5 via liip on OS X Mavericks