MAMP PRO, PECL, SSH2, and OSX CLI (AKA acronym madness)
Or madness in general. So as you may know, I've started using PHPStorm to work locally. I decided to dust off an old SSH2 wrapper I wrote and play with how PHPStorm uses PHPUnit and does refactoring. I knew that I would have to install the extension via PECL and was like, "Oh it can't be that bad to do it through MAMP PRO" and as you may have guessed, I sealed my own fate for a couple hours. One thing I can say is that, even though I use a convenient app like MAMP PRO to set up my local development environment, I'm glad my sysadmin-fu is up to snuff enough to fly without the conveniences because after this ordeal, I feel like I might as well have made my MAMP stack from scratch with all the hoops I jumped tonight. (I'm pretty sure that last sentence is also one of the worst run-on sentences ever).
The first thing you need to know is that the PECL command is located at the directory/Applications/MAMP/bin/php/php5.3.6/bin
when I tried to runsudo ./pecl install -a ssh2 channel://pecl.php.net/ssh2-0.11.3
from that directory, I got a memory error. I found out later that the error is most likely caused by the file/Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
So if you get an error, try doingsudo mv /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf.bkp
If you're still getting the error, you can also the following:
- Install Xcode Tools from your Mac OS X DVD or download it fromAApple Developer Connection
- Download theAcomplete PHP source codeAfrom php.net into /Applications/MAMP/bin/php/php5.3.6/
- Create an include directory in the the php5.3.6 directory.
- Unzip/tar the php source archive and move it to/Applications/MAMP/bin/php/php5.3.6/include/
- Rename the php source directory to just php (so then it will look like /Applications/MAMP/bin/php/php5.3.6/include/php)
- In Terminal use the following commands to compile the extension:
That should allow you to run the PECL command however, you will probably get a complaint about not having libssh installed. So you will have to
- go download libssh2 (http://www.libssh2.org/). As much as I like git, I recommend Adownloading the latest release tarball instead of cloning the repo. For some reason, I got a version incompatibility error when trying to run the PECL install with the repo version and had to do all these steps over with the tarball release version.
- unzip the directory and cd to the upacked directory in the terminal.
- run: ./configure; make all install;
libssh should compile and place the output file in src/*.o
- copy all headers from the include folder within the libssh2 directory to
- copy all compiled files (*.o) from the src folder within the lib
Truncated by Planet PHP, read more at the original (another 2880 bytes)