- Welcome to Geeksww.com
Installing Gearman shared PECL extension for PHP on Debian/Ubuntu Linux
Please read how to install Gearman server here. Download the source code for gearman PHP extension here.
cd /tmp wget http://pecl.php.net/get/gearman-0.7.0.tgz tar xzf gearman-0.7.0.tgz cd gearman-0.7.0
Before installing the Gearman PHP extension you need to install the autoconf package first. Here is how you do it on Debian Linux.
apt-get install autoconf
After installing autoconf, run the following commands to configure, compile, test, and install Gearman PHP extension on your Debian Linux machine.
# in the gearman PECL extension directory phpize; ./configure --with-php-config=/opt/php/bin/php-config --with-gearman=/opt/gearman/; make ; make test; make install;
The Gearman module on my machine was created in /opt/php/lib/php/extensions/no-debug-non-zts-20090626/. In order to use the gearman extension you have to load the module in PHP. Add the following line in your PHP configuration file (make sure you have Gearman module gearman.so in your extensions directory).
extension=gearman.so
In order to test the extension, follow the three steps below:
- Make sure Gearman server is up and running
- Write a Gearman worker in PHP and register with Gearman server
- Write a Gearman client in PHP and run it and make sure you get the desired output
Step 1:
ps aux | grep gearmand
If you can see the Gearman deamon running then it means Gearman job server is running.
Step 2:
Here is the content for the Gearman worker program (copy from Gearman's example on the website).
<?php $worker= new GearmanWorker(); $worker->addServer(); $worker->addFunction("reverse", "my_reverse_function"); while ($worker->work()); function my_reverse_function($job) { return strrev($job->workload()); } ?>
Assuming that the filename is worker.php, do the following to register it with Gearman job server.
/opt/php/bin/php worker.php & ps aux | grep worker
Step 3:
Here is the content for the Gearman client program (copy from Gearman's example on the website).
<?php $client= new GearmanClient(); $client->addServer(); print $client->do("reverse", "Hello World!"); print "\n"; ?>
Now, run the following command to test your installation program (assuming the client resides in client.php).
/opt/php/bin/php client.php
The output should look something like below:
!dlroW olleH
Did this tutorial help a little? How about buy me a cup of coffee?
Please feel free to use the comments form below if you have any questions or need more explanation on anything. I do not guarantee a response.
IMPORTANT: You must thoroughy test any instructions on a production-like test environment first before trying anything on production systems. And, make sure it is tested for security, privacy, and safety. See our terms here.
tags cloud
popular searches
free download for mysql database server 5.1.5, bison, gearman, source code, php, install cairo, laptop, mysql, java, linux, install mysql, mysql initialization, mysql mysql, tools, ubuntu
Similar Tutorials:
- MySQL error while dropping databases
- Some Tricks used by the Linux kernel
- Simple Coding Style for PHP - Part 1/2
- How to install Python Gearman client module?
- Installing Flex (The fast lexical analyzer) on Ubuntu Linux
Tutorials in 'Operating Systems > Linux' (more):
- Bash script to compare remote directory's files using file size
- Script to transfer files to remote server with verification
- setfacl: command not found
- How to download, compile, and install CMake on Linux
- How to download, compile, and install GNU ncurses on Debian/Ubuntu Linux?
Comments (write a comment):
0 comments so far. Be the first one to leave a comment on this article.
leave a comment