A step-by-step how-to guide to install, configure, and test a Linux, Apache, Informix, and PHP server

A cookbook for LAIP systems

Before you start

This article assumes the use of an RPM-based 32-bit Linux system. The steps provided have been completed on Red Hat Enterprise Linux 4 and SUSE Linux 9. 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:

su - root

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.

Fetch and unpack the source code for all applications

  1. Move to a location to store all of your source code:
    cd /usr/local/src
  2. Get the components you need:

The following versions of the LAIP products are used during this setup:

Apache HTTP server2.2.0
Informix Dynamic Server (IDS)10.00.UC4
Informix Client Software Development Kit (Client SDK)2.90.UC4
Informix PHP Data Objects (PDO)1.0.0

A different version of the above products may require a different set of steps for the setup to work properly. The steps given are unique to the products above. However, the general ideas can be followed across versions.

Unpack all the source code

tar zxf httpd-2.2.0.tar.gz
tar zxf php-5.1.2.tar.gz
tar zxf PDO_INFORMIX-1.0.0.tgz

Install Informix and Client SDK

To install Informix onto your Linux environment, perform the following steps:

  1. 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.
  2. 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
  3. 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:
    su informix mkdir /opt/informix
    chown informix.informix /opt/informix
    chown informix.informix /opt/informix
  4. 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):
    export INFORMIXDIR
    export PATH


    C shell (csh):
    setenv INFORMIXDIR /opt/informix
    setenv PATH ${PATH}:${INFORMIXDIR}/bin
  5. Extract the Informix files with the given Informix tar file. If the tar file of the Informix Server and Client SDK are in the current directory, extracting the files is done as so (if the file is something like IIF*.tar):
    mv IIF*.tar /opt/informix
    cd /opt/informix
    su informix tar -xvf IIF*.tar
  6. 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:
    ./install_rpm -acceptlicense=yes

    After running the script, simply follow the on-screen instructions to complete the installation of Informix. Be sure to use the /opt/informix as the installation directory. The accept license flag should only be added if you accept the Informix license.

  7. Extract the Client SDK tar file into /opt/informix.
    mv client*.tar /opt/informix
    cd /opt/informix
    su informix tar -xvf client*.tar
  8. Run the installation script to install the Client SDK. After running the script, simply follow the on-screen instructions to complete the installation of the Client SDK portion of Informix:

Configure Informix and the Informix Client SDK

  1. Create environment files needed to bring the Informix server up and running. An .informix file is created in the home directory with the following contents: Bourne Again shell (bash):
    set INFORMIXDIR=/opt/informix
    set INFORMIXSQLHOSTS=/opt/informix/etc/sqlhosts
    set ONCONFIG=onconfig
    set INFORMIXSERVER=myserver
    set SERVERNUM=1


    C shell (csh):
    setenv INFORMIXDIR /opt/informix
    setenv INFORMIXSQLHOSTS /opt/informix/etc/sqlhosts
    setenv ONCONFIG onconfig
    setenv INFORMIXSERVER myserver
    setenv SERVERNUM 1
    setenv PATH $INFORMIXDIR/bin:.:$PATH
  2. Add your server to the sqlhosts file. The sqlhosts file is found in /opt/informix/etc. You must add the INFORMIXSERVER name given above in the environment variables to the sqlhosts file. The added line in sqlhosts should follow this format: dbservername nettype hostname servicename [options]

    Here is what was added:

    myserver onsoctcp myserver port_alias

    The port given must also be open on your system. In this example, it was opened in the /etc/services file. Here is an example of the line added to the services file:

    port_alias 8201/tcp
  3. Create the onconfig file. The onconfig file must be in the /opt/informix/etc directory. There should already be a standard onconfig file there named onconfig.std. The contents below fit the system needs for this example. You may need to add extra variables or you may not need all of the variables shown below. The onconfig file contains the following contents:
    DBSERVERNAME myserver
    DUMPDIR /tmp
    LOGDIR /opt/informix/logdir
    MSGPATH /opt/informix/logdir/online.log
    PHYSDBS rootdbs
    ROOTNAME rootdbs
    ROOTPATH /opt/informix/logdir/rootdbs
    ROOTSIZE 30000

    The DBSERVERNAME refers to the unique name associated with this specific database server instance. The DUMPDIR refers to the directory in which the server dumps shared memory and messages. The LOGDIR is the log directory for the IDS instance. The MSGPATH is the full path name of the message log file. The PHYSDBS is the name of the dbspce that contains the physical log. The ROOTNAME is the name for the root dbspace. The ROOTPATH is the full path name of the initial chunk of the root dbspace. The ROOTSIZE is the size of the initial chunk of the root dbspace.

  4. Add the above specified log directory and root space. For the setup in this example, the following was done:
    su informix mkdir /opt/informix/logdir
    su informix chmod 777 /opt/informix/logdir
    cd /opt/informix/logdir
    su informix touch rootdbs
    su informix chmod 660 rootdbs
    su root chown informix.root rootdbs
  5. Make sure everything works correctly.
    1. Try to bring up the server:
      cd /opt/informix/bin
      oninit -i
    2. Check to make sure it came up correctly by using the following command:
      onstat -
    3. If you see "shared memory not initialized for INFORMIXSERVER 'myserver'", then the setup did not work. However, if you see the something similar to "IBM Informix Dynamic Server Version 10.00.UC4 -- 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

For any issues with the Informix Dynamic Server, refer to the IBM Informix Dynamic Server v10.0 Information Center for troubleshooting help.

Install and configure Apache

Follow the steps below to install Apache with support for dynamically loaded modules:

