php配置oci8

來源:互聯網
上載者:User

標籤:ice   php版本   option   log   gnu   版本   programs   package   構建環境   

1.下載oracle client rpm

Instant Client for Linux    http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64
oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64

$rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm 

$rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

 

這裡下這兩個就可以,然後安裝

 

隨即會在這個目錄下產生.so的檔案

/usr/lib/oracle/11.2/client64/lib

$ls /usr/lib/oracle/11.2/client64/lib

$echo /usr/lib/oracle/11.2/client64/lib/ > /etc/ld.so.conf.d/oracle_client.conf

At this point, you‘re ready to register your newly-installed libraries:

$ldconfig -v

2.配置phpize

下載的版本要和php版本一致,不然裝不了

http://rpm.pbone.net/index.php3/stat/4/idpl/24668595/dir/scientific_linux_6/com/php-devel-5.3.3-26.el6.x86_64.rpm.html   

php-devel-5.3.3-26 x86_64 download

 

phpize,一種構建工具,為php擴充準備構建環境。

[[email protected] tmp]# rpm -ivh php-devel-5.3.3-26.el6.x86_64.rpm

warning: php-devel-5.3.3-26.el6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEY

Preparing...                ########################################### [100%]

   1:php-devel              ########################################### [100%]

[[email protected] tmp]# whereis phpize

phpize: /usr/bin/phpize /usr/share/man/man1/phpize.1.gz

 3.配置oci8

 https://pecl.php.net/package/oci8   oci8下載

[[email protected] oci]# cd

oci8-1.3.3/     oci8-1.3.3.tgz  package.xml    

[[email protected] oci]# cd oci8-1.3.3

[[email protected] oci8-1.3.3]# ls

config.m4   CREDITS  oci8_collection.c  oci8_interface.c  oci8_statement.c  php_oci8_int.h  tests

config.w32  oci8.c   oci8.dsp           oci8_lob.c        php_oci8.h        README

[[email protected] oci8-1.3.3]# phpize

Configuring for:

PHP Api Version:         20090626

Zend Module Api No:      20090626

Zend Extension Api No:   220090626

 

When prompted, enter either the value of $ORACLE_HOME, or instantclient,/path/to/instant/client/lib.

Note: Do not enter the variable $ORACLE_HOME because it will not be expanded. Instead, enter the actual path of the Oracle home directory.

 

If using an RPM-based installation of Oracle Instant Client, the configure line will look like this:

./configure --with-oci8=shared,instantclient,/usr/lib/oracle/<version>/client/lib

For example, --with-oci8=shared,instantclient,/usr/lib/oracle/12.1/client/lib

Note that Oracle Instant Client support first appeared in PHP 4.3.11 and 5.0.4 and originally used the option --with-oci8-instant-client to configure PHP.

 

[[email protected] oci8-1.3.3]# ./configure -with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib

....

checking for cc option to produce PIC... -fPIC -DPIC

checking if cc PIC flag -fPIC -DPIC works... yes

checking if cc static flag -static works... no

checking if cc supports -c -o file.o... yes

checking if cc supports -c -o file.o... (cached) yes

checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes

checking whether -lc should be explicitly linked in... no

checking dynamic linker characteristics... GNU/Linux ld.so

checking how to hardcode library paths into programs... immediate

checking whether stripping libraries is possible... yes

checking if libtool supports shared libraries... yes

checking whether to build shared libraries... yes

checking whether to build static libraries... no

configure: creating ./config.status

config.status: creating config.h

config.status: executing libtool commands

 

make install

 

Libraries have been installed in:

   /tmp/oci/oci8-1.3.3/modules

 

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR‘

flag during linking and do at least one of the following:

   - add LIBDIR to the `LD_LIBRARY_PATH‘ environment variable

     during execution

   - add LIBDIR to the `LD_RUN_PATH‘ environment variable

     during linking

   - use the `-Wl,-rpath -Wl,LIBDIR‘ linker flag

   - have your system administrator add LIBDIR to `/etc/ld.so.conf‘

 

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

----------------------------------------------------------------------

Installing shared extensions:     /usr/lib64/php/modules/

 

 

$echo extension=oci8.so > /etc/php.d/oci8.ini

 

$/etc/init.d/httpd restart

 oci8的安裝官方文檔參考如下:

http://php.net/manual/en/oci8.installation.php

 

 4.驗證下php能否連上oracle資料庫:

可以看到phpinfo中的資訊oci8模組已經載入了 

 

[[email protected] html]# more get_dbinfo.php
<?php
$db_connect = oci_connect(‘system‘, ‘xxx‘, ‘(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1
30.131)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = deff)))‘);

$sql_query = oci_parse($db_connect, ‘select status from v$instance‘);
oci_execute($sql_query,OCI_DEFAULT);
##echo $sql_query
while($r=oci_fetch_row($sql_query))
{
echo $r[0];
echo "<BR>";
}
?>
[[email protected] html]# php get_dbinfo.php
OPEN<BR>[[email protected] html]#

 

在這裡,關於php的配置全部完成,後面就是關於一些php與資料庫,與shell指令碼相結合做出html介面的東西。

 

=============ENDED============

 

php配置oci8

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.