Having problems while try to install OAUTH with PECL in MAMP on mac OS lion

i am new to setting php servers, and i had go though other related post, seems like nobody have the same error as i have. I am using MAMP 2.0.2, and running PHP 5.3.6, and I was trying to install oAuth on my local MAMP, using following commands:

$ cd /Applications/MAMP/bin/php/php5.3.6/bin
$ ./pecl install oauth

however, it return such error:

Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.

What is happening? PECL is bundled in MAMP, which should be working out of the box....

Update:

I read a post elsewhere suggest that the config file's data, which holds the install paths are in-correct, so i changed some value in the following file :

/Applications/MAMP/bin/php/php5.3.6/conf/pear.conf

Then, i use the command:

$ ./pecl install oauth

Which it starts download and unpack, but when it try to install, it gives:

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/libtool --mode=compile cc  -I. -I/private/tmp/pear/temp/oauth -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/include -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/main -I/private/tmp/pear/temp/oauth -I/Applications/MAMP/bin/php/php5.3.6/include/php -I/Applications/MAMP/bin/php/php5.3.6/include/php/main -I/Applications/MAMP/bin/php/php5.3.6/include/php/TSRM -I/Applications/MAMP/bin/php/php5.3.6/include/php/Zend -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2 -Wall -g   -c /private/tmp/pear/temp/oauth/oauth.c -o oauth.lo
mkdir .libs
cc -I. -I/private/tmp/pear/temp/oauth -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/include -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/main -I/private/tmp/pear/temp/oauth -I/Applications/MAMP/bin/php/php5.3.6/include/php -I/Applications/MAMP/bin/php/php5.3.6/include/php/main -I/Applications/MAMP/bin/php/php5.3.6/include/php/TSRM -I/Applications/MAMP/bin/php/php5.3.6/include/php/Zend -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -Wall -g -c /private/tmp/pear/temp/oauth/oauth.c  -fno-common -DPIC -o .libs/oauth.o
In file included from /private/tmp/pear/temp/oauth/oauth.c:14:
/private/tmp/pear/temp/oauth/php_oauth.h:20:10: 

fatal error: 'php.h' file not found

include "php.h"
     ^

1 error generated.

make: *** [oauth.lo] Error 1

ERROR: `make' failed

Again, what is happening?


Solution 1:

I know this is old but I found this question while having a similar issue.

MAMP doesn’t ship with a bunch of the PHP sources

  • Download MAMP components and configure
  • URL: http://www.mamp.info/en/downloads/index.html (i.e. MAMP_components_2.0.2.zip)
  • Unpack your MAMP_components_2.0.2.zip
  • Identify your php-5.x.x.tar.gz file (where 5.x.x is your version of PHP)
  • If you are using php > 5.4.10 then download the sources from http://php.net/releases as they are not in the MAMP components download (credit pulkitsinghal in comments)
  • Create directory for your PHP sources:

    mkdir -vp /Applications/MAMP/bin/php5/include

  • Untar php-5.x.x.tar.gz into /Applications/MAMP/bin/php/php5.*/include or /Applications/MAMP/bin/php5/ include:

    tar zxvf php-5.x.x.tar.gz -C /Applications/MAMP/bin/php/php5.?.??/include

  • Rename your php-5.x.x directory to php (without the version numbering):

    mv /Applications/MAMP/bin/php/php5.2.17/include/php-5.?.?? /Applications/ MAMP/bin/php/php5.2.17/include/php

  • Configure PHP sources (it’ll create necessary files i.e. zend_config.h, tsrm_config.h, etc.):

    cd /Applications/MAMP/bin/php/php5.?.??/include/php

    ./configure

The process was for another fix but this resolved the issues with php.h not being found

Credit to where I found the answers - :

Thomas Hunter Blog

Google Doc detailing process

Solution 2:

I had the same problem whilst trying to pecl install -f ssh2 with MAMP.

Here's how I fixed it:

  1. MAMP doesn't provide the source code archive for PHP 5.4.10 so download it from php.net
  2. Extract the source code archive to /Applications/MAMP/bin/php/php5.4.10/include/php
  3. Run ./configure to configure the source code for your platform (without this step the pecl install will fail looking for a bunch of header files)
  4. Retry your pecl install

(much thanks to Stephen's answer which is pretty much the same)