HOWTO: Install Gearman (with PHP extension) on Fedora 11
December 19, 2009
This is brief instruction for you to install gearmand and gearman's PHP extension on a Fedora 11 server.
It is assumed that you have a valid PHP installed either by compilation or RPM. You need to prepare your own PHP installation path first. In RPM case, it would be "/usr". If you compiled your own PHP and didn't configured your own PREFIX, you may try "/usr/local".
- First, go to the place you store source code
- cd /usr/local/src
- Get the source code of both gearmand and php extension
- wget http://launchpad.net/gearmand/trunk/0.11/+download/gearmand-0.11.tar.gz
- wget http://pecl.php.net/get/gearman-0.6.0.tgz
- Compile and install gearmand
- tar -xzf gearmand-0.11.tar.gz
- cd gearmand-0.11
- find . -type d | xargs -I{} chmod 755 {}
- yum -y install libevent libevent-devel e2fsprogs-devel autoconf automake
- ./configure --prefix="/usr/local/gearmand-0.11"
- make && make install
- Compile and install gearman PHP extension
- export PHPROOT="/path/to/your/php/installation/not-include-bin"
- export GEARMANROOT=" /usr/local/gearmand-0.11"
- $PHPROOT/bin/phpize
- ./configure \
- --with-php-config="$PHPROOT/bin/php-config" \
- --with-gearman="$GEARMANROOT"
- make && make install
- Update your php.ini and add this line:
- extension="gearman.so"
- You may create an init script this way:
- #!/bin/bash
- #
- # gearmand Startup script for the Gearman server
- #
- # chkconfig: - 85 15
- # description: Gearman is a distributed job system.
- # processname: gearmand
- # config: /etc/sysconfig/gearmand
- # pidfile: /var/run/gearmand/gearmand.pid
- #
- ### BEGIN INIT INFO
- # Provides: gearmand
- # Required-Start: $local_fs $network
- # Required-Stop: $local_fs $network
- # Default-Start:
- # Default-Stop:
- # Short-Description: start and stop the Gearman server
- # Description: Gearman is a distributed job system.
- ### END INIT INFO o
- # Configurations
- PREFIX="/usr/local/gearmand-0.11"
- USER="daemon"
- # Source function library.
- . /etc/rc.d/init.d/functions
- if [ -f /etc/sysconfig/gearmand ]; then
- /etc/sysconfig/gearmand
- fi
- if [ ! -d "/var/run/gearmand" ]; then
- mkdir /var/run/gearmand
- chown $USER /var/run/gearmand
- chmod 700 /var/run/gearmand
- fi
- [ -z "${PIDFILE}" ] && pidfile="/var/run/gearmand/gearmand.pid"
- [ -z "${LOCKFILE}" ] && lockfile="/var/lock/subsys/gearmand"
- gearmand=$PREFIX/sbin/gearmand
- prog=gearmand
- RETVAL=0
- start() {
- echo -n $"Starting $prog: "
- daemon --pidfile=$pidfile --user=$USER $gearmand -d $OPTIONS
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && (touch $lockfile; pgrep -f $gearmand > $pidfile)
- return $RETVAL
- }
- stop() {
- echo -n $"Stopping $prog: "
- killproc -p $pidfile $gearmand
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && rm -f $lockfile $pidfile
- }
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status -p $pidfile $gearmand
- RETVAL=$?
- ;;
- restart|reload)
- stop
- start
- ;;
- condrestart|try-restart)
- if status -p $pidfile $gearmand >&/dev/null; then
- stop
- start
- fi
- ;;
- *)
- echo $"Usage: $prog {start|stop|restart|reload|condrestart|status|help}"
- RETVAL=3
- esac
- exit $RETVAL