Oracle 10g Instant Client

Source: Internet
Author: User
Tags php software

Enable PHP OCI8 extension on Linux
To add an Oracle connection to Linux, You need to recompile PHP.
1. Download and install Apache

  1. Cd apache_1.3.31
  2. ./Configure -- prefix =/usr/local/apache \
  3. -- Enable-module = so \
  4. -- Enable-shared = max \
  5. -- Enable-module = most
  6. Make
  7. Make install
-- Enable-module = so module is used to provide the apachehe core module supported by DSO.
-- Enable-shared = all the standard modules except so of max are compiled into DSO modules (so cannot be compiled into DSO)
-- Enable-module = most: Compile modules that are not in the default common modules into Apache
2. Download and decompress the Instant Client
Instantclient-odbc-linux32, instantclient-jdbc-linux32 according to your own needs whether decompression.
  1. Unzip instantclient-basic-linux32-10.2.0.3-20061115.zip-d/tmp
  2. Unzip instantclient-sdk-linux32-10.2.0.3-20061115.zip-d/tmp
  3. Unzip instantclient-sqlplus-linux32-10.2.0.3-20061115.zip-d/tmp
  4. Mv instantclient_10_2/usr/local
  5. Export LD_LIBRARY_PATH =/usr/local/instantclient_10_2
  6. Cd $ LD_LIBRARY_PATH
  7. Ln-s libclntsh. so.10.1 libclntsh. so
  8. Ln-s libocci. so.10.1 libocci. so is not created during actual installation.
  9. This connection is not created when ln-s libsqora. so.10.1 libsqora. so is installed.
3. Download and install php
  1. Tar-xvzf php-5.2.3.tar.gz
  2. ./Configure -- prefix =/usr/local/php \
  3. -- With-apxs =/usr/local/apache/bin/apxs \
  4. -- With-oci8 = instantclient, $ LD_LIBRARY_PATH \
  5. -- Enable-sigchild
  6. Make
  7. Make install
  8. Cp php. ini-dist/usr/local/lib/php. ini
4. Edit/usr/local/apache/conf/httpd. conf and add:
  1. AddType application/x-httpd-php. php
  2. AddType application/x-httpd-php-source. phps
  3. ServerName 127.0.0.1
  4. DocumentRoot "/var/www"
  5. <Directory "/var/www">
  6. DirectoryIndex index.html index. php
5. Test OCI8 support
<? Php phpinfo ();?>
The browser page should contain an "OCI8" section showing "oci8 Support enabled.
6. test connection to Oracle
(A) sqlplus
  1. Export LD_LIBRARY_PATH =/usr/local/instantclient_10_2
  2. Export TNS_ADMIN =/usr/local/instantclient_10_2
  3. The content of the sqlnet. ora file is as follows:
  4. SQLNET. AUTHENTICATION_SERVICES = (CNT)
  5. NAMES. DIRECTORY_PATH = (TNSNAMES)
  6. The content of the tnsnames. ora file is as follows:
  7. Test =
  8. (DESCRIPTION =
  9. (ADDRESS_LIST =
  10. (ADDRESS = (PROTOCOL = TCP) (HOST = xxx. xxx) (PORT = 1521 ))
  11. )
  12. (CONNECT_DATA =
  13. (SID = test)
  14. )
  15. )
  16. ./Sqlplus user/passwd @ test
(B) php
  1. Vi/etc/rc. local
  2. Export LD_LIBRARY_PATH =/usr/local/instantclient_10_2
  3. Export TNS_ADMIN =/usr/local/instantclient_10_2
  4. Export NLS_LANG = "SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
  5. /Usr/local/apache/bin/apachectl start
  6. Vi/var/www/testoci. php
  7. <? Php
  8. $ Conn = ocilogon ("user", "passwd", "test ");
  9. $ Query = 'select table_name from user_tables ';
  10. $ Stid = ociparse ($ conn, $ query );
  11. Ociexecute ($ stid, OCI_DEFAULT );
  12. While ($ succ = ocifetchinto ($ stid, $ row ))
  13. {
  14. Foreach ($ row as $ item) {echo $ item ."";}
  15. Echo "<br> \ n ";
  16. }
  17. Ocilogoff ($ conn );
  18. ?>
Pass in FC3.
Enable PHP OCI8 extension on Windows
1. Download the Instant Client Basic Package for Windows from the Instant Client page of OTN.
2. Create a sub-directory (for example, c: \ instantclient10_1) and copy the following library from the compressed file:
Oraociei10.dll, orannzsbb10.dll, oci. dll
To use an earlier version of the "oracle" extension of PHP (Enabled with "extension = php_oracle.dll" in php. ini), copy ociw32.dll instead of oci. dll.
3. Add c: \ instantclient10_1 to PATH (before other Oracle Directories ).
If the tnsnames. ora file is used to define the Oracle Net service name, copy tnsnames. ora to c: \ instantclient10_1 and set the user environment variable TNS_ADMIN to c: \ instantclient10_1. You can also define the default service name in the LOCAL environment variable.
Set the required Oracle global language environment variables, such as NLS_LANG. If this parameter is not set, the default local environment is used. For more details, see the overview of Oracle PHP application globalization.
You do not need to set unnecessary Oracle variables, such as ORACLE_HOME and ORACLE_SID.
4. Edit php. ini and do not set the OCI8 extension as a comment:
Extension = php_oci8.dll
Set the extension_dir command to the complete PHP extension DLL path. In PHP 4, the DLL is located in the "extensions" subdirectory of the PHP software. In PHP 5, they are located in "ext.
5. Restart Apache.

Related Article

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.