Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: PHP Informix client support
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
drsound
n00b
n00b


Joined: 20 Sep 2004
Posts: 10
Location: Italy

PostPosted: Sun Oct 31, 2004 6:09 pm    Post subject: HOWTO: PHP Informix client support Reply with quote

I was just asked to add Informix support to mod_php running on a Gentoo Linux server (x86): it should be used to develop a PHP application accessing an Informix server running on a Sco Unix. I was completely new to Informix, so I looked for info on the Internet and I got some connection parameters from existing ODBC connections on Windows workstations. In particular I copied from ODBC parameters (without further investigation) the "onsoctcp" communication protocol (it looks like there are several communication protocols available) and the "firm_name_01" parameter (should be the "database server name": beware it's not the DNS name of the host running the Informix server! Probably it's assigned when you install the Informix server). Here are the steps I needed, hope it helps:

0) Download the Informix client from IBM website: I got "Informix Client SDK V2.81.UC3 32 bit for Linux on Intel" (clientsdk.2.81.UC3.LINUX-I32.tar).

1) groupadd informix ; useradd -g informix -d /dev/null informix

2) mkdir /opt/informix

3) Move clientsdk.2.81.UC3.LINUX-I32.tar to /opt/informix and untar it.

4) You will need cpio, so if you haven't do emerge cpio.

5) Unpack csdk.cpi using cpio -idumB <csdk.cpi (notice the absence of the "c" flag in cpio parameters, it would not work otherwise).

6) Within the unpacked files there will be 3 or 4 scripts (installclientsdk, etc. can't remember the names now): modify them searching for "cpio" and removing all "c" flag references (see previous step).

7) Run installclientsdk.

8) Create the file /etc/env.d/99informix containing the following lines:
INFORMIXDIR=/opt/informix
PATH=/opt/informix/bin
ODBCINI=/opt/informix/etc/odbc.ini
INFORMIXSERVER=firm_name_01
LDPATH=/opt/informix/lib:/opt/informix/lib/esql:/opt/informix/lib/cli:/opt/informix/lib/client

NB: substitute "firm_name_01" with your "database server name".

9) env-update ; source /etc/profile

10) Edit /opt/informix/etc/sqlhosts adding the parameters needed to establish a connection to the Informix server. In my case they were "firm_name_01 onsoctcp 192.168.0.1 1526".
Field 1 is the name of the database server (the same used in step number 8), field 2 is the communication protocol (often referred to as "nettype" in Informix's documentation), field 3 is the DNS name or IP address, field 4 is the service name or port number.

11) If you want you can test your connection trying some of the demos in /opt/informix/demo. I wasn't so successful in this: I suppose you have to create some db/tables/permissions on the server to let the demos work. Anyway if you get some error code you can use /opt/informix/bin/finderr to get a textual description.

12) Add the "informix" use flag in /etc/make.conf and emerge mod_php.

13) Add these lines to /etc/apache2/conf/apache2.conf:
SetEnv INFORMIXDIR /opt/informix
SetEnv ODBCINI /usr/local/etc/odbc.ini
SetEnv INFORMIXSERVER firm_name_01


14) The /etc/init.d/apache2 scripts clears the environment (env -i) before starting the Apache daemon, but we need to preserve some variables if we want mod_php to work, so modify the script this way (the original lines are commented):
#env -i PATH=$PATH /sbin/start-stop-daemon --quiet \
# --start --startas /usr/sbin/apache2 \
# --pidfile ${PIDFILE} -- -k start ${APACHE2_OPTS}
env -i \
PATH=$PATH:/opt/informix/bin \
INFORMIXSERVER=firm_name_01 \
INFORMIXDIR=/opt/informix \
ODBCINI=/opt/informix/etc/odbc.ini \
/sbin/start-stop-daemon --quiet \
--start --startas /usr/sbin/apache2 \
--pidfile ${PIDFILE} -- -k start ${APACHE2_OPTS}

