Skip to content

Fun with PHP

April 18, 2006

I consider myself somewhat experienced with PHP, having used it for several years with an open source adserver. I’ve run into and dealt with issues with webserver and MySQL integration and performance tuning. I’ve got a fairly tuned php.ini, and serveral server builds for various platforms.

So I thought it would be trivial to try out Zabbix, an open source monitoring system based on PHP/MySQL to evaluate its usefulness for my web engineering team. Should be a piece-o-cake since I’ve already got MySQL, phpMyAdmin, Apache, along with a fairly current PHP Apache module, right? Wrong!

Actually, I was able to get 90% of the way there thanks to this HOWTO, but was unable to get graphs/charts to work- and we all know how important the eye candy is when you’re trying to impress the boss (and myself in this case :-/).

Mr. Watt was kinda enough to point out the issue while trying to point his agent at my freshy instally server:

Fatal error:  Call to undefined function imagecreate() in ./include/classes/ on line 641

It seems my system was missing GD, and more importantly PHP was not explicitly compiled with GD support. After a bit of pain getting GD compiled, I was hoping I could just build a dynamic PHP extension to include GD support- no luck. Mismatched PHP versions (between the source version I downloaded and the one I had already installed on my system) meant I’d have to rebuild PHP from scratch. Sigh…

Some time later, I’ve come up with the magic config line:

[~/w/php-5.1.2]./configure --with-gd=shared --with-zlib --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql

I was finally at the point where my simple PHP GD test:

header("Content-type: image/png");
$im = @imagecreate(200, 50)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 80, 20,  "GD works!", $text_color);

produced a gloriously simple image:

A webserver restart later, and I’m able to produce my first Zabbix graph:

Zabbix looks pretty sweet- and I’m stoked there are apps like this that are open source, like Nagios– but I gotta wonder how many people would have the knowledge or patience to go through with an install like that. (Even Linux guys with pre-installed builds or readily available RPMs had their share of problems, from what Google reveals.) I’ve built out my system over many years, and have a working GCC, PHP, countless libraries (libpng, zlib, etc…) and it still took a considerable effort to get it functioning. And whats worse, I’m just days away from cutting over from my current sparc desktop to my new opteron based desktop. I’ll have to rebuilt it *all* from scratch.

I’m all for using the right tool for the right job- you’ll find Perl, Python, PHP, and C books on the my shelf next to the Java books (so you LAMP zealots take it easy), but this space seems like the ideal place for Java. Had this stack been Java based, it likely would have taken a fraction of the time to install, and it would have been that much easier to redeploy on my new platform…


From → Interweb

  1. Roy permalink

    Kind of makes me glad I haven’t had to compile anything since about 1992.

  2. lee permalink

    There is a java based alternative, but it *IS* a real hard install. OpenNMS. Have a google, and investigate…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: