PHP + Oracle environment in Linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.