NB: if you use the statement VARIABLE=$VARIABLE (as for PATH) it will not work when Apache is started at boot time, probably because Apache is started before the variables in /etc/profile are added to the environment.

15) /etc/init.d/apache2 restart

16) Execute a phpinfo() to check if PHP sees the environment variables: looking in the "PHP Variables" section you should see the values you added in /etc/apache2/conf/apache2.conf as _SERVER variables (example _SERVER["INFORMIXDIR"]="/opt/informix") and the ones you added in /etc/init.d/apache2 as _ENV variables (example _ENV["INFORMIXDIR"]="/opt/informix").


Last edited by drsound on Sat Feb 05, 2005 3:25 pm; edited 1 time in total
Back to top
View user's profile Send private message
Niosop
n00b
n00b


Joined: 04 Oct 2003
Posts: 24

PostPosted: Fri Feb 04, 2005 11:40 pm    Post subject: Thanks so much Reply with quote

My current project requires interfacing with an HP-UX Informix DB. I was dreading setting this up, as all the information I had gathered so far was fragmentary. Then I found this post (I should have known it would be on gentoo forums, everything is) and it worked like a charm.

Thanks so much for posting this, I'm sure it saved me hours (or more likely, days) of pounding my head trying to get it to work.

Very appreciatively,
Niosop

P.S. I especially like the cpio arguments -idumB. Was that intentional on your part?

[EDIT] You may also want to move step 7 to after step 9 as the installclientsdk script wants the env vars set.
Back to top
View user's profile Send private message
queru
n00b
n00b


Joined: 10 Sep 2002
Posts: 7
Location: Zaragoza (Spain)

PostPosted: Wed Sep 21, 2005 2:43 pm    Post subject: 2.90.UC3 Reply with quote

Same for 2.90.UC3?

Thanks.
_________________
queru - http://queru.org
Linux Registered User: 170191
Back to top
View user's profile Send private message
queru
n00b
n00b


Joined: 10 Sep 2002
Posts: 7
Location: Zaragoza (Spain)

PostPosted: Wed Sep 21, 2005 2:54 pm    Post subject: ifx_connect(): E [SQLSTATE=IX 001 SQLCODE=-1829] Reply with quote

This works for me until yesterday. In the today upgrade of apache2, changes are made by Gentoo in the location of the files. I adjust everything, re-emerge the mod_php, and all that I get is:

Code:
ifx_connect(): E [SQLSTATE=IX 001 SQLCODE=-1829]


I follow every step a hundred of times. I'm totally lost.

Any idea, please?
_________________
queru - http://queru.org
Linux Registered User: 170191
Back to top
View user's profile Send private message
queru
n00b
n00b


Joined: 10 Sep 2002
Posts: 7
Location: Zaragoza (Spain)

PostPosted: Thu Sep 22, 2005 10:40 am    Post subject: _ENV[] array in phpinfo() Reply with quote

Ok, it works now.

Is really very very important to see the INFORMIX vars in the _ENV array in a phpinfo() page. I only can get this using this start function in /etc/init.d/apache2 bash script:

Code:

start() {
        checkconfig || return 1
        ebegin "Starting apache2"
        [ -f /var/log/apache2/ssl_scache ] && rm /var/log/apache2/ssl_scache
        [ -f /usr/lib/apache2/build/envvars ] && . /usr/lib/apache2/build/envvars
        env -i \
                PATH=$PATH:/opt/informix/bin \
                INFORMIXDIR=/opt/informix \
                ODBCINI=/opt/informix/etc/odbc.ini \
                INFORMIXSERVER=mazesc1_tcp \
                DBDATE=DMY4/ \
                CLIENT_LOCALE=en_US.819 \
                DB_LOCALE=en_US.819 \
                INFORMIXSQLHOSTS=/opt/informix/etc/sqlhosts \
                SQLIDEBUG=/tmp/ifx \
                /sbin/start-stop-daemon --quiet \
                --start --startas /usr/sbin/apache2 \
                --pidfile ${PIDFILE} -- -k start ${APACHE2_OPTS}
                #${APACHE2} ${APACHE2_OPTS} -k start
        eend $?
}



