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
when I tried to run
sudo ./pecl install -a ssh2 channel://pecl.php.net/ssh2-0.11.3
from that directory, I got the error:
Notice: unserialize(): Error at offset 267 of 1133 bytes in Config.php on line 1050 PHP Notice: unserialize(): Error at offset 267 of 1133 bytes in /Applications/MAMP/bin/php/php5.3.6/lib/php/PEAR/Config.php on line 1050 ERROR: The default config file is not a valid config file or is corrupted.
I found out later that the error is most likely caused by the file
So if you get an error, try doing
sudo 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 from Apple Developer Connection
- Download the complete PHP source code from 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 downloading 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 libssh2
directory to /usr/local/lib/
After you’ve successfully ran the the PECL install, it should tell you to Add the line
to the Dynamic Extensions area of your php.ini file. I believe both MAMP and MAMP PRO allow you to edit the necessary ini through File>Edit Template.
Lastly, restart apache. You should be able to see the SSH2 extension when you load a phpinfo() page.
I’m not sure how I have PHP CLI working in OSX but if you’ve followed the steps above and try to verify the extension install with through the cli, it won’t show up.
$ php -a
This is because (if you’re also using MAMP PRO) the binaries are different. The good news is that you can make things happy in 3 easy steps
- run `sudo ln -s /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/ssh2.so /usr/lib/php/extensions/no-debug-non-zts-20090626/ssh2.so` in the terminal.
- Edit the /etc/php.ini (copy /etc/php.ini.default if /etc/php.ini doesn’t exist) like you did for the MAMP php.ini(s)
Note: I still have to install PHPUnit into my current setup so that may or may not elicit another blog post.
- Using MySQL Workbench with MAMP (phpprotip.com)
Looking for something?
Use the form below to search the site:
Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!