27

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?

afuzzyllama
  • 6,538
  • 5
  • 47
  • 64
David Chen
  • 271
  • 1
  • 3
  • 5

4 Answers4

66

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

Jonny White
  • 875
  • 10
  • 21
Stephen
  • 3,607
  • 1
  • 27
  • 30
  • This didn't work for me but didn't have time to dig in any further. – Mike Gifford Sep 17 '12 at 19:00
  • 2
    thanks a lot - i used this to get the php mongo driver installed with php 5.4.4 – monofonik Oct 09 '12 at 10:22
  • 3
    If you get the following `/Applications/MAMP/bin/php/php5.4.4/include/php/Zend/zend.h:51:11: fatal error: 'zend_config.h' file not found` make sure you configure php sources. i.e. in the directory where you copied all the files run ./configure – greg Jan 19 '13 at 02:41
  • Well i'm using MAMP 2.2 now, where do i get the component.zip?? – GusDeCooL Nov 12 '13 at 17:46
  • 3
    the only tweak is that MAMP_components_2.1.2 didn't have the zip for php5.5.3 so that had to be retrieved from http://www.php.net/releases/ instead. – pulkitsinghal Jan 24 '14 at 15:50
  • 1
    Thanks a lot man. You saved my life. I used this structure to get mongo driver installed with php 5.5.26 – AliRNazari Aug 17 '15 at 05:15
  • I was so sure this would work... but after running ./configure: configure: error: build test failed. Please check the config.log for details. https://dl.dropboxusercontent.com/u/17428145/config_log.txt – Sanfly Sep 24 '16 at 03:29
  • I would really like to try this solution but I cant seem to find the MAMP_component zip file, When I go to the url suggested all i get is a pkg file – Dallas Caley Sep 17 '18 at 15:02
30

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)

James Newell
  • 652
  • 8
  • 12
  • 6
    This is the simpler answer. One thing to note: rename the uncompressed PHP 5.4.10 folder to simply `php` after placing it into the `/include` directory, I was confused about that step. – Victor S May 05 '13 at 15:51
  • 1
    This answer should be accepted, it fixes the issue, is clearly explained and I guess it will work for a long time. Not like the most voted one. – TCB13 Dec 07 '14 at 17:44
  • But running these commands in the terminal don't affect the MAMP installation but the system installation of PHP which doesn't appear to help me. – zkent Oct 10 '16 at 15:37
6

This is a complement to Stephen's answer and Greg's comment

When compiling xdebug 2.3.2 for php 5.6.2 on OSX 10.10.2, I could not get rid of the

'zend_config.h' file not found

error until I added the following option to ./configure in the php folder:

./configure --without-iconv

Credits to Cameron Browning

beniguet
  • 121
  • 2
  • 3
1

PECL Modules are compiled modules, in order to install them, you need the PHP headers. You can found the headers on php.net/downloads.php make sure you download a version which match with your PHP version. Then you can follow this : Installing PHP OAuth in MAMP environment

Community
  • 1
  • 1
sonique
  • 4,539
  • 2
  • 30
  • 39