The _ENV array from the server:

Code:

 _ENV["PATH"]  [...]:/opt/informix/bin
 _ENV["INFORMIXDIR"]  /opt/informix
 _ENV["ODBCINI"]  /opt/informix/etc/odbc.ini
 _ENV["INFORMIXSERVER"]  mazesc1_tcp
 _ENV["DBDATE"]  DMY4/
 _ENV["CLIENT_LOCALE"]  en_US.819
 _ENV["DB_LOCALE"]  en_US.819
 _ENV["INFORMIXSQLHOSTS"]  /opt/informix/etc/sqlhosts
 _ENV["SQLIDEBUG"]  /tmp/ifx



The Informix Client SDK it's a bullshit piece of code.[/b]
_________________
queru - http://queru.org
Linux Registered User: 170191
Back to top
View user's profile Send private message
midan
n00b
n00b


Joined: 16 Mar 2004
Posts: 2
Location: Bucuresti,RO

PostPosted: Wed Oct 05, 2005 8:12 am    Post subject: Environment Reply with quote

in /etc/conf.d/apache2

# Environment variables to keep
# All environment variables are cleared from apache
# Use this to preserve some of them
# NOTE!!! It's very important that this contains PATH
# Also, it will fail if the _value_ of any of these variables contains a space
KEEPENV="PATH INFORMIXDIR INFORMIXSERVER"

and there is no need to modify /etc/init.d/apache2 bash script:
Back to top
View user's profile Send private message
5Ball
n00b
n00b


Joined: 18 May 2005
Posts: 7

PostPosted: Thu Oct 06, 2005 4:20 pm    Post subject: PHP / Informix - connect to multiple databases Reply with quote

Since there is only one INFORMIXSERVER environment variable set in the Apache configuration file, is it not possible to connect to more than one database server?

Last edited by 5Ball on Mon Oct 31, 2005 10:44 pm; edited 1 time in total
Back to top
View user's profile Send private message
Niosop
n00b
n00b


Joined: 04 Oct 2003
Posts: 24

PostPosted: Mon Oct 10, 2005 5:52 am    Post subject: PHP 5 and AMD64 Reply with quote

After hours of pounding my head, I've finally got PHP5+Informix client working on a new AMD64 server. I didn't document everything I did, because I didn't really think I'd get it to work, but here are some hints for anyone trying to do the same. If you attempt it, please document it and post it here.

-Download the 64 bit Linux Informix client SDK from IBM.
-Do everything in the original post
-Using rpm and cpio, run all the install programs you can. I never got all the way through w/o errors, but evidentally enough was finished to get it to work.
-Comment out the informix entry in /usr/portage/profiles/default-linux/amd64/use.mask
-Start a dev-lang/php emerge, but at some point your going to have to Control-Z and fix the file described in http://lists.alioth.debian.org/pipermail/pkg-php-maint/2005-September/000194.html
-Resume the emerge w/ fg.

After that, it should work ok.

The configure script and/or Makefile should really be fixed instead of the ugly pause compiling/fix file/resume hack above, but that's for someone wiser than me.

Hope this helps someone.
Back to top
View user's profile Send private message
asommer
n00b
n00b


Joined: 15 Nov 2005
Posts: 36

PostPosted: Tue Jan 23, 2007 8:40 pm    Post subject: Reply with quote

Hello,

I found this thread and thought FREAKIN Awesome I need Informix on Gentoo...

Then I realized I'm running an AMD64...heh

Anyway, I finally got the informix client-sdk to run on Gentoo. I did it in a sort of round about way:

Quote:

1. I downloaded the Informix Client Software Development Kit 2.90.FC4: http://www14.software.ibm.com/webapp/download/preconfig.jsp?id=2006-01-26+07%3A28%3A52.181415R&S_TACT=104CBW71&S_CMP=
*** I couldn't find the UC file in for 64. ***

