可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I want to connect to my oracle database, but i have a problem with function oci_connect. i have tried to uncomment this:
extension=php_oci8.dll
but, still have an error :
Fatal error: Call to undefined function oci_connect() in C:\xampp\htdocs\testing\db.php on line 71
But, when i check in phpinfo(), oci8 still not loaded and i can not connect to my oracle database. i already restart my apache. How i fix this problem ? Canyou help me?
Thank you..
回答1:
In php.ini
ensure that you enable the correct OCI extension (11g), like this:
;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client
extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client
As long as you've got Oracle 11gR2 or greater client libraries correctly installed you should now be able to run:
C:\>php --ri oci8
And get the result:
oci8
OCI8 Support => enabled
Version => 1.4.10
Revision => $Id: b0984d94e17f7c099470cd0a9404259f2a59da04 $
Active Persistent Connections => 0
Active Connections => 0
Oracle Run-time Client Library Version => 11.2.0.3.0
Oracle Instant Client Version => 11.2
Temporary Lob support => enabled
Collections support => enabled
Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off
To check your Oracle client is installed correctly (i.e., in your environment PATH
variable) you can run:
C:\>where oci*
You should get a result like this:
C:\instantclient_11_2\oci.dll
C:\instantclient_11_2\oci.sym
C:\instantclient_11_2\ocijdbc11.dll
C:\instantclient_11_2\ocijdbc11.sym
C:\instantclient_11_2\ociw32.dll
C:\instantclient_11_2\ociw32.sym
回答2:
In Ubuntu 16.04, using PHP 5.6, with 64bit os, try this:
Install the packages:
sudo apt-get install php5.6-dev build-essential php-pear libaio1
Download the latest version of the packages from:
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
Search for these packages, according with the latest version:
oracle-instantclientXX.X-basic-XX.X.X.X.X-X.x86_64.rpm
oracle-instantclientXX.X-devel-XX.X.X.X.X-X.x86_64.rpm
Converting packages:
sudo apt-get install alien
sudo alien oracle-instantclientXX.X-basic-XX.X.X.X.X-X.x86_64.rpm
sudo alien oracle-instantclientXX.X-devel-XX.X.X.X.X-X.x86_64.rpm
Installing:
sudo dpkg -i oracle-instantclientXX.X-basic_XX.X.X.X.X-X_amd64.deb
sudo dpkg -i oracle-instantclientXX.X-devel_XX.X.X.X.X-X_amd64.deb
Installing oci8:
sudo pecl install oci8-2.0.12
*Build process completed successfully
Installing '/usr/lib/php/20131226/oci8.so'
install ok: channel://pecl.php.net/oci8-2.0.12
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini*
Add the extension to php:
sudo gedit /etc/php/5.6/apache2/php.ini
add the extension:
extension=oci8.so
Restart apache:
sudo service apache2 restart
That's it.
回答3:
Follow the offcial link for me Oracle
http://www.oracle.com/technetwork/articles/dsl/technote-php-instant-084410.html
Here is what worked with Xammp
1.uncomment extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client if you are using 11g (in php.ini)
2.add AddHandler fcgid-script .php to httpd.conf
3.Download the FastCGI component mod_fcgid-2.3.6-win32-x86.zip from httpd.apache.org/download.cgi#mod_fcgid
4.Unzip it to the installed Apache 2.2 directory. The C:\xamp\apache\modules directory should now have mod_fcgid.so and mod_fcgid.pdb files.
5.Download the "Instant Client Package - Basic" for Windows from the OTN Instant Client page. Because PHP is 32 bit, use the 32 bit version of Instant Client.
Unzip the Instant Client files to C:\instantclient_11_2
Edit the Windows PATH environment setting and add C:\instantclient_11_2. For example, on Windows XP, follow Start -> Control Panel -> System -> Advanced -> Environment Variables and edit PATH in the System variables list.
Commonly you need to reboot Windows so the new environment is correctly set.
that worked for me all the best
回答4:
Have a look at RO_engineer's answer of installing x86 files of Oracle insta client rather than x64 version. It resolved my issue, may be that can help you too.
https://stackoverflow.com/a/27177616/289587
Download Instant Client for Microsoft Windows (32-bit)