Showing posts with label db2. Show all posts
Showing posts with label db2. Show all posts

2008-09-21

Quick DB2 Express-C 9.5 Update

A while pack, I started a post series about getting Drupal to work with DB2 Express-C 9.5 under Ubuntu. Unfortunately, right after jumping into this project, I updated my laptop from Ubuntu Gutsy Gibbon (7.10) to Hardy Heron (8.04). During this process, DB2 completely broke itself. Not only did it break itself, it broke itself in such a way that it couldn't even be un-installed through apt-get.

I recently found instructions for how to force removal of a broken DB2 package on Hardy Heron. This is good news, because it seems that about 6 months later, there's finally a working version of Express-C 9.5 for Hardy Heron!

Let's just hope that the db2exc package for Intrepid Ibex (8.10) comes out in a more timely manner :)

2008-04-23

Part 2: Drupal 6.2 and DB2 Express-C 9.5 on Ubuntu 7.10

This is part 2 in my series on getting Drupal 6.2 and DB2 Express-C 9.5 to play nicely with each other. In the first part, I installed DB2 Express-C 9.5. In this part, I'll look at getting Apache/PHP5 setup and DB2 working from within PHP.

Step 1: Configuring DB2. There were some additional configuration steps needed for DB2, which are detailed on the developerWorks forum. There were some superfluous steps, but the worst you're going to do is overwrite something with the same thing. In particular, all the user accounts were set up already. If you're not familiar with DB2, you can issue commands from the shell, in the form of:

db2 "create database testdb"
but just make sure you're running these commands as the user db2inst1, or you source db2inst1's db2profile. If you can create `testdb`, then DB2 is working correctly.

Step 2: Install Apache httpd 2.2 and PHP 5.2. The Ubuntu Guide has information on setting up Apache and PHP, but the quick and dirty steps are:
sudo apt-get install apache2
sudo apt-get install php5 libapache2-mod-php5
sudo /etc/init.d/apache2 restart
Step 3: Install DB2 support for PHP. There is a PECL module for IBM DB2, which can be installed with PHP's PEAR (PHP Extension and Application Repository, like apt-get for Ubuntu).
sudo apt-get install php-pear
sudo pecl install ibm_db2
When I first ran this, I got the error: "sh: phpize: not found". After doing a quick search, I realized that I needed the PHP development files to be able to compile the DB2 driver:
sudo apt-get install php5-dev
After the module is compiled, it will ask you where your installation of DB2 is. In my experience, it wouldn't believe me when I told it where DB2 was installed to. Luckily, it ended up not mattering. When you get to this part of the PECL install, just hit Ctrl-C.

Next, I needed to configured PHP to use the IBM DB2 driver. In `/etc/php5/apache2/php.ini`, go to the extension section and add:
extension_dir="/opt/ibm/db2/V9.5/dsdriver/php32"
extension="extension=ibm_db2_5.2.1.so"
Note: correct the path if you have your module installed somewhere else; do a `locate ibm_db2_5.2.1.so`)

After making the changes, I reloaded Apache:
sudo /etc/init.d/apache2 reload
Verify that the module is loaded by making a quick PHP page in /var/www/ with the content:
<?php phpinfo(); ?>
and make sure there's a DB2 driver loaded. I started playing around with DB2 in PHP, but it was getting late and I decided to put that off for another day. IBM has some information on developing PHP5 for DB2, but it's barebones at best. I'll post a sample script next time.

Ok, so at this point, I have Apache, PHP, and DB2 Express-C 9.5 all installed and playing well with each other. In the next article in this series, I'll look at getting Drupal 6.2 to use DB2 on the back end.

2008-04-22

Part 1: Drupal 6.2 and DB2 Express-C 9.5 on Ubuntu 7.10

DrupalFinally! It's been far too long since I've had an interesting project to work on. With a couple of sites I might have to make in the foreseeable future, it's time to investigate what I can do with stuff available today. There's a couple of reasons I've hit upon Drupal 6.2 and DB2 Express-C 9.5:


  • Silicon Valley Lab had it's inaugural meeting of the SVL Linux Users Group this morning. I recognize that this is extremely nerdy, and even nerdier to be so excited about it. But the turnout for the SVLLUG's first, unstructured, sort of planning event was about 50 people. Now, to put this in perspective, at any one point in time, I've had about five friends interested in Linux. 50? All of which who are guaranteed to be on campus eight hours a day, five days a week? I'm certainly going to take advantage of it!

  • Seriously, I work for DB2. If I can't get this database to work with Drupal, I will pester people until I have it working, and then I'll blog about it.

  • With MySQL drifting away from open source (come back MySQL! Come back!), I don't see a whole lot of reason to use it. MySQL doesn't exactly have the most cutting edge features (native XML support), and if it's free in the same sense as DB2, why not? IBM has always supported Drupal (15 part series!)

  • I recently read an article comparing Django and Drupal. I've used Drupal for a couple of web sites in the past, and been happy overall. The problem always ended up being with 3rd party modules, but I'd rather have an architecturally sound framework than something flashy that won't last.
Anyway, first thing's first:
  1. Download DB2 Express-C V9.5 for Ubuntu: it's as easy as `sudo apt-get install db2exc`, but you can find more information on Ubuntu's DB2 Virtual Appliance Page

  2. Download Drupal 6.2

  3. Install Apache httpd with PHP support

  4. Install DB2 driver for PHP
Ok, in the time it took to write that post, DB2 Express-C has downloaded and installed. Time to start playing; next post will be how to do steps 3 and 4.