HOWTO build the PHP rrdtool extension?

This HOWTO is based on SL5, RHEL5, CentOS 5. (rrdtool-1.2.23-1.el5.rf.x86_64, rrdtool-1.2.23-1.el5.rf.i386)

STEP 1 : Go to http://oss.oetiker.ch/rrdtool/pub/contrib/ to get the PHP rrdtool source : php_rrdtool.tar.gz

STEP 2 : Extract the php_rrdtool.tar.gz file into php extensions directory(/usr/include/php/ext/). Please use the following commands :

# tar zxvf php_rrdtool.tar.gz
# mv rrdtool /usr/include/php/ext/

STEP 3 : Generate configure files in order to build the PHP rrdtool. In rrdtool directory, run phpize. Please follow the below commands:

# cd /usr/include/php/ext/rrdtool
# phpize
# ./configure --with-php-config=/usr/bin/php-config --with-rrdtool=/usr

Notes : Make sure you have librrd.so file in library. If you don’t have that file, you can do a symbol link as bellow :

# ln -s /usr/lib/librrd.so.2 /usr/lib/librrd.so

STEP 4 : Build the PHP rrdtool. Just use make and make install commands.

# make
/bin/sh /usr/include/php/ext/rrdtool/libtool --mode=install cp ./rrdtool.la /usr/include/php/ext/rrdtool/modules
cp ./.libs/rrdtool.so /usr/include/php/ext/rrdtool/modules/rrdtool.so
cp ./.libs/rrdtool.lai /usr/include/php/ext/rrdtool/modules/rrdtool.la
PATH="$PATH:/sbin" ldconfig -n /usr/include/php/ext/rrdtool/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/include/php/ext/rrdtool/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).

# make install
Installing shared extensions:     /usr/lib64/php/modules/

STEP 5 : Configure rrdtool.so in php configuration file.

# cd /etc/php.d/
# vi rrdtool.ini
; Enable rrdtool extension module
extension=rrdtool.so

STEP 6 : Restart apache web services.

# service httpd restart

After compiling and installing rrdtool you should be able to use the phpinfo() function to list the installed extensions.


You should see rrdtool in phpinfo page.

Leave a Reply

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

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.