RSS
 

HOWTO build the PHP rrdtool extension?

11 Mar

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.

 
12 Comments

Posted in Linux

 

Tags: , ,

Leave a Reply

 

 
 
  1. pierre

    July 13, 2009 at 11:30 pm

    hello,

    I’m working on ubuntu 8.10 and I want to create the rrdtool.so file but when I type

    “./configure –with-php-config=/usr/bin/php-config –with-rrdtool=/usr”

    it’s not working, it says:

    checking if rrdtool specified path is valid… no
    configure: error: The specified RRDTool path is Invalid or the installation is incomplete
    Please specify another path or reinstall the rrdtool distribution

    would you tell me how to fixe this or what are those files ??

    thanx

     
  2. Sam Tseng

    July 14, 2009 at 9:44 am

    hi pierre,

    did you install rrdtool in your ubuntu? you have to install rrdtool, first. i use scientific linux. so, i don’t know how to install rrdtool on ubuntu. :)

    after you installed rrdtool. just locate the rrdtool.so. configure with “with-rrdtool=/SOMEWHERE”.

    best, s

     
  3. Miguel

    October 10, 2009 at 5:01 am

    here are the commands that i’v used to compile and install on ubuntu 8.04.1 and 9.04 (both versions work fine)

    apt-get install librrd2-dev php5-dev
    wget http://oss.oetiker.ch/rrdtool/pub/contrib/php_rrdtool.tar.gz
    tar zxvf php_rrdtool.tar.gz
    mv rrdtool /usr/include/php5/ext
    cd /usr/include/php5/ext/rrdtool
    phpize
    ./configure –with-php-config=/usr/bin/php-config –with-rrdtool=/usr
    ln -s /usr/lib/librrd.so.2 /usr/lib/librrd.so (if file exists ignore)
    make
    make install
    cd /etc/php5/conf.d/
    pico rrdtool.ini
    paste the following
    ;enable rrdtool extension module
    extension=rrdtool.so
    save and exit pico
    /etc/init.d/apache2 restart

     
  4. John

    December 16, 2009 at 4:37 am

    Thanks to your help I managed to install the darn thing. Along with the phpinfo() command it is also useful to run “php –ini” as this told me the “make install” was installing in the wrong place.

    /usr/lib/php # php –ini
    PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/extensions/rrdtool.so’ – /usr/lib/php5/extensions/rrdtool.so: cannot open shared object file: No such file or directory in Unknown on line 0

     
  5. isogashii

    May 30, 2010 at 10:59 pm

    thanks Sam for the instructions,
    I followed instructions for Ubuntu as Miguel mentioned in his comment and everything is great.

     
  6. isogashii

    June 13, 2010 at 7:34 pm

    If you get an error about rrdtool wrong path, then probably you will need to install the rrdtool development package:
    On Ubuntu (or Debian): apt-get install rrdlib-dev
    On Centos (or Redhat): yum install rrdtool-devel

    best regards ;)

     
  7. Sam Tseng

    June 14, 2010 at 10:00 pm

    thanks isogashii & Miguel for the great information. : )

     
  8. [SOLVED] Howto build the PHP rrdtool extension :: Kelvin Tan - Lucene Solr Nutch Consultant

    October 10, 2010 at 12:53 am

    [...] Posted by Kelvin on 09 Oct 2010 at 11:52 am | Tagged as: programming The definitive answer is here: http://www.samtseng.liho.tw/~samtz/blog/2009/03/11/howto-build-the-php-rrdtool-extension/ [...]

     
  9. P_A

    December 9, 2010 at 3:19 am

    Thanks, it worked great, before starting the steps you mentioned I just did on ubuntu:

    sudo apt-get install rrdtool librrd-dev php5-dev

    Keep it up!

     
  10. Sam Tseng

    December 9, 2010 at 7:21 am

    thanks for the help.. ubuntu is quite friendly. XD

     
  11. Install PHP RRDtool – Ubuntu 9.10 | Networking Blog

    March 4, 2011 at 10:57 pm

    [...] tutorial is based on: http://www.samtseng.liho.tw/~samtz/blog/2009/03/11/howto-build-the-php-rrdtool-extension/ Leave a comment | Trackback Related PostsNo Related Post No comments [...]

     
  12. Install PHP RRDtool – Ubuntu 9.10 « Maxliner Site

    September 27, 2011 at 7:14 pm

    [...] tutorial is based on: http://www.samtseng.liho.tw/~samtz/blog/2009/03/11/howto-build-the-php-rrdtool-extension/ [...]