# Apache2 - mod_php - OCI8 Problem

## JATMAN

I have been running a small server with Apache2, mod_php and OCI8 which I've been using to experiment with building PHP applications that access Oracle databases.  All was well until last night when I checked for software updates, saw that one was available for apache, and emerged it.  When this had finished, apache seemed to work okay and so did php - but I no longer could make Oracle connections using OCI8.

I successfully ran phpinfo() and verified that it reported that OCI8 was available (and that PHP was available).  Not being much of an expert at this, I'm now lost.  I know that the apache upgrade moved the Document Root to /var/www/localhost/htdocs.

When I attempt to make a connection through PHP via OCI8 now, I get something like the following:

Warning: ocilogon(): _oci_open_server: Error while trying to retrieve text for error ORA-12154 in /var/www/localhost/htdocs/oratest.php on line 3

Warning: ociparse(): supplied argument is not a valid OCI8-Connection resource in /var/www/localhost/htdocs/oratest.php on line 7

Warning: ociexecute(): supplied argument is not a valid OCI8-Statement resource in /var/www/localhost/htdocs/oratest.php on line 8

Warning: ocifetchstatement(): supplied argument is not a valid OCI8-Statement resource in /var/www/localhost/htdocs/oratest.php on line 10

The OCI8 section of the display from phpinfo() shows:

```
oci8

OCI8 Support    enabled

Revision    $Revision: 1.183.2.5 $

Oracle Version    9.2

Compile-time ORACLE_HOME    /ora1/ora920

Libraries Used    no value

```

I'm not sure if the "no value" for Libraries Used is a problem.

Anyone have any ideas?

----------

## sardanap

seems that there is some problem in php_src_compile from  /usr/portage/eclass/php.eclass, i need php+oracle+apache too. I'm tryin' to modify php.eclass. When i will reach (hope so) a working status, i will post

Ciao

Matteo

----------

## JATMAN

Thanks.

It's at least good to know someone else has observed the same problem I'm seeing.  I was afraid that I had missed some configuration bit that was keeping this from working.

Please do post your findings if you get this working.  This problem is definitely causing me some heartburn...

----------

## sardanap

After i lost 3 days about all possible combination of tests i submitted a bug report

https://bugs.gentoo.org/show_bug.cgi?id=32799

Matteo

----------

## sardanap

SOOOOLVEEEEEEEEEEEEEEEEEEEEEEEEEEEDDDDDDDDDD

Apply this little patch to /etc/init.d/apache2 and you will have FULL WORKING oracle+php+apache2

```

diff -u apache2.orig apache2

--- apache2.orig        2003-11-06 10:36:52.000000000 +0100

+++ apache2     2003-11-06 10:52:41.000000000 +0100

@@ -3,6 +3,11 @@

 # Distributed under the terms of the GNU General Public License v2

 # $Header: /home/cvsroot/gentoo-x86/net-www/apache/files/2.0.40/apache2.initd,v

 1.13 2003/10/31 07:17:45 rajiv Exp $

 

+ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE

+ORACLE_HOME=$ORACLE_BASE/product/9.2.0.1.0; export ORACLE_HOME

+LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH

+PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin; export PATH

+

 opts="${opts} reload"

 

 depend() {

@@ -14,7 +19,7 @@

 start() {

        ebegin "Starting apache2"

        [ -f /var/log/apache2/ssl_scache ] && rm /var/log/apache2/ssl_scache

-       env -i PATH=$PATH /sbin/start-stop-daemon --quiet \

+       /sbin/start-stop-daemon --quiet \

                --start --startas /usr/sbin/apache2 \

                --pidfile /var/run/apache2.pid -- -k start ${APACHE2_OPTS}

        eend $?

```

Change your ORACLE_HOME to reflect your installation

Ciao Ciao 

Matteo

P.S. Italians do it better  :Smile: 

----------

## JATMAN

Thanks!!!

