Locating the latest PHP Components
The Gearman.org page has links to the PHP code on the Downloads page, however the link is very old. The latest code is located at: http://pecl.php.net/package/gearman.
As of 23-OCT-2014, the current stable version is gearman-1.1.2.
I like to drop these files in my /opt directory, and work on them there and unball the package.
mv ~/Downloads/gearman-1.1.2.tgz /opt/.
tar xvzf gearman-1.0.2.tgz
cd gearman-1.0.2
Configuring for Build
The following commands prepared the PHP package to build on OSX Yosemite (10.10).
phpize
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212./configure
checking for grep that handles long lines and -e… /usr/bin/grep
checking for egrep… /usr/bin/grep -E
checking for a sed that does not truncate output… /usr/bin/sed
[…]
appending configuration tag “CXX” to libtool
configure: creating ./config.status
config.status: creating config.h
Building the Library
Next step is to run the compile and install the built objects:
make
/bin/sh /opt/gearman-1.1.2/libtool –mode=compile cc -I. -I/opt/gearman-1.1.2 -DPHP_ATOM_INC -I/opt/gearman-1.1.2/include -I/opt/gearman-1.1.2/main -I/opt/gearman-1.1.2 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -Wall -c /opt/gearman-1.1.2/php_gearman.c -o php_gearman.lo
mkdir .libs
[…]
Build complete.
Don’t forget to run ‘make test’.make install
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20121212/
Telling PHP about gearman
You will need to identify your relevant php.ini file, and edit it, letting PHP know where the library file are located.
Typically under OSX, this file does not exist, and it must be created.
Edit the file:
vi /etc/php.ini
Either way, make sure these two lines are in the file:
Add these lines:
include_path=.:/mnt/crawler
extension=gearman.so
DONE
At this point you should be able to reference Gearman library in your PHP code.
These lines of code, should not throw an error:
$client = new GearmanClient(); // instance
$worker = new GearmanWorker(); // instance
One thought on “Installing Gearman PHP components for OSX”