2008
Wie baue ich eine OCI Modul für PHP5 und Apache2?
Benötigt wird:
Bei SuSE 10.X
- autoconf
- php5-5.X
- apache2-mod_php5-5.X
- php5-pdo-5.2.0-10
- php5-devel-5.X
- php5-pear-5.X
- instant client for Oracle http://www.oracle.com/technology/tech/oci/instantclient/index.html)
- instantclient-basic-linux-*.zip und instantclient-sdk-linux-*.zip
- http://pecl.php.net/get/oci8 (oci8-1.2.3.tgz)
Anlegen von mkdir /opt/oracle
Auspacken der Zip-Dateien in den Ordner /opt/oracle/instantclient_10_2
Link anlegen
cd /opt/oracle/instantclient_10_2
ln -s libclntsh.so.10.1 libclntsh.so
Test ob Oracle vorhanden:
echo $ORACLE_HOME
Anlegen der Pfade in der Datei /etc/profile
ORACLE_HOME=/opt/oracle/instantclient_10_2
LD_LIBRARY_PATH=$ORACLE_HOME
export ORACLE_HOME
export LD_LIBRARY_PATH
Der gleiche Eintrag muss auch noch in
/etc/init.d/apache2
Tip: vom System abmelden und wieder anmelden
cd /opt/oracle/
wget http://pecl.php.net/get/oci8
pear5 install oci8-1.2.3.tgz
—————————-Meldung ———————————
10 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Please provide the path to ORACLE_HOME dir. Use ‘instantclient,/path/to/instant/client/lib’
if you’re compiling against Oracle Instant Client [autodetect] :
—————————-Meldung ———————————
Eingeben von: instantclient,/opt/oracle/instantclient_10_2
Nach der Installation:
Die Datei /etc/php5/conf.d/oci.ini anlegen mit dem Inhalt:
; comment out next line to disable oci extension in php
extension=oci8.so
Test der Installation:
php /usr/share/doc/packages/php5/test.php5 | grep oci8
Apache2 Restarten
Testseite anlegen und ausführen:
Da wir keine tnsnamesora verwenden ändert sich der Aufruf:
—————————-Meldung ———————————
< ?php
$conn = OCILogon(”dbuser”, “dbpasswd”, “//dbserver.host.net/DB”);
$query = ’select table_name from user_tables’;
$stid = OCIParse($conn, $query);
OCIExecute($stid, OCI_DEFAULT);
while ($succ = OCIFetchInto($stid, $row)) {
foreach ($row as $item) {
echo $item.” “;
}
echo ”
\n”;
}
OCILogoff($conn);
?>
—————————-Meldung ———————————
Links:
http://www.oracle.com/technology/tech/php/index.html
http://en.opensuse.org/Howto_build_oci8_extension_module_for_php

