Menu
Dec 23, 2014 The PEAR piece was left over from an older version of the guide that utilized PEAR's `pecl` command. I have updated the guide accordingly. Comment by: Anant on Aug. Install PHP OCI8 extension for Codeigniter on Mac OSX Working on a DBA dashboard using Codeigniter and Bootstrap, the most popular platform to build professional looking web apps. To make easy development, I installed MAMP on my MAC, so I can have an environment with me on the go.
- Installing Php Pear And Pecl Extensions On Mamp For Mac Pro
- Installing Php Pear And Pecl Extensions On Mamp For Mac Download
The problem
I need to use runkit to work some magic during tests and, running MAMP as my local server stack, I do not have it built-in and ready.
Trying to use the command
Trying to use the command
Will generate an error while trying to include the
To run
The combination of the two is not anywhere I can find on the web so I need to build it from source.
php.h
file.To run
runkit
in my code I need a version of it compiled on my system (Mavericks) and for my PHP version.The combination of the two is not anywhere I can find on the web so I need to build it from source.
Works on other versions too I guess
Since my solution involves building PHP from source it should work on other Mac and PHP versions too. In the examples I will use PHP version
5.3.27
but any version will do.Install Xcode
Available for free on the AppStore I install it and that’s done. In earlier versions Command Line Tools had to be manually downloaded but in Maverick version those seem to be installed by default so one less step.
Add the version of php, pear and pecl that comes with MAMP to the path
I do this to be able to invoke any one of the three above commands without having to specify the full path to MAMP nested folder. Using any text editor I simply tell my machine, a Mac, to look for
php
, pear
and pecl
in MAMP folder before resorting to the versions that came bundled with Mavericks.Download, position and configure PHP source
MAMP is shipped as ready to run and hence will not come with the source files to build PHP from scratch. I need those and a quick Googling turns out the source for my PHP version of choice.
After the downloading it I position the folder containing the extracted files, named in my case
After the downloading it I position the folder containing the extracted files, named in my case
php-5.3.27
, in MAMPPlease note that there is an implicit renaming of the folder too: from
php-5.3.27
to php
. After this I cd
to the just moved folder and run configure
Download, configure and build runkit
I use zenovich’s version of
runkit
and, after downloading it to the Desktop build it with the chained commandsThe prize is now located in the
modules
folder and I will copy it to the MAMP extension folder Gt 430 driver windows 10.This is the default folder MAMP will look into for extensions and will make any file in it available in code. MAMP is already configured to look into the folder for modules but wil not load them.
Load runkit at code time
I can now call
runkit
using the dl('runkit.so')
instruction in place of adding it to the default loaded extensions MAMP will load each time. In any case the way to this second option is to add a line to the php.ini
file of the used PHP version like this- Comments:
- 14
- Tags:
- Walkthrough
- PHP
- MacOS
- Mac OS X
- Extensions
- By Jesse Donat on
- (Updated: )
Should you run into errors related to missing
php.h
or other .h
files, you should check out my post on fixing missing headers on macOS Mojave.These directions are for working with the native installation of PHP. Your results may vary if you are using a brew, MAMP or otherwise installed version of PHP - I do not recommend this for those cases.
Important: As you are altering the built in version of PHP, you will need to ensure you have disabled System Integrity Protection before you begin. You can find instructions on how to do this here: How to: Disable macOS System Integrity Protection.
This was previously dedicated to installing the Mcrypt extension specifically but in reality can be used to install any of the following extensions distributed with the PHP source.
We need install the required dependencies. If you are not already using Homebrew you will need it.
For certain extensions like mcrypt you may additionally need to install additional libraries such as:
Next we will download the PHP source. Verify the exact version of PHP you are running. This can be retrieved as follows. The version is highlighted.
Now we move into a working directory and download the source making sure to update the following for the version from above.
Now we will compile and test the extension.
If all that goes well finally we'll need to add the following to our php.ini - I usually add at it at the end of the file.
You can verify your installation with the following:
Lastly, depending on your setup now you may want to restart apache.
Comment by: Kevin on
Comment by: Jonathan on
Thank you for this. I must've tried half a dozen different guides doing all sorts of strange things in my attempts to install mcrypt. This guide was the most clear, concise, and easy to follow. I am not certain what PEAR is being used for though.
Comment by: Jesse G. Donat on
Good catch! The PEAR piece was left over from an older version of the guide that utilized PEAR's `pecl` command. I have updated the guide accordingly.
Comment by: Anant on
Thank you , steps are pretty simple and its working
Comment by: kmabas on
Don't forget disable SIP in El capitan and earlier and if 'phpize' doesn't work, is because you need to install xcode cli tools
Comment by: DMITRY LOBURETS on
Great thank you! This is the only thing after an hour of googling which help to me!
Comment by: Umberto on
Hello there.
I would like to point some additional steps I had to do to get it set:
1. copy /etc/php.ini.default to /etc/php.ini
2. locate the mcrypt.so (in my case it was in
/usr/local/Cellar/php56-mcrypt/5.6.30_4/mcrypt.so
https://stackoverflow.com/questions/14357107/installing-mcrypt-on-osx-10-8-2-php-5-3-15-with-homebrew
I would like to point some additional steps I had to do to get it set:
1. copy /etc/php.ini.default to /etc/php.ini
2. locate the mcrypt.so (in my case it was in
/usr/local/Cellar/php56-mcrypt/5.6.30_4/mcrypt.so
https://stackoverflow.com/questions/14357107/installing-mcrypt-on-osx-10-8-2-php-5-3-15-with-homebrew
Comment by: Umberto on
Hello there.
I would like to point some additional steps I had to do to get it set:
1. copy /etc/php.ini.default to /etc/php.ini
2. locate the mcrypt.so:
/usr/local/Cellar/php56-mcrypt/5.6.30_4/mcrypt.so
3. add the line below to php.ini:
extension = /usr/local/Cellar/php56-mcrypt/5.6.30_4/mcrypt.so
After that I would have opencart running well
https://stackoverflow.com/questions/14357107/installing-mcrypt-on-osx-10-8-2-php-5-3-15-with-homebrew
I would like to point some additional steps I had to do to get it set:
1. copy /etc/php.ini.default to /etc/php.ini
2. locate the mcrypt.so:
/usr/local/Cellar/php56-mcrypt/5.6.30_4/mcrypt.so
3. add the line below to php.ini:
extension = /usr/local/Cellar/php56-mcrypt/5.6.30_4/mcrypt.so
After that I would have opencart running well
https://stackoverflow.com/questions/14357107/installing-mcrypt-on-osx-10-8-2-php-5-3-15-with-homebrew
Comment by: shikha on
![Pecl Pecl](https://imgs.developpaper.com/imgs/2017032214501025.jpg)
after running make cmd, getting this error
/tmp/php-7.1.19/ext/mcrypt/mcrypt.c:25:10: fatal error: 'php.h' file not found
how to solve this one?
please help
/tmp/php-7.1.19/ext/mcrypt/mcrypt.c:25:10: fatal error: 'php.h' file not found
how to solve this one?
please help
Comment by: Jesse G Donat on
Mojave installation messes up some peoples header files for some unknown reason.
You can pretty easily reinstall them following my post here.
You can pretty easily reinstall them following my post here.
Comment by: Greg on
Hi, I've try with intl extension on 'sudo make isntall', I have an 'Operation not permitted' error :
MacBook-Pro-de-Greg-2:intl greg$ sudo make install
Password:
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20160303/
cp: /usr/lib/php/extensions/no-debug-non-zts-20160303/#INST@47872#: Operation not permitted
make: *** [install-modules] Error 1
MacBook-Pro-de-Greg-2:intl greg$ sudo make install
Password:
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20160303/
cp: /usr/lib/php/extensions/no-debug-non-zts-20160303/#INST@47872#: Operation not permitted
make: *** [install-modules] Error 1
Comment by: Jesse G Donat on
I think odds are good you have System Integrity Protection turned on.
I updated my post to note that you need to turn it off first, along with a link to directions on how to do so.
I updated my post to note that you need to turn it off first, along with a link to directions on how to do so.
Installing Php Pear And Pecl Extensions On Mamp For Mac Pro
Comment by: Ben on
Outcome: -bash: syntax error near unexpected token
Installing Php Pear And Pecl Extensions On Mamp For Mac Download
Comment by: Jesse G Donat on
Did you replace the `{{php-version}}` with your PHP Version - something like: