2

We are having almost the same issue as this person:

OCI8 functions not found when run by apache with php5

The difference between their issue and ours is that we only have one php.ini (/etc/php.ini). We are running PHP 5.3.5 with Apache 2.2.3 on CentOS 5.5. As you can see, their question was never really answered but I hope y'all can help up with ours. Thanks!

Community
  • 1
  • 1
Blu Dragon
  • 394
  • 5
  • 14

3 Answers3

2

I have found the cause of the issue but I do not know how to permenantly solve it. Apparently, our test server is using SELinux set to "Enforce". Setting it to "Permissive" allows Apache/PHP to run the oci8 extension. My boss, however wants SELinux set back to "Enforce" for which I do not blame her. I'm going to look into creating an exception for Oracle/oci8.

Blu Dragon
  • 394
  • 5
  • 14
  • Thanks for clarifying the issue back here. If you do find a good, permanent solution... be sure to post the details for the benefit of anybody else that might encounter the same problem. – Mark Baker Mar 09 '11 at 17:20
1

Re. SELinux and OCI8 when running as an Apache module

Suggested solution from http://old.nabble.com/php-with-oci8-td16460446.html

you can customize your policy to allow this access using audit2allow

# grep http /var/log/audit/audit.log | audit2allow -M myhttp 
# semodule -i myhttp.pp 

This should allow you to run these oracle apps with SELinux in enforcing mode.

There's also a thread about this on the oracle forums

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • The installation guide on php.net says that 'If the Oracle Database is on the same machine as PHP, the database software already contains the necessary libraries'. However, in my case when I exclude the Oracle Instant Client then, even PHP and Oracle reside on the same machine, oci8 only works on command mode but fails to be loaded in apache. Including the client fixes the issue for me. – Khanh Tran Apr 14 '14 at 08:20
0

Ensure that you have ORACLE_HOME, ORACLE_SID and LD_LIBRARY_PATH in the Apache envvars. Remember that Apache is running as a daemon, so it doesn't necessarily have access to the same environment variables as when you run your PHP scripts from the command line.

ORACLE_HOME=/u01/app/oracle/product/10.1
ORACLE_SID=orcl
export ORACLE_HOME ORACLE_SID
export LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}

Depending where your database server is and how you connect to it you may also want to set TWO_TASK or TNS_ADMIN. To ensure the correct character set is used, you may also want to set NLS_LANG.

EDIT

I normally build PHP from source, so I have full control:

Assuming that the standard Oracle Client is running on the server, then my ./configure includes:

--with-pdo-oci=$ORACLE_HOME

On the couple of occasions when I've needed to build for the Oracle instant client, I've used

--with-pdo-oci=instantclient,/usr,10.2.0.3

in my ./configure line

Note that I use PDO_OCI rather than OCI8, but the ./configure should be similar

The other step that I take when deploying to a new server is to ensure that the apache user/group (as defined by the User and Group directives in httpd.conf... my apache runs as user "daemon") will have read and execute privilege to the files under ORACLE_HOME

Mark Baker
  • 209,507
  • 32
  • 346
  • 385