Installing Gearman on CentOS 6.2
The latest Gearman version available in the EPEL repository is not always up to date. The latest version of Gearman at this moment is 1.1.6. So, here is the procedure to install the Latest version from source. It’s easy to install but I’ve run into some problems while installing that in an amazon EC2 large instance. So added the troubleshooting parts too.
Install Gearman’s dependencies
Use yum to install the dependencies that Gearman needs:
yum install uuid-devel libuuid libuuid-devel uuid boost-devel libevent libevent-devel
Download the latest gearmand source
# cd /usr/share/
# wget https://launchpad.net/gearmand/1.2/1.1.6/+download/gearmand-1.1.6.tar.gz
Untar, compile and install
Now unpack it (gearmand version 1.1.6 in this example):
# tar -xvzf gearmand-1.1.6.tar.gz
and then compile and install it:
# cd gearmand-1.1.6
# ./configure && make && make test && make install
That’s all, gearman is installed and ready to use.
Unfortunately, for my case it shows couple of errors and then terminated. Here is how I resolved that.
1. While configuring, i’ve got the following error:
checking for the toolset name used by Boost for g++… configure: WARNING: could not figure out which toolset name to use for g++
checking for Boost headers version >= 1.39.0… no
configure: error: cannot find Boost headers version >= 1.39.0
Solution: The reason is either you don’t have the “boost-devel” package installed, but I had already installed it before in the first phase (yum install boost-devel). For my case, it seems that I didn’t install g++ (found in the gcc-c++ package). So Installing the gcc-c++ package fixed the issue. ref: Building Gearman 0.27 on CentOS 6
# yum install gcc-c++
2. Now it proceeds further but throws error while running “make”, while compiling the libhostile.c file:
libhostile/function.c: In function ‘print_function_cache_usage’:
libhostile/function.c:54:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
libhostile/function.c:54:3: note: use option -std=c99 or -std=gnu99 to compile your code
make: *** [libhostile/libhostile_libhostile_la-function.lo] Error 1
make: *** Waiting for unfinished jobs….
libhostile/poll.c: In function ‘poll’:
libhostile/poll.c:93:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
libhostile/poll.c:93:9: note: use option -std=c99 or -std=gnu99 to compile your code
make: *** [libhostile/libhostile_libhostile_la-poll.lo] Error 1
make: Leaving directory `/usr/share/gearmand-1.1.6′
make: *** [all] Error 2
The solution was hard to find, but as it suggests it is failing because the -std=c99 is required. The libhostile C code requires C99. There are some bug reports for this, but forcing the CFLAGS environment variable will fix this.
Solution: Run ./configure –help, you will see a list of configurable variables.
[.. gearmand-1.1.6]# ./configure –help
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L
if you have libraries in a
I tried to specify gnu99 library,
# CFLAGS=-std=gnu99 ./configure && make && make test && make install
or you can also use c99, and it works:
# CFLAGS=-std=c99 ./configure && make && make test && make install
3. Finally I ran into the mysql.h header file missing error while in “make”:
libgearman-server/plugins/queue/mysql/queue.cc:49:19: fatal error: mysql.h: No such file or directory
Solution: The solution is simple, i had missing “mysql-devel” package. So installing it solves the problem.
# yum install mysql-devel
so now you can run the gearman as below:
# gearmand -d -u root
Next to code Gearman’s client and worker process you need to install Gearman PHP extension. It’s very easy and straightforward, to do so, please follow this link: Installing Gearman PHP extension on CentOS
Hope that it’ll help someone.