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:
http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/contrib/

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:

/usr/local/src/php-5.1.3/ext/

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: ,

Leave a Reply

Your email address will not be published.