I'll give that a try this evening.  Still seems like a bug in the latest apache ebuild since previous versions detected the Oracle environment of the session the emerge occured in and applied it whereever necessary.  Regardless, I'm happy that I can work around it with your patch.

I guess Italians really do do it better!

JATMAN

----------

## JATMAN

Matteo:

Just wanted to followup and confirm that I did make the patch you described and it did restore OCI8 operation on my server.  Thank you very much for your help.

John

----------

## Antonio

 *sardanap wrote:*   

> After i lost 3 days about all possible combination of tests i submitted a bug report
> 
> https://bugs.gentoo.org/show_bug.cgi?id=32799
> 
> Matteo

 

I had the same problem, I have to dig some time too... just to easy the things see this bug:

[edit]

https://bugs.gentoo.org/show_bug.cgi?id=32364

  Thanks Tangent for the right link

[/edit]

"To fix: change "env -i" to "env -i ORACLE_HOME=$ORACLE_HOME" (in the /etc/init.d/apache2) if the "oci8" use flag is enabled."

hope this save some time...

anTONIoLast edited by Antonio on Tue Dec 23, 2003 1:43 pm; edited 1 time in total

----------

## tangent

 *Quote:*   

> I had the same problem, I have to dig some time too... just to easy the things see this bug:
> 
> https://bugs.gentoo.org/show_bug.cgi?id=32324
> 
> "To fix: change "env -i" to "env -i ORACLE_HOME=$ORACLE_HOME" (in the /etc/init.d/apache2) if the "oci8" use flag is enabled."
> ...

 

The correct link is https://bugs.gentoo.org/show_bug.cgi?id=32364

----------

## gcombe74

Is there a apache2 - php and oracle setup guide for gentoo?  I have searched but I did not get any results.

Thanks

----------

## Antonio

 *gcombe74 wrote:*   

> Is there a apache2 - php and oracle setup guide for gentoo?  I have searched but I did not get any results.
> 
> Thanks

 

Some time ago I used this thread to get OCI working with PHP/APACHE and this https://forums.gentoo.org/viewtopic.php?t=106527

to make ORACLE work on gentoo...

Just a start point...

hope this helps,

anTONIo

----------

## gcombe74

Thanks...

any and all help is appreicated.   I just did not know how to attempt this on gentoo since it seems the package maintainers are modulizing all the things for apache on this distro.

thanks

----------

## kumy

 *Quote:*   

> I had the same problem, I have to dig some time too... just to easy the things see this bug:
> 
> https://bugs.gentoo.org/show_bug.cgi?id=32324
> 
> "To fix: change "env -i" to "env -i ORACLE_HOME=$ORACLE_HOME" (in the /etc/init.d/apache2) if the "oci8" use flag is enabled."
> ...

 .

Works great for me too...

----------

## dussel

Hi,

I'm not sure is this bug already fixed (this thread starts Oct 2003), but I 've now exactly the problem that was here descriped.

I tried all the hints, changing the things like sardanap did it. Also I tried the way with changing the 

 *Quote:*   

> "To fix: change "env -i" to "env -i ORACLE_HOME=$ORACLE_HOME" (in the /etc/init.d/apache2) if the "oci8" use flag is enabled." 

 

But it doesnt work for me. Maybe someone could look over my code, I still trying to did it like this(second) way:

out of /etc/init.d/apache2 

```

APACHE2="env -i ORACLE_HOME=$ORACLE_HOME /usr/sbin/apache2"

# orginal   APACHE2="env -i ${OLDENV} /usr/sbin/apache2"

```

I export the 

```

export ORACLE_BASE=/usr/lib/oracle

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

export TNS_ADMIN=/root

```

in the /etc/profile

Any suggestions?

Kind regards

Dussel

----------

## kumy

after emerging a new version of apache, I had to change things like this

in /etc/init.d/apache2

```
APACHE2="env -i ORACLE_HOME=/home/oracle/app/product ${OLDENV} /usr/sbin/apache2"
```

of course, adjust the ORACLE_HOME path to fit your needs...

Regards

----------

