Installation steps:
1. Install oracle-instantclient
Download address: http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
Download oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
Download
oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
Place it in the /usr/packages/ directory
# rmp -ivh oracle-instantclient*
The /usr/lib/oracle/11.2/client/lib/ directory will be generated at this time
*Note: Download the corresponding database version
2. Modify the /etc/ld.so.conf configuration file
Add some content:
/usr/lib/oracle/11.2/client/lib/
Execute command # ldconfig
3. Install oci8
Download the latest oci8 components
Download address: http://pecl.php.net/package/oci8
Download oci-2.0.8.tgz
Place it in the /usr/packages/ directory
# tar -xvzf oci-2.0.8.tgz # cd oci-2.0.8 # /usr/local/php/bin/phpize (用phpize生成configure配置文件) # ./configure --with-php-config=/usr/local/php/bin/php-config --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client/lib # make && make install
After success, you will be informed that oci8.so has been successfully placed in the following directory
4. Configure PHP to support OCI extension
Modify php configuration file
# vi /usr/local/php/lib/php.ini file
Append the following content after the extension item
extension=oci8.so
5. Restart the Apache service test
# apachectl restart
Use the probe function phpinfo() to check whether the extension is enabled. If the following picture appears, it means the extension is enabled
6. Test database connection
Write oracle.php in the site root directory
The code is as follows:
<?php $conn = ocilogon('test','test','192.168.23.131:1521/dev'); if (!$conn) { $Error = oci_error(); print htmlentities($Error['message']); exit; } else { echo "Connected Oracle Successd!"."<br>"; ocilogoff($conn); } ?>
Enter http://192.168.1.131/oracle.php in the browser address bar
Explanation: 192.168.1.131 is the server address, which directly points to the site and directory of the server Apache.
Display Connected Oracle Successd! indicates that the database connection is successful.
Please explain the specific meaning of "not easy to use". It needs to be analyzed based on the specific situation. If it prompts that there is no such function, then you should use ocilogon to replace this function.
$dbhost = "192.168.0.111"; $dbuser = "system"; $dbpasswd = "manager "; $dbname = "192.168.0.111"; if(@$conn=OCILogon($dbuser,$ dbpasswd,$dbname)): echo "Connection successful!"; else: echo "Connection failed!"; endif; OCILogoff($conn); ?>