Quite often creating web applications based on PHP language is limited to the platform LAMP (Linux, Apache, MySQL and PHP). But it is the only solution on the market and if we do not have any alternative?
In recent years, large corporations have issued a free alternative to their database servers. Their licenses allow the use of advanced engines for both commercial and commercial purposes, placing restrictions only on platforms (and more precisely terms of resources used). Here I would like to focus on using one of these databases - IBM DB2 Express-C.
In this section we will focus on installation of the complete system environment to Windows platform, but in my spare time I will try to add information to install the extension php_ibm_db2 in a Linux environment.
From what we use:
- DB2 Express-C 9.5 - available at http://www.ibm.com/db2/express
- Apache HTTP 2 (2.2.9 for me ) - available at http://apache.org
- Environment PHP (in my package php-5.2.6-Win32) - available at http://www.php.net
- php_ibm_db2.dll extension (in my package pecl-5.2.6-Win32) - available at Page http://www.php.net
After unpacking the file with the installer just run the data server setup. On the Setup screen appears Launchapd in which we can see the information about the new version, the instructions migration from previous DB2 and system requirements. Install by selecting a product we can install a new database environment. After accepting the license, choose the standard installation option (Typical) and for 4 subsequent screens to confirm the default values. Then we asked for your username and password for the so-called owner instance. It is dedicated to preserve user - db2admin - and give him the password for compliance with current security policies in the system (or domain).
After successful installation of the console using the First Steps (First Steps) will be possible to create the SAMPLE database.
NOTE If someone does not create a sample database at this point would be to be able to make from a special shell (db2cmd) using the command db2sampl-sql-xml
next step is to install Apache and PHP. If the web server it is confined to accept the standard installation options. Then unpack the package php-5.xx-win32 to c: \\ PHP, as well as the package pecl php_ibm_db2.dll to copy the file c: \\ PHP \\ ext.
time to setup a whole. Create a copy of php.ini-dist file called php.ini in c: \\ PHP and surrender it to edit. The Paths and Directories section, set the value of extension_dir to "c: \\ PHP \\ ext", in the Dynamic Extensions add an entry
extension = php_ibm_db2.dll
and at the end of the file
[IBM DB2]
ibm_db2.instance_name = DB2
where DB2 is the name of the instance was installed by us.
left join PHP to Apache. To do this go to the Apache configuration directory (on my C: \\ Program Files \\ Apache Software Foundation \\ apache2.2 \\ conf) and surrender edit the httpd.conf file by adding at the end:
# For PHP 5 do something like this :
LoadModule php5_module "c: / php/php5apache2_2.dll"
AddType application / x-httpd-php. php # configure
the path to php.ini
PHPIniDir "C: / php"
before starting the server Apache should prepare a two files in the directory htdocs (on my C: \\ Program Files \\ Apache Software Foundation \\ apache2.2 \\ htdocs). The first named test.php form:
db2test.php
\u0026lt;? Php
phpinfo ();
?>
and file the form:
\u0026lt;?
php $ database = 'SAMPLE';
$ user = 'db2admin';
$ password = 'your_password';
db2_connect $ conn = ($ database, $ user, $ password);
if ($ conn) {
echo "Connected";
db2_close ($ conn);}
?>
It only remained to run the server and check correct display page http://localhost/test.php and http://localhost/db2test.php. On the first of them should see php modules installed, including one added by us ibm_db2. On the other hand, as you might guess, you will see the word Connected, you connect to the SAMPLE database.
Since we have configured the environment, we can see a list of features offered by the module ibm_db2. The full list can be found on http://uk2.php.net/manual/pl/ref.ibm-db2.php .
But as they say a good programmer is a lazy programmer. The question therefore arises whether or not you can skip the whole process of setting up and ready to install package. The solution is a server for Zend Core 2 available on the IBM www.zend.com / en / products / core / downloads . It allows for much simpler systems environment, including Apache HTTP 2, PHP5 (with Zend Optimizer) and DB2 Express-C 9
0 comments:
Post a Comment