Skip to content

Instantly share code, notes, and snippets.

@faizalmansor
Last active June 29, 2023 19:59
Show Gist options
  • Save faizalmansor/7bbafd2b4e712642066f3de6a44a5362 to your computer and use it in GitHub Desktop.
Save faizalmansor/7bbafd2b4e712642066f3de6a44a5362 to your computer and use it in GitHub Desktop.
Setting Up Linux, Apache, Informix & PHP (LAIP) Server Guide

This guide is adapted and updated from an online article "A step-by-step how-to guide to install, configure, and test a Linux, Apache, Informix, and PHP server" by Kellen F. Bombardier.

Original article can be accessed at: http://www.ibm.com/developerworks/data/library/techarticle/dm-0606bombardier/

##Before you start This guide assumes the use of an RPM-based 64-bit Linux system. The steps provided have been completed on Centos 7 on minimal/centos7 vagrant box. However, the overall ideas can be conveyed across any Linux distribution.

##Pre-installation steps First, you need to have the Informix Dynamic Server and the Informix Software Development Kit. If you do not have these products, you can find them on the Informix product family page. Most Linux distributions come with some or all of the LAIP components pre-installed. They are generally not installed from the source, and therefore may not have the correct extensions compiled in. In order to remove these components, and not fall into RPM trouble, you must first be logged in as root:

sudo -i

You can then look for all of the packages that are currently installed on your system:

rpm -qa | grep -i apache
rpm -qa | grep -i httpd
rpm -qa | grep -i php

You can then remove all of the packages found in the above commands:

rpm -e filename

You should now have a "clean" Linux distribution ready for component installation and setup.

##Install Informix and Client SDK To install Informix onto your Linux environment, perform the following steps: Check if any patches are needed for your operating system. You can go to the Informix Dynamic Server page to see if any patches are needed. Create the Informix user and group. The Informix user acts as the root account for the Informix database. Keep this account highly secured. Creation can be done as follows (where xxxx is the password for the user Informix):

groupadd informix
useradd -g informix -p xxxx -d /dev/null informix

Create the installation directory. The default location is /opt/informix. Also, the last two commands are to ensure that the directory is owned by the Informix user and group:

mkdir /opt/informix
chown informix.informix /opt/informix
chown informix.informix /opt/informix

Set up all the environment variables needed. The INFORMIXDIR should be the location you used to install Informix. Using the default is done as follows: Bourne Again shell (bash):

INFORMIXDIR=/opt/informix
export INFORMIXDIR
PATH=$PATH:$INFORMIXDIR/bin
export PATH

Extract the Informix files with the given Informix tar file. If the tar file is in the current directory, extracting the files is done as so (if the file is something like IIF.12.10.FC6DE.linux-x86_64.tar):

mv IIF*.tar /opt/informix
cd /opt/informix
tar -xvf IIF*.tar

Go to the extracted files and run the installation of the IDS. There are three methods of installing IDS. The default is the console method. There is also the graphical and silent method. You can choose whatever suits your needs. The console method is used in this example. The console method can be run as follows:

./ids_install

##Configure Informix and the Informix Client SDK Create environment files needed to bring the Informix server up and running. Modify your .bash_profile file (located in your root or vagrant home directory) with the following contents: Bourne Again shell (bash):

INFORMIXDIR=/opt/informix
INFORMIXSQLHOSTS=/opt/informix/etc/sqlhosts.ol_informix1210
ONCONFIG=onconfig
INFORMIXSERVER=ol_informix1210
SERVERNUM=1
PATH=$INFORMIXDIR/bin:.:$PATH

Your server (ol_informix1210) is already in the sqlhosts.ol_informix1210 file. The sqlhosts file is found in /opt/informix/etc. The name was given and appended in related files by the installer earlier. It is always follow this format:

dbservername nettype hostname servicename [options]

Here is what was added:

ol_informix1210 onsoctcp centos7 ol_informix1210
dr_informix1210 drsoctcp centos7 dr_informix1210
lo_informix1210 onsoctcp 127.0.0.1 lo_informix1210

However, to get it to work without setting the hostname/domain, change all of centos7 occurences with 127.0.0.1 so that it becomes like the following:

ol_informix1210 onsoctcp 127.0.0.1 ol_informix1210
dr_informix1210 drsoctcp 127.0.0.1 dr_informix1210
lo_informix1210 onsoctcp 127.0.0.1 lo_informix1210

You can then test the server by bringing it up with:

oninit -i

Check to see if it came up correctly with:

onstat -

If you see "shared memory not initialized for INFORMIXSERVER 'ol_informix1210'", then the setup did not work. However, if you see the something similar to "IBM Informix Dynamic Server Version 12.10.FC6DE -- On-Line -- Up 00:00:07 -- 19508 Kbytes", then everything is up and working. If you would later like to bring the server down, then the following command can be issued:

onmode -kuy

##Troubleshooting If server fail to be brought up, check the log file /opt/informix/ol_informix1210.log Usually, due to write disk issue. Informix, by default will prevent reinitialization to protect data in database. Subsequent start for the Informix server is the following command:

oninit -v

To clear memory (in case of unclean shutdown) use the following command:

onclean -ky

##Install Apache Run the yum install command:

yum install httpd

Once the installation is complete you can start it using:

systemctl start httpd.service

You should be able to access your webpage with

http://your_server_IP_address/

##Install PHP Run the command to install php and php development package:

yum install php php-devel

This command should also installed phpize which is required to compile php_informix.

Test your server by creating a PHP info file

vi /var/www/html/info.php

Add the following line

<?php phpinfo(); ?>

Save and close the file. You can access it at

http://your_server_IP_address/info.php

If everything is going as planned, you should see an info page of your PHP installation.

Before going further, make sure that you have installed the group "Development Tools" for Centos. This package group will install all necessary software for compiling source file etc. Use the following command to install them:

yum group install "Development Tools"

##Download & Compile PDO Driver for Informix Download the driver from PECL website

wget https://pecl.php.net/get/PDO_INFORMIX-1.3.1.tgz

If you did not have wget installed, you can install it with yum install wget -y

Extract it anywhere convenient to you, example in /home/vagrant.

tar zxf PDO_INFORMIX-1.3.1.tgz
cd PDO_INFORMIX-1.3.1/
phpize
./configure
make

Copy or move the pdo_informix.so file to your PHP installation extension directory. Then, enable that extension in your php.ini file:

extension=pdo_informix.so

In order to connect from a PHP page to informix server, you would need to create a database server user. This is done by doing the following: On the server,

>dbaccess - -
> database  sysuser;

Database selected.

>

Once this is shown, you can run the command below:

CREATE DEFAULT USER WITH PROPERTIES USER 'apache';

CREATE USER testuser WITH PASSWORD "testpass";

You would need to add apache user into the surrogates file:

vi /etc/informix/allowed.surrogates

in the file, add apache after daemon and don't forget to add a comma to separate them like so:

#Added by informix installer - USERS:daemon
USERS:daemon,apache

Test Script

You can then test your connection with the following example script:

<?php

$db = new PDO("informix:host=127.0.0.1; service=8201;
database=test_db; server=testserver; protocol=onsoctcp;
EnableScrollableCursors=1;", "testuser", "testpass");

print "Connection Established!\n\n";

?>

If you see Connection Established! printed on the screen, then you're set! Congratulations! You now have a working LAIP server!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment