How to connect to Oracle8i with PHP4 in Linux

Source: Internet
Author: User

This article describes how to use PHP4 to connect Oracle8i in a Linux environment.

1. Download and install Oracle 8i for linux. Complete installation. Do not only install the client.

2. Download The PHP3 or PHP4 source code.

3. Configure PHP installation parameters:

       
        for php 4:./configure with-apxs=/usr/sbin/apxsprefix=/usrwith-gdenable-versioningwith-mysql=/usrwith-oracle=/usr/local/oracle/8i/u01/app/oracle/product/8.1.5with-oci8=/usr/local/oracle/8i/u01/app/oracle/product/8.1.5with-zlibwith-dbasewith-fileprowith-config-file-path=/etc/httpd/confwith-fdftk=noenable-debug=noenable-magic-quotesenable-debuggerenable-bcmathenable-track-varsenable-safe-modewith-exec-dir=/usr/binwith-system-regexno-createno-recursion
       

The with-oracle option allows php to access Oracle 7.x or 8.xthrough the ORA _ function.

With-oci8 options allow php to use more and better oci8 functions.

4. make.

5. make install.

6. cp./php. ini-dist/wherever/your/conf/files/are/php. ini copy php. ini to the appropriate location.

7. Modify httpd. conf, such as LoadModule php4_module lib/apache/libphp4.so, and change it to LoadModule php4_module/usr/lib/apache/libphp4.so.

8. Restart APACHE.

9. test whether the installation of PHP4 is successful. Create a test. php3 with the following content: Access it in a browser to check whether ORACLE and ORACLE8 information exists. If yes, it will succeed.

10. Now use Oracle functions:

       
        
<? // Set the ORACLE environment variable putenv ("ORACLE_SID = PROD "); putenv ("ORACLE_HOME =/usr/local/oracle/8i/u01/app/oracle/product/8.1.5"); // create a connection // modify the current user_id, password, db to adapt to your configuration if ($ conn = OCILogon ("user_id", "password", "db ")) {// obtain the database information printf ("% s </P>", OCIServerVersion ($ conn) ;}else {printf ("Conncetion Failed") ;}?>
       

This section shows some information about the Oracle you are connected.

12. Others:

If you need to connect to a remote ORACLE Server, you also need to set your sqlnet. ora and tnsnames. ora to specify the location of the remote database. Ask the database administrator to copy some files to the $ ORACLE_HOME/network/admin/directory.

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.