Re: Informix, PHP, Apache
Posted in 2004
A user on Slackware with Apache 1.3.29, PHP 4.3.4 and Informix 7.30 couldn't get PHP to connect to Informix; phpinfo() showed no Informix environment variables. Advice: PHP must be built correctly, and INFORMIXDIR/INFORMIXSERVER must reach Apache, either via PassEnv/SetEnv in httpd.conf or (Paul Watson's preference) by exporting them in the Apache startup script; also, an /etc/services entry isn't needed for shared-memory (onipcshm) connections. Adding PassEnv INFORMIXDIR helped, but connections then failed with -951/-952 'incorrect password or user not known', seemingly because of the web server user and shared-memory authentication. Suggestions to pass an explicit user/password to ifx_connect didn't work, and the thread ends with no resolution recorded.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Installation, Setup & Upgrades, Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration, Networking & sqlhosts Configuration
Paul Watson wrote:
> Sounds like php has not been installed correctly, have a look
> at
>
> http://www.oninit.com/reference/reference.php?page=php
>
> [it a copy of an article by JLeffler]
>
> There is nothing informix specific in the httpd.conf (unless you
> are using the webblade)
Well, you might need to look at Apache directives SetEnv and/or
PassEnv, with a view to setting $INFORMIXDIR and $INFORMIXSERVER (and
possibly $INFORMIXSQLHOSTS, and maybe almost any other Informix
environment variable, though the fewer you set the better).
The posting referenced does mention configuring httpd.conf; it doesn't
say how. An 'Advanced Groups Search' at http://groups.google.com/
with setenv and httpd.conf as required words, comp.databases.informix
as the news group and Jonathan Leffler as the poster pulls up 6
threads from 1999 and 2000 - most of which probably help.
> Thomas Ronayne wrote:
>>I've managed to get myself completely confused. Can anyone tell me what
>>to set and where in httpd.conf and php.ini so PHP can connect to an
>>Informix data base (an example would be most helpful)? I'm running
>>Slackware 9.1, Apache 1.3.29, PHP 4.3.4, Informix 7.30.UC5.
>>
>>My onconfig System Configuration section looks like:
>>
>>My sqlhosts file looks like this:
>>
>> fubar_a onipcshm fubar informixa
As long as the name informixa is unique, there is no need for an
informixa entry in /etc/services when the protocol is not ontlitcp or
onsoctcp.
>>
>>And /etc/services looks like this:
>>
>> # IBM Informix Software
>> informixa 1625/tcp # IBM Informix 7.x engine shared
>> informixanet 1725/tcp # IBM Informix 7.x engine network
>>
>>Informix works (both dbaccess and isql), ESQL/C works, all of that; no
>>problems.
>>
>>PHP works fine with MySQL and anything else I want to do with it -- just
>>can't seem to get it to connect to an Informix data base. phpinfo() does
>>not show the Informix environment variables (which are set in
>>/etc/profile and thus are system-wide).
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
In my experience you are better off setting the environment as part
of your apache startup script and not using setenv etc, I've always
found it easier to look after. With the webblade Apache will not
start without a reasonable Informix environment so it has to be
in startup script.
If you are running php in safe mode, which you should be, then
you can not set informix host/user/passwd in the ini file.
How much this will change with Apache 2, I don't know but until
I can my hands on a webblade that runs with apache 2 then I'm
not going to worry
Jonathan Leffler wrote:
>
> Paul Watson wrote:
>
> > Sounds like php has not been installed correctly, have a look
> > at
> >
> > http://www.oninit.com/reference/reference.php?page=php
> >
> > [it a copy of an article by JLeffler]
> >
> > There is nothing informix specific in the httpd.conf (unless you
> > are using the webblade)
>
> Well, you might need to look at Apache directives SetEnv and/or
> PassEnv, with a view to setting $INFORMIXDIR and $INFORMIXSERVER (and
> possibly $INFORMIXSQLHOSTS, and maybe almost any other Informix
> environment variable, though the fewer you set the better).
>
> The posting referenced does mention configuring httpd.conf; it doesn't
> say how. An 'Advanced Groups Search' at http://groups.google.com/
> with setenv and httpd.conf as required words, comp.databases.informix
> as the news group and Jonathan Leffler as the poster pulls up 6
> threads from 1999 and 2000 - most of which probably help.
>
> > Thomas Ronayne wrote:
> >>I've managed to get myself completely confused. Can anyone tell me what
> >>to set and where in httpd.conf and php.ini so PHP can connect to an
> >>Informix data base (an example would be most helpful)? I'm running
> >>Slackware 9.1, Apache 1.3.29, PHP 4.3.4, Informix 7.30.UC5.
> >>
> >>My onconfig System Configuration section looks like:
>
> >>
> >>My sqlhosts file looks like this:
> >>
> >> fubar_a onipcshm fubar informixa>
> As long as the name informixa is unique, there is no need for an
> informixa entry in /etc/services when the protocol is not ontlitcp or
> onsoctcp.
>
> >>
> >>And /etc/services looks like this:
> >>
> >> # IBM Informix Software
> >> informixa 1625/tcp # IBM Informix 7.x engine shared
> >> informixanet 1725/tcp # IBM Informix 7.x engine network
> >>
> >>Informix works (both dbaccess and isql), ESQL/C works, all of that; no
> >>problems.
> >>
> >>PHP works fine with MySQL and anything else I want to do with it -- just
> >>can't seem to get it to connect to an Informix data base. phpinfo() does
> >>not show the Informix environment variables (which are set in
> >>/etc/profile and thus are system-wide).
>
> --
> Jonathan Leffler #include <disclaimer.h>
> Email: jleffler@earthlink.net, jleffler@us.ibm.com
> Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
--
Paul Watson #
Oninit Ltd # Growing old is mandatory
Tel: +44 1436 672201 # Growing up is optional
Fax: +44 1436 678693 #
Mob: +44 7818 003457 #
www.oninit.com #
Paul Watson wrote: > In my experience you are better off setting the environment as part > of your apache startup script and not using setenv etc, I've always > found it easier to look after. I've not done it sufficiently recently to be totally confident, but I was under the impression that Apache ignored its inherited environment and used only what was specified by either PassEnv (to pass the value of an inherited environment through) or SetEnv (to override the value of inherited environment variable, or to set a value if it was not in the environment). YMMV, as they say. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
Not in my experience, but 'cos we use Informix explode.so for the webblade this library might read the startup environment and not the standard apache libraries. This library loads prior to the php one so explode.so might get something from the environment. But in all our apache/informix/php installs we do not use passenv or setenv Jonathan Leffler wrote: > > Paul Watson wrote: > > > In my experience you are better off setting the environment as part > > of your apache startup script and not using setenv etc, I've always > > found it easier to look after. > > I've not done it sufficiently recently to be totally confident, but I > was under the impression that Apache ignored its inherited environment > and used only what was specified by either PassEnv (to pass the value > of an inherited environment through) or SetEnv (to override the value > of inherited environment variable, or to set a value if it was not in > the environment). YMMV, as they say. > > -- > Jonathan Leffler #include <disclaimer.h> > Email: jleffler@earthlink.net, jleffler@us.ibm.com > Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/ -- Paul Watson # Oninit Ltd # Growing old is mandatory Tel: +44 1436 672201 # Growing up is optional Fax: +44 1436 678693 # Mob: +44 7818 003457 # www.oninit.com #
Jonathan Leffler wrote:
>
> Well, you might need to look at Apache directives SetEnv and/or
> PassEnv, with a view to setting $INFORMIXDIR and $INFORMIXSERVER (and
> possibly $INFORMIXSQLHOSTS, and maybe almost any other Informix
> environment variable, though the fewer you set the better).
>
> The posting referenced does mention configuring httpd.conf; it doesn't
> say how. An 'Advanced Groups Search' at http://groups.google.com/
> with setenv and httpd.conf as required words, comp.databases.informix
> as the news group and Jonathan Leffler as the poster pulls up 6
> threads from 1999 and 2000 - most of which probably help.
>
I've added PassEnv INFORMIXDIR to httpd.conf and get a lot further --
still not quite there, but a lot further. I also tried with
INFORMIXSERVER set but that didn't matter.
What I'm getting (from ifx_connect ("track")) is
Connect id value is 0
Can't connect to track@fubar: E [SQLSTATE=IX 000 SQLCODE=-951]
Error message = Incorrect password or user -p is not known on the
database server.
I tried Connect in dbaccess, which wants a server, then a login and
password -- if I just hit the carriage return to the login prompt it
connects; if I enter my userid and password dbaccess fails with error
952. This makes me wonder if I don't have something set properly in
onconfig (there is no NETTYPE entry, for example) or in sqlhosts or
perhaps in the environment?
And here I thought this was supposed to be easy.
Who are running apache as, I'd guess at 'nobody' so the ifx_connect
might be trying to user the username nobody and no password. But if
you are not running in safe_mode then the connection will be based on
the php.ini setting. 952 is incorrect passwd. As a test use
ifx_connect("track","informix","<password>")
AFAIK if you are in safe_mode you must pass the username/password
through to the connection
Thomas Ronayne wrote:
>
> Jonathan Leffler wrote:
>
> >
> > Well, you might need to look at Apache directives SetEnv and/or
> > PassEnv, with a view to setting $INFORMIXDIR and $INFORMIXSERVER (and
> > possibly $INFORMIXSQLHOSTS, and maybe almost any other Informix
> > environment variable, though the fewer you set the better).
> >
> > The posting referenced does mention configuring httpd.conf; it doesn't
> > say how. An 'Advanced Groups Search' at http://groups.google.com/
> > with setenv and httpd.conf as required words, comp.databases.informix
> > as the news group and Jonathan Leffler as the poster pulls up 6
> > threads from 1999 and 2000 - most of which probably help.
> >
> I've added PassEnv INFORMIXDIR to httpd.conf and get a lot further --
> still not quite there, but a lot further. I also tried with
> INFORMIXSERVER set but that didn't matter.
>
> What I'm getting (from ifx_connect ("track")) is
>
> Connect id value is 0
> Can't connect to track@fubar: E [SQLSTATE=IX 000 SQLCODE=-951]
> Error message = Incorrect password or user -p is not known on the
> database server.
>
> I tried Connect in dbaccess, which wants a server, then a login and
> password -- if I just hit the carriage return to the login prompt it
> connects; if I enter my userid and password dbaccess fails with error
> 952. This makes me wonder if I don't have something set properly in
> onconfig (there is no NETTYPE entry, for example) or in sqlhosts or
> perhaps in the environment?
>
> And here I thought this was supposed to be easy.
--
Paul Watson #
Oninit Ltd # Growing old is mandatory
Tel: +44 1436 672201 # Growing up is optional
Fax: +44 1436 678693 #
Mob: +44 7818 003457 #
www.oninit.com #
No, actually, safe mode is off. No matter what I fiddle with or who I
run as I continue to get the same message and no connection. I know
there's something I've missed somewhere, but I'll be darned if I can see
it. Again, I note, I cannot "connect" to Informix in dbaccess if I enter
a userid and password when prompted -- that seems to be meaningful for
some reason.
Paul Watson wrote:
>Who are running apache as, I'd guess at 'nobody' so the ifx_connect
>might be trying to user the username nobody and no password. But if
>you are not running in safe_mode then the connection will be based on
>the php.ini setting. 952 is incorrect passwd. As a test use
>
>ifx_connect("track","informix","<password>")
>
>AFAIK if you are in safe_mode you must pass the username/password
>through to the connection
>
>
>
>Thomas Ronayne wrote:
>
>
>>Jonathan Leffler wrote:
>>
>>
>>
>>>Well, you might need to look at Apache directives SetEnv and/or
>>>PassEnv, with a view to setting $INFORMIXDIR and $INFORMIXSERVER (and
>>>possibly $INFORMIXSQLHOSTS, and maybe almost any other Informix
>>>environment variable, though the fewer you set the better).
>>>
>>>The posting referenced does mention configuring httpd.conf; it doesn't
>>>say how. An 'Advanced Groups Search' at http://groups.google.com/
>>>with setenv and httpd.conf as required words, comp.databases.informix
>>>as the news group and Jonathan Leffler as the poster pulls up 6
>>>threads from 1999 and 2000 - most of which probably help.
>>>
>>>
>>>
>>I've added PassEnv INFORMIXDIR to httpd.conf and get a lot further --
>>still not quite there, but a lot further. I also tried with
>>INFORMIXSERVER set but that didn't matter.
>>
>>What I'm getting (from ifx_connect ("track")) is
>>
>> Connect id value is 0
>> Can't connect to track@fubar: E [SQLSTATE=IX 000 SQLCODE=-951]
>> Error message = Incorrect password or user -p is not known on the
>> database server.
>>
>>I tried Connect in dbaccess, which wants a server, then a login and
>>password -- if I just hit the carriage return to the login prompt it
>>connects; if I enter my userid and password dbaccess fails with error
>>952. This makes me wonder if I don't have something set properly in
>>onconfig (there is no NETTYPE entry, for example) or in sqlhosts or
>>perhaps in the environment?
>>
>>And here I thought this was supposed to be easy.
>>
>>
>
>
>