HOWTO: Install Gearman (with PHP extension) on Fedora 11

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".

  1. First, go to the place you store source code
    1. cd /usr/local/src
  2. Get the source code of both gearmand and php extension
    1. wget http://launchpad.net/gearmand/trunk/0.11/+download/gearmand-0.11.tar.gz
    2. wget http://pecl.php.net/get/gearman-0.6.0.tgz
  3. Compile and install gearmand
    1. tar -xzf gearmand-0.11.tar.gz
    2. cd gearmand-0.11
    3. find . -type d | xargs -I{} chmod 755 {}
    4. yum -y install libevent libevent-devel e2fsprogs-devel autoconf automake
    5. ./configure --prefix="/usr/local/gearmand-0.11"
    6. make && make install
  4. Compile and install gearman PHP extension
    1. export PHPROOT="/path/to/your/php/installation/not-include-bin"
    2. export GEARMANROOT=" /usr/local/gearmand-0.11"
    3.  
    4. $PHPROOT/bin/phpize
    5. ./configure \
    6.   --with-php-config="$PHPROOT/bin/php-config" \
    7.   --with-gearman="$GEARMANROOT"
    8.  
    9. make && make install
  5. Update your php.ini and add this line:
    1. extension="gearman.so"
  6. You may create an init script this way:
    1. #!/bin/bash
    2. #
    3. # gearmand        Startup script for the Gearman server
    4. #
    5. # chkconfig: - 85 15
    6. # description: Gearman is a distributed job system.
    7. # processname: gearmand
    8. # config: /etc/sysconfig/gearmand
    9. # pidfile: /var/run/gearmand/gearmand.pid
    10. #
    11. ### BEGIN INIT INFO
    12. # Provides: gearmand
    13. # Required-Start: $local_fs $network
    14. # Required-Stop: $local_fs $network
    15. # Default-Start:
    16. # Default-Stop:
    17. # Short-Description: start and stop the Gearman server
    18. # Description: Gearman is a distributed job system.
    19. ### END INIT INFO o
    20.  
    21. # Configurations
    22. PREFIX="/usr/local/gearmand-0.11"
    23. USER="daemon"
    24.  
    25. # Source function library.
    26. . /etc/rc.d/init.d/functions
    27.  
    28. if [ -f /etc/sysconfig/gearmand ]; then
    29.     /etc/sysconfig/gearmand
    30. fi
    31.  
    32. if [ ! -d "/var/run/gearmand" ]; then
    33.     mkdir /var/run/gearmand
    34.     chown $USER /var/run/gearmand
    35.     chmod 700 /var/run/gearmand
    36. fi
    37.  
    38. [ -z "${PIDFILE}" ] && pidfile="/var/run/gearmand/gearmand.pid"
    39. [ -z "${LOCKFILE}" ] && lockfile="/var/lock/subsys/gearmand"
    40.  
    41. gearmand=$PREFIX/sbin/gearmand
    42. prog=gearmand
    43.  
    44. RETVAL=0
    45.  
    46. start() {
    47.     echo -n $"Starting $prog: "
    48.     daemon --pidfile=$pidfile --user=$USER $gearmand -d $OPTIONS
    49.     RETVAL=$?
    50.     echo
    51.     [ $RETVAL = 0 ] && (touch $lockfile; pgrep -f $gearmand > $pidfile)
    52.     return $RETVAL
    53. }
    54.  
    55. stop() {
    56.     echo -n $"Stopping $prog: "
    57.     killproc -p $pidfile $gearmand
    58.     RETVAL=$?
    59.     echo
    60.     [ $RETVAL = 0 ] && rm -f $lockfile $pidfile
    61. }
    62.  
    63. # See how we were called.
    64. case "$1" in
    65.         start)
    66.     start
    67.     ;;
    68.         stop)
    69.     stop
    70.     ;;
    71.         status)
    72.               status -p $pidfile $gearmand
    73.     RETVAL=$?
    74.     ;;
    75.         restart|reload)
    76.     stop
    77.     start
    78.     ;;
    79.         condrestart|try-restart)
    80.     if status -p $pidfile $gearmand >&/dev/null; then
    81.         stop
    82.         start
    83.     fi
    84.     ;;
    85.         *)
    86.     echo $"Usage: $prog {start|stop|restart|reload|condrestart|status|help}"
    87.     RETVAL=3
    88. esac
    89.  
    90. exit $RETVAL
Reference Sites