Installing PHP’s OAuth PECL extension on Mac OS X Snow Leopard

I recently reinstalled the operating system on my Macbook and this time around I decided to use homebrew to manage packages. Since php comes pre-installed with OS X and homebrew encourages using the pre-installed binaries, I have been using the built-in install of php, and so far so good.

But today I tried to install php’s OAuth extension, which comes as a pecl package, and I run into some errors

Before I started I updated the default pecl channel and upgraded pecl extensions already installed:

$ sudo pecl channel-update
$ sudo pecl upgrade

At this point everything looked good, so I went ahead trying to install the OAuth extension but run into the following error:

$ sudo pecl install oauth

downloading oauth-1.1.0.tgz ...
Starting to download oauth-1.1.0.tgz (44,731 bytes)
............done: 44,731 bytes
6 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
building in /var/tmp/pear-build-root/oauth-1.1.0
running: /private/var/tmp/apache_mod_php/apache_mod_php-53~1/Build/tmp/pear/temp/oauth/configure
checking for grep that handles long lines and -e... /usr/bin/grep


In file included from /private/var/tmp/apache_mod_php/apache_mod_php-53~1/Build/tmp/pear/temp/oauth/php_oauth.h:47,
             from /private/var/tmp/apache_mod_php/apache_mod_php-53~1/Build/tmp/pear/temp/oauth/oauth.c:14:
/usr/include/php/ext/pcre/php_pcre.h:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php/ext/pcre/php_pcre.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php/ext/pcre/php_pcre.h:44: error: expected specifier-qualifier-list before ‘pcre’
make: *** [oauth.lo] Error 1
ERROR: `make' failed

Hmmm. So something was wrong with the built-in PCRE package. After “googling” the problem and reading many contradicting solutions the only thing that was clear is that I needed a newer version of PCRE. So I installed PCRE using homebrew with the following command (this should also work using any other method – macports, compile from source, …):

$ brew install pcre

This worked fine. So now I tried to install the OAuth extension once again using the same comand as before:

$ sudo pecl install oauth

And this time the extension was insatlled ok, yay!!

The only thing I needed to do after that was adding the extension in my php.ini fie (by default it is in /etc/php.ini). Before the end of the php.ini file add Finally we can check if the extension is getting loaded:

$ php -i | grep -i oauth

OAuth support => enabled
source version => $Id: oauth.c 308061 2011-02-06 17:15:34Z jawed $

Note that you will need to restart the apache web server in order for the extension to be loaded in the web server.

Categories: Uncategorized
  • Fergus Gibson

    Thank you.

    Instructions are good for OS X Lion (10.7.3) as well.

  • Cal

    thanks so much!

  • Yangxinyi

    you are my hero!!!!

  • nan

    brew install php54-oauth


  • Muhammad Asif

    a complete and sample installation for Oauth for the begginers? plxxxx

  • Pingback: Install PHP OAuth Extension In Snow Leopard - Just just easy answers()

ENOISE - WordPress Hosting