Our Blog. We have some things we'd like to share.

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.

Tagged:

4 Responses to “How to build the PHP rrdtool extension by hand”

  1. 1

    October 15th, 2006 @ 7:02 pm Sébastien Cramatte Hollered:

    I’ve tried to compile the extension under debian sarge with php 5.1.6 packages from dotdeb.org and rrdtool 1.2 package from http://www.backports.org

    When I do a phpize and just after ./configure it tell me that not found rrdtool header …

    I’ve tried ./configure –include=/usr/src/rrdtool-1.2.11/src without succes …

    # ./configure
    checking for egrep… grep -E
    checking for a sed that does not truncate output… /bin/sed
    checking for gcc… gcc
    checking for C compiler default output file name… a.out
    checking whether the C compiler works… yes
    checking whether we are cross compiling… no
    checking for suffix of executables…
    checking for suffix of object files… o
    checking whether we are using the GNU C compiler… yes
    checking whether gcc accepts -g… yes
    checking for gcc option to accept ANSI C… none needed
    checking whether gcc and cc understand -c and -o together… yes
    checking if compiler supports -R… no
    checking if compiler supports -Wl,-rpath,… yes
    checking build system type… i686-pc-linux-gnu
    checking host system type… i686-pc-linux-gnu
    checking target system type… i686-pc-linux-gnu
    checking for PHP prefix… /usr
    checking for PHP includes… -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext
    checking for PHP extension directory… /usr/lib/php5/20050922
    checking for PHP installed headers prefix… /usr/include/php5
    checking for re2c… no
    configure: WARNING: You will need re2c 0.9.11 or later if you want to regenerate PHP parsers.
    checking for gawk… gawk
    checking for rrdtool support… yes, shared
    checking for rrdtool header files in default path… not found
    configure: error: Please reinstall the rrdtool distribution

  2. 2

    December 1st, 2006 @ 4:07 pm Jason Fesler Hollered:

    Thank you for posting this – I was going a bit nuts putting two and two together from php-rrdtool.tgz’s limited documentation.

  3. 3

    December 4th, 2006 @ 9:31 pm Scott Howe Hollered:

    BTW – 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.

  4. 4

    May 5th, 2007 @ 3:48 pm Marinko Hollered:

    Hi. Very nice article.
    I have one question about php and rrdtool. I need php script for collecting data from local router so I can use it for billing software to see traffic for specific host in MB and in direction (up and down.)

    Any ideas?

Leave a Response


Cincinnati 513.298.1865

Virginia 7875 Promontory Court Dunn Loring, VA 22027

Kentucky 12910 Shelbyville Road Suite 310 Louisville, KY 40243 502.245.6756

© 2010 Mission Data