2. Setup /opt/informix and informix user
mkdir /opt/informix
useradd -s /bin/noshell informix
chown informix:informix /opt/informix

3. tar -xvf clientsdk.2.90.FC4.LINUX.tar -C /opt/informix

4. Setup environment variables:
export INFORMIXDIR=/opt/informix
export INFORMIXSERVER=server_name

5. Once you expand the tar file it creates an "install_rpm" shell script in /opt/informix. There's probably a better way, but I don't know it, so I checked the portage tree for ways to convert rpms into something Gentoo and use. To my surprise rpm is actually in portage, so I:
emerge rpm

6. Once rpm is installed I simply ran the install_rpm script:
/opt/informix/install_rpm -acceptlicense=yes

7. I didn't install informix for PHP however so you'll probably want to follow the example above. But this did work for ruby-informix.




I'm not sure how good of an idea installing 2 package managers is, but I figure if the only rpms I ever install are from 3rd party odd ball places it shouldn't hurt anything. I was truly surprised that rpm was even in portage! Definitely cool that it was.

Maybe this will help someone in the future...or if you have a better way to install the clientsdk on amd64 let me know.
_________________
Party On!
Back to top
View user's profile Send private message
mafonso
n00b
n00b


Joined: 21 Dec 2007
Posts: 5

PostPosted: Fri Dec 21, 2007 8:26 pm    Post subject: Reply with quote

Hello, list

I need to install php with informix support, but seems that informix is no longer supported in portage (read somewhere that the informix use flag was removed...)

Do I need to do it all 'by hand'? (downloading source from php site, configure, make and make install...)

The machine is an AMD64

thanks in advance.

btw, merry christmas ;-)
Back to top
View user's profile Send private message
mafonso
n00b
n00b


Joined: 21 Dec 2007
Posts: 5

PostPosted: Wed Dec 26, 2007 8:38 pm    Post subject: Reply with quote

Hi

I did this (after installed the IBM client sdk and setted all the environment variables):

Code:

# emerge php
# emerge PEAR-PEAR
# pecl install --alldeps pdo_informix


Then I edited php.ini and wrote this:

Code:

extension=pdo.so


I created a php script with an ifxconnect() evocation into it, just for a test, but then:

Code:

# php -f test.php
Fatal error: Call to undefined function ifx_connect()...


Something is missing...
Any ideas?
Back to top
View user's profile Send private message
mafonso
n00b
n00b


Joined: 21 Dec 2007
Posts: 5

PostPosted: Wed Dec 26, 2007 9:43 pm    Post subject: Reply with quote

hum... I guess I can't use ifx_* anymore...

the sintax from php v5.2.1 on is something like:

Code:

<?php
$dbh = new PDO('informix:host=somehost;dbname=somedbname', $user, $pass);
?>


Is there any way of putting ifx_* back to work?
Configuring php like ./configure --with-informix=... doesn't work

I guess the only solution is install 5.2.0 or earlier...
Back to top
View user's profile Send private message
mafonso
n00b
n00b


Joined: 21 Dec 2007
Posts: 5

PostPosted: Thu Dec 27, 2007 4:45 pm    Post subject: Reply with quote

I found this.

I successfully compiled and installed informix.so from php 5.2.0.
ifx_connect apparently works, but php segfaults with an ifx_query :-(

The problem may be something about informix configuration, or the module informix.so just doesn't work

I'm also trying to connect with pdo like this:
Code:

try {
   $dbh = new PDO('informix:host=somehost;database=somedb', 'someusr', 'somepass');
   foreach ($dbh->query('SELECT * from cliente') as $row) {
      print_r($row);
   }
   $dbh = null;
} catch (PDOException $e) {
   print "Error!: " . $e->getMessage() . "<br/>";
   die();
}


but the result is:
Code:

Error!: SQLSTATE=HY000, SQLDriverConnect: -11060 [Informix][Informix ODBC Driver]Unspecified System Error = -11060.


I'll just keep on trying.
Any ideas are welcome.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum