How to build the PHP rrdtool extension by hand

I think by now most sysadmin types know about rrdtool and the nice graphs it makes. I recently wanted to create some graphs by hand using PHP so I turned to the php-rrdtool extension. I found that it takes a little work to get it to compile but that could be because I'm not constantly recompiling PHP and just don't know better. You can get this module as an rpm for fedora (php-rrdtool) but I like to compile php by hand so I couldn't use it. I'm going to assume that you know how to compile PHP normally with whatever other items you want to include and that you have the rrdtool development libraries installed or have compiled and installed rrdtool from source.

Step 1. Get the PHP rrdtool source

Go to the contrib directory on the rrdtool distribution site:

There are a number of files in this directory that mention rrd. You want the one named: php_rrdtool.tgz

Step 2. Untar into the correct place

Now that you have the source go into your php source directory and then into the ext directory. So you will be somewhere like this:


Now untar the source into this directory.

Step 3. Recreate the php configuration file

There is a warning that you will get if you do not have autoconf 2.13 installed on your system when you try to do this. It is easy enough to get this version if you have fedora so that is what I did.

One tricky part to this is that I had to remove the old configuration file first before the new one could be created.

  1. Change directory to your PHP source, if you are still in the ext directory just cd ..
  2. Remove the existing configuration file
  3. If you are using autoconf 2.13 run the following command:
    PHP_AUTOCONF=autoconf-2.13 ./buildconf –force
    If you are using whatever other autoconf you have installed just run:
    ./buildconf –force
  4. You should now have a new configuration file that can be run with the –with-rrdtool option

Step 4. Test

After compiling with rrdtool you should be able to use the phpinfo() function to list the installed extensions. If everything went right you should see rrdtool listed.

Tags: ,

15 thoughts on “How to build the PHP rrdtool extension by hand

  1. Pingback: IONCANNON » PHP RRDTool tutorial

  2. Scott

    I am trying to following your instructions (thank you btw) and while everything compiles I am not seeing any mention of rrdtool during the make/install. I rebuild the config file but when I run the ./configure I don't see it. Below is autoconf and the configure I am using. Do you have any idea what the problem could be?

    [root@localhost php-5.2.0]# PHP_AUTOCONF=autoconf ./buildconf –force
    Forcing buildconf
    using default Zend directory
    buildconf: checking installation…
    buildconf: autoconf version 2.59 (ok)
    buildconf: Your version of autoconf likely contains buggy cache code.
    Running cvsclean for you.
    To avoid this, install autoconf-2.13.
    rebuilding configure
    aclocal.m4:2056: PHP_PROG_LEX is expanded from…
    rebuilding main/
    autoheader: WARNING: Using auxiliary files such as `acconfig.h', `'
    autoheader: WARNING: and `', to define templates for `'
    autoheader: WARNING: is deprecated and discouraged.
    autoheader: WARNING: Using the third argument of `AC_DEFINE' and
    autoheader: WARNING: `AC_DEFINE_UNQUOTED' allows to define a template without
    autoheader: WARNING: `acconfig.h':
    autoheader: WARNING: AC_DEFINE([NEED_FUNC_MAIN], 1,
    autoheader: [Define if a function `main' is needed.])
    autoheader: WARNING: More sophisticated templates can also be produced, see the
    autoheader: WARNING: documentation.
    aclocal.m4:2056: PHP_PROG_LEX is expanded from…

    [root@localhost php-5.2.0]# ./configure '–prefix=/usr/local/groundwork' '–exec-prefix=/usr/local/groundwork' '–with-config-file-path=/usr/local/groundwork/etc' '–libdir=/usr/local/groundwork/lib' '–with-libdir=lib' '–with-apxs2=/usr/local/groundwork/apache2/bin/apxs' '–enable-force-cgi-redirect' '–with-mod_charset' '–enable-safe-mode' '–enable-shared' '–with-ldap=/usr/local/groundwork' '–with-layout=GNU' '–enable-libxml' '–with-libxml-dir=/usr/local/groundwork' '–enable-spl' '–with-regex=php' '–disable-ipv6' '–enable-session' '–with-openssl=/usr/local/groundwork' '–with-jpeg=/usr/local/groundwork' '–with-png=/usr/local/groundwork' '–with-zlib=/usr/local/groundwork' '–with-gd=/usr
    /local/groundwork' '–enable-calendar' '–with-mnogosearch=/usr/local/groundwork' '–with-mysql=/usr' '–enable-ctype' '–with-freetype' '–enable-soap' '–with-rrdtool'

    Thank you, so much for the help!

  3. Vern Dias

    Trying to build on PHP 5.2.0 and getting the following:

    ./buildconf –force
    Forcing buildconf
    using default Zend directory
    buildconf: checking installation…
    buildconf: autoconf version 2.60 (ok)
    buildconf: Your version of autoconf likely contains buggy cache code.
    Running cvsclean for you.
    To avoid this, install autoconf-2.13.
    make: Fatal error in reader: build/, line 31: Badly formed macro assignment
    Current working directory /usr/local/nms/Source/php-5.2.0
    *** Error code 1
    The following command caused the error:
    make -s -f build/
    make: Fatal error: Command failed for target `all'

    Anyone have any ideas?

    Thanks, Vern

  4. Vern Dias

    OK, ignore the previous post. After installing autoconf 2.13, I got past this issue …..

    Right into another issue. Apparently this code is not compatible with the newer versions of RRDTOOL.

    /usr/local/nms/Source/php-5.2.0/ext/rrdtool/rrdtool.c:347: error: too few arguments to function `rrd_graph'
    make: *** [ext/rrdtool/rrdtool.lo] Error 1

    The statement in question is passing 5 arguments:

    if ( rrd_graph(argc-1, &argv[1], &calcpr, &xsize, &ysize) != -1 )

    rrd:graph is now looking for 8 arguments.

    int rrd_graph(int, char **, char ***, int *, int *, FILE *, double *, double *);

    Not really being a coder, I am at a loss as to how to fix this.


  5. Scott

    Well I got it working… For some reason with any other version of AUTOCONF (even newer versions) it will not configure correctly. I had to uninstall the autoconf rpm and compile 2.13 from source to get it to work. Once I did that your instructions were perfect! Thanks for these tips.

  6. Mark

    For rrdtool versions 1.2.x, use the CFLAG:


    It worked for my using rrdtool 1.2.15 and php 5.2.0.

  7. kotto bass

    System: Red Hat Enterprise Linux ES release 4
    Apache: 2.2.3
    PHP: 5.2.1 from source
    ImageMagick: 6.3.3

    Since I didn't want to recompile PHP, and also didn't want to downgrade autoconf to 2.13, here's my route:

    – Download and untar MagicWand
    – In MagicWand directory, run phpize
    Note: Mine is located at /usr/local/apache/php/bin/phpize
    – Type autoconf
    – Type ./configure with options.
    Note: I had to specify location of PHP config file, and directory of ImageMagick install, so I entered: ./configure –with-php-config=/usr/local/apache/php/bin/php-config –with-magickwand=/usr
    – Type make
    Note: Make creates in the modules subfolder.
    – Copy to your php modules directory from the MagickWand modules subdirectory.
    Note: My PHP modules directory is located at /usr/lib/php/modules/
    – Add '' to your php.ini file if it's not there already.
    – Restart Apache

  8. bitto

    I am running PHP server in windows environment.
    Maybe this is a stupid question: 'is there any bin source of PHP RRDtool for Windows platform?'

  9. Sébastien Cramatte

    For impatient and perfectionist It possible to build a clean php rrdtool debian package in 5mn …

    First you should use php5 packages that are always up to date …

    With the help of this little magic script

    You can build your extension …
    This script requires php5-dev, deb-helper, build-essential package and of course the
    php-rrdtool source (

    /usr/src#apt-get install php5-dev deb-helper build-essential librrd2-dev
    /usr/src#tar-xvzf php_rrdtool.tgz
    /usr/src#./debianize5 rrdtool

    Creating php5-rrdtool…
    PHP version : 5.2.3-0.dotdeb.1
    PHP Api : 20041225

    Configuring for:
    PHP Api Version: 20041225
    Zend Module Api No: 20060613
    Zend Extension Api No: 220060519

    dpkg-deb: building package `php5-rrdtool' in `../php5-rrdtool_5.2.3-0.dotdeb.1_amd64.deb'.

    Nice ;)
    Hope that will be useful …

  10. setiawan

    @Sébastien Cramatte

    The correct package name of deb-helper it should be written as debhelper (i have tried by using Debian Etch), and also i have been followed your post and it works properly..thanks..

  11. Pingback: RRDTool bindings for php5 in Ubuntu

  12. patrick oleary

    Much easier to compile if you use phpize

    cd rrdtool-php/
    ./configure –enable-rrdtool
    make install

    echo "" >> /etc/php.ini

    restart your web server or continue with command line.


    Hi! i am using this
    Quick Install of the PHP RRDTool Extension

    PHP version : 5.2.1
    Apache version : 2.x

    This extension is build for PHP 5.2.1 as downloadable from the PHP site,
    and will probably not work with other versions!
    Also it is recommended that you download the complete RRDTool package
    for further documentation:

    can you help me to work with PHP 5.3.3 i cant found any info about it

Leave a Reply

Your email address will not be published. Required fields are marked *