176 DB2 Deployment Guide
Preparing DB2 PHP driver and redistributable DB2 ODBC and CLI driver files
You can obtain the DB2 PHP driver file from any of the method described in
“Installation procedure on Linux and UNIX” on page171. For this example, we
have built the ibm_db2 driver and taken the driver file named ibm_db2.so. In the
target system where the PHP has been installed, you can just register the IBM
PHP driver. We place the PHP driver file ibm_db2.so under
php_deploy/phpdriver.
You only have to prepare the DB2 PHP driver your PHP application will use.
If your application uses only IBM_DB2, then there is no necessity to package
PDO_IBM as well. We discuss how to prepare the redistributable ODBC and CLI
driver files in “Preparing the redistributable driver files” on page159. The
redistributable ODBC and CLI driver is required for preparing the DB2 PHP
drivers for distribution with PHP applications. The script introduced in ODBC and
CLI section requires minor modification. In this example, we gather the required
DB2 driver files under php_deploy/odbcdrv and zip them in a package
itso_cli.tar.gz.
Preparing the PHP application package
This step is to identify all the PHP application files. In real life, the application is
usually under some type of library control system and can be gathered easily. In
our example, we only have a simple PHP application file for demonstration
purpose. We place it under /php_deploy/bin.
Preparing the deployment package
To automate the application deployment process, we create a deployment script,
php_app_install. The script copies the application file and PHP driver file to the
specified path and makes PHP recognize the driver file. It also extracts ODBC
and CLI driver files to a specified path and performs environmental configuration.
Example 4-20 shows the deployment script. There are two command line options
for the scr ipt:
򐂰The flag -p specifies the location where application to be deployed.
򐂰The flag -r registers required system variables.
Example 4-20 Deployment script php_app_install
#!/usr/bin/ksh
##########################################################################
## Deploy application and ODBC CLI driver files to target path
#
# php_app_install -p <installpath> -r
#
# -p specify the location where application and ODBC drv files to be deployed