cd /usr/local/src/httpd-2.2.0/

./configure \
--prefix=/usr/local/apache \
--enable-shared=max \
--enable-module=rewrite \

make install
  1. Edit the http.conf file to process .php files correctly. The httpd.conf file can be found in /usr/local/apache/conf/httpd.conf. Look for the following lines: #AddType application/x-httpd-php .php
    #AddType application/x-httpd-php-source .phps
  2. Remove the #s from the beginning of these lines if they are found. If they are not in the file, then add them without the #s. This enables Apache to process and display php files correctly.
  3. You can more fully configure your Apache server by editing the httpd.conf file in /usr/local/apache/conf. There is a great deal of documentation on the Internet about this topic.

Install and configure PHP

Follow the steps below to install PHP:

  1. Copy the PDO_INFORMIX folder into the ext directory of PHP:
    cd /usr/local/src/php-5.1.2/ext
    cp -R ../../PDO_INFORMIX-1.0.0 pdo_informix
  2. Configure and make PHP with the PDO:
    cd /usr/local/src/php-5.1.2
    ./buildconf --force
    ./configure --with-apxs2=/usr/local/apache/bin/apxs \
    --disable-debug \
    --disable-ftp \
    --disable-inline-optimization \
    --disable-magic-quotes \
    --disable-mbstring \
    --enable-wddx=shared \
    --enable-xml \
    --with-dom \
    --with-regex=system \
    --with-xml \
    --with-jpeg-dir=/usr/lib \
    --with-zlib-dir=/usr/lib \
    --with-zlib \
    --without-pdo-sqlite \
    --without-iconv \
    --without-sqlite \
    --enable-shared \
    --enable-pdo \
    make install
    cp php.ini-dist /usr/local/lib/php.ini
  3. You can now see if the PHP install went as planned. You can issue the following command:
    php -m
  4. The output from this command should include both the PDO and the pdo_informix modules. If those are not included, then the buildconf, configure, make, or the make install commands did not go as planned.

    There is the option to configure pdo_informix at a different time than PHP itself.

  5. You can compile pdo_informix by itself, but it requires phpize from the installation location of PHP. You do not need to perform this step if you configured or compiled pdo_informix while configuring or compiling PHP.
    cd pdo_informix
  6. Add the correct extensions to the php.ini file. It is found at /usr/local/lib/php.ini. The loadable extensions directory is specified inside the php.ini file. It is most commonly found after the line: ; Directory in which the loadable extensions (modules) reside.

    The entry used in this example looks like the following:

    ; Directory in which the loadable extensions (modules) reside.
    extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20050922/"

The other change needed in the php.ini file is the definition of the PDO and pdo_informix extensions. They are found in the Dynamic Extensions section in php.ini. If they were created as shared modules, you need to copy the modules into the above extension directory and enable them in the php.ini file as shown below:

Test the New Dynamic Web server

To test the New Dynamic Web server, complete the following steps:

  1. Start Apache. All you need to do is the following (again as root):
    /usr/local/apache/bin/apachectl start

    Open up your favorite browser and type localhost into the address bar. The default Apache start page should show. This confirms that Apache has been started.

  2. Make sure that PHP is working with Apache. You need to edit the index.html file that is being displayed in your browser. This corresponds to where you installed Apache. The location used for this example is here: /usr/local/apache/htdocs/index.html.

    Erase the index.html file and replace it with the following (named index.php):

    echo "PHP and Apache are playing nicely!";

    Then when you open up the page modified (http://localhost/index.php), you should see PHP and Apache are playing nicely!. If you see the PHP code itself , then your PHP and Apache installation or configuration is flawed.

  3. Make sure Informix is running and there is information you can query. In order to see if Informix is running, do the following:
    ps -aef | grep oninit

    If any processes are found, then Informix is running. If not, start Informix with the command given above. The tool Informix uses is dbaccess to create or delete databases, create or delete tables, and insert or delete data. You can run dbaccess from:


    Remember to do the following:

    1. Add users that need access to the 'informix'.sysauth table in the sysuser database.
    2. Add a new database and table with data in it to test your server's setup.

    There is documentation on the Internet if you are not familiar with dbaccess.

  4. Check to make sure your PHP and PDO Informix setup is working correctly. You should go to your default Apache document location (/usr/local/apache/htdocs) to add a test.php file. The following is the contents of the test.php file (explained below):
    $db = new PDO("; service=8201;
    database=test_db; server=testserver; protocol=onsoctcp;
    EnableScrollableCursors=1;", "testuser", "testpass");
    print "Connection Established!\n\n";
    $stmt = $db->query("select * from test_table");
    $res = $stmt->fetch( PDO::FETCH_BOTH );
    $rows = $res[0];
    echo "Table contents: $rows.\n";

    The variables in the connection string fit our system's needs. Choose the variables and their values to fit your system and environment. The first line is the connection string for the Informix database. The informix: is needed to start the connection string. The host is simply the server host name. The service is the port number opened for your database (/etc/services). The database is the name of the database you created above. The server is the name of the database instance you created earlier. The protocol type is the protocol you entered in the /etc/sqlhosts file. The rest of the options are self explanatory. The last two options to the PDO object is the username and the password. Be sure that the user has been added to the sysuser database as explained above.

    When you open the Web page of test.php you should see Connection Established! and Table Contents followed by the entity contents you added to your table.

Congratulations! You have an LAIP system ready for use!

Downloadable resources

Related topics

Zone=Information Management, Linux, Open source
ArticleTitle=A step-by-step how-to guide to install, configure, and test a Linux, Apache, Informix, and PHP server