Very troublesome
Record my tossing process
First, PHP Compilation
After setting Oracle environment variables
Oracle_base =/opt/Oracle; export oracle_base
ORACLE_HOME = $ oracle_base/product/10.2.0.1/db_1; export ORACLE_HOME
Add
With-oci8
Subsequent errorsOCIEnvNlsCreate() failed It's a very troublesome thing.
You can see ORACLE_HOME in oci8 in phpinfo ().
But I cannot find it when I use it.
I have read many documents and tried it multiple times.
My method
For 10 GB
First
chmod -R a+x $ ORACLE_HOME
Or
Chmod-r o + RX $ ORACLE_HOME
Write another test
<? PHP
// PHP connection to Oracle Functions
Function php_conn_ora (){
$ Username = 'your username ';
$ Passwd = 'your password ';
$ Protocol = 'tcp ';
$ SERVICE_NAME = 'you SERVICE_NAME or Sid ';
$ Oracle_server_ip_address = 'your Oracle ip ';
$ Port = '000000 ';
Putenv ("nls_lang = simplified chinese_china.al32utf8 ");
If (! $ Conn = oci_pconnect ($ username, $ passwd, "(description = (address_list = (address = (Protocol = $ Protocol) (host = $ oracle_server_ip_address) (Port = $ port) (CONNECT_DATA = (SERVICE_NAME = $ SERVICE_NAME) ") echo (" error in connecting to Database ");
Return $ conn;
}
// Query function
Function ora_query ($ SQL ){
Global $ conn_ora;
$ Result = oci_parse ($ conn_ora, $ SQL );
Oci_execute ($ result, oci_default );
Return $ result;
}
// Echo environment variable
$ ORACLE_HOME = getenv ("ORACLE_HOME ");
Echo "ORACLE_HOME = $ ORACLE_HOME
/N ";
$ LD_LIBRARY_PATH = getenv ("LD_LIBRARY_PATH ");
Echo "LD_LIBRARY_PATH = $ LD_LIBRARY_PATH
/N ";
$ Path = getenv ("path ");
Echo "Path = $ path
/N ";
// Connection test
$ Conn_ora = php_conn_ora ();
$ SQL = "select * From sometable where rownum <= 2 ";
$ Result = ora_query ($ SQL );
Oci_fetch_all ($ result, $ array );
Echo "<PRE> ";
Var_dump ($ array );
Echo "</PRE> ";
?>
Then you can try to add environment variables in three places.
Apachectl
Apache user bash
/Etc/profile
Not reported
Ocienvnlscreate () failed
References
http://blog.cn-ic.org/?p=94