php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61223 php can run oci,but php-fpm oci error
Submitted: 2012-03-01 16:45 UTC Modified: 2013-01-03 05:19 UTC
From: 4yuinfo at gmail dot com Assigned: sixd (profile)
Status: Closed Package: OCI8 related
PHP Version: 5.3.10 OS: CentOS 6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 - 22 = ?
Subscribe to this entry?

 
 [2012-03-01 16:45 UTC] 4yuinfo at gmail dot com
Description:
------------
update php 5.3.5 to php 5.3.10
php-fpm oci can't run

Test script:
---------------
cat a.php
---------------------------------------------------------
<?php
print oci_connect('login_id', 'login_pw', 'oracle_db');
---------------------------------------------------------
#command line
php -q a.php
Resource id #5
#nginx+php-fpm
502 bad gateway
#apache + perfork
Resource id #3

Expected result:
----------------
oci8 run to php-fpm can work

Actual result:
--------------
oci8 run to php-fpm can't work

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-02 19:32 UTC] sixd@php.net
-Status: Open +Status: Feedback
 [2012-03-02 19:32 UTC] sixd@php.net
Do non-Oracle apps work?  The 502 isn't obviously going to be caused by an 
Oracle problem.

Add error checking on the the oci_connect call and see what message is being 
passed.

What configuration options did you use?

What Oracle client did you use?

What Oracle environment variables have you set?

How/where did you set the variables?

What is your fpm configuration?
 [2012-03-02 19:32 UTC] sixd@php.net
-Assigned To: +Assigned To: sixd
 [2012-03-03 02:32 UTC] 4yuinfo at gmail dot com
-Status: Feedback +Status: Assigned
 [2012-03-03 02:32 UTC] 4yuinfo at gmail dot com
cat b.php
#-------------------------------------------------------------------
<?php
if (@oci_connect('login_id', 'login_pw', 'oracle_db')) {
    print 'right';
} else {
    print 'error';
}
#-------------------------------------------------------------------
#command line
php -q b.php
    right
#apache curl http://127.0.0.1:80/b.php
    right
#ngixn + php-fpm curl http://127.0.0.1:81/b.php
    502 bad gateway 
        => but remove remi 5.3.10 rpm
        => reinstall remi 5.3.5 rpm show right string is work
#-------------------------------------------------------------------
#1.download CentOS-6.2-x86_64-minimal.iso
#2.install CentOS-6.2-x86_64-minimal.iso
#3.yum add repo remi and nginx
yum install php-* --skip-broken php-mysql #no install php-pecl* and php-pear*
yum install nginx
#4.set nginx and php-fpm
#5.download oracle client oracle-instantclient-11.2.0.1.0*.rpm
#6.rpm -ivh oracle-instantclient-11.2.0.1.0*.rpm
#7.set oracle environment variables in the bashrc and php-fpm
#========================================================================
#--------------------------
# php-fpm.conf
#--------------------------
[global]
pid = /var/run/php-fpm/php-fpm.pid
emergency_restart_threshold = 1
emergency_restart_interval = 20m
process_control_timeout = 15m

[test]
listen = 127.0.0.1:5101
listen.allowed_clients = 127.0.0.1
user = nginx
group = nginx
pm = static
pm.max_children = 20
pm.max_requests = 0
pm.status_path = /php-fpm/status
ping.path = /php-fpm/ping
ping.response = pong
request_terminate_timeout = 10m
request_slowlog_timeout = 0
rlimit_files = 65530
rlimit_core = 0
env[HOSTNAME]                       = $HOSTNAME
env[ORACLE_HOME]                    = /usr/lib/oracle/11.2/client64/
env[LD_LIBRARY_PATH]                = /usr/lib/oracle/11.2/client64/lib/
env[NLS_LANG]                       = "TRADITIONAL CHINESE_TAIWAN.UTF8"
env[TNS_ADMIN]                      = /etc/oracle
php_admin_flag[short_open_tag]          = on
php_admin_flag[display_errors]          = on
#========================================================================
# command line add oracle client environment variables
#========================================================================
echo -e "export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib/\nexport NLS_LANG=\"TRADITIONAL CHINESE_TAIWAN.UTF8\"\nexport TNS_ADMIN=/etc/oracle" >> /etc/sysconfig/httpd
echo -e "export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib/\nexport NLS_LANG=\"TRADITIONAL CHINESE_TAIWAN.UTF8\"\nexport TNS_ADMIN=/etc/oracle" >> /etc/bashrc
echo -e "export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib/\nexport NLS_LANG=\"TRADITIONAL CHINESE_TAIWAN.UTF8\"\nexport TNS_ADMIN=/etc/oracle" >> /etc/profile
#========================================================================
 [2012-03-05 20:28 UTC] sixd@php.net
-Status: Assigned +Status: Feedback
 [2012-03-05 20:28 UTC] sixd@php.net
Try real error checking with oci_error().  Write the output to a log.

Check all logs to see if there are startup errors, such as libraries not found.

A side comment: since you are using Oracle Instant Client you should not set 
ORACLE_HOME.  If you need access to a tnsnames.ora file, set TNS_ADMIN instead
of ORACLE_HOME.

Can you strace the webserver process and see what calls are being made?

Try building PHP from source and linking oci8 as a static extension not 
"shared".
 [2012-10-12 21:46 UTC] mikhail dot v dot gavrilov at gmail dot com
Look here solution http://www.php.net/manual/it/oci8.installation.php#110226
 [2012-10-15 07:55 UTC] 4yuinfo at gmail dot com
-Status: Feedback +Status: Closed
 [2012-10-15 07:55 UTC] 4yuinfo at gmail dot com
discovery of errors raised
---------------------------------------------------------------
database use [ Dedicated server ]
so client tnsname.ora setting use (SERVER=DEDICATED)
php-fpm + nginx have 502 bad
---------------------------------------------------------------
chang client tnsname.ora setting (SERVER=SHARED)
php-fpm + nginx is working
---------------------------------------------------------------
 [2013-01-03 03:41 UTC] haris dot srafiq at gmail dot com
OS : Centos 5.7 final x86_64 
INSTANT CLIENT :11.2.0.3-1 x86_64 
PHP : 5.3.14 
Webserver : nginx 1.2.4 and apache 
2.2.23

configure --enable-fpm --with-
oci8=shared,instantclient,/usr/lib/or
acle/11.2/client64/lib --with-pdo-
oci=instantclient,/usr,11.2 --
prefix=/usr/local/php5 

edit php.ini
add extension=oci8.so 

Reload php-fpm Service 


solved my problem 

sorry my bad english
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 23:01:29 2024 UTC