- 配置好 oracle 客户端
zypper in apache2
zypper in apache2-mod_php8
zypper in php8-devel
C_INCLUDE_PATH=/usr/lib/oracle/21/client64 pecl install oci8
instantclient,/usr/lib/oracle/21/client64
成功后按提示改下php.ini,extension=oci8.so(这里要重写,php.ini 中有但是后面没有.so,注意)
Build process completed successfully
Installing '/usr/lib64/php8/extensions/oci8.so'
install ok: channel://pecl.php.net/oci8-3.2.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini
测试一下连接:
$conn = oci_connect($username,$password,$sid,'UTF8');
$stid = oci_parse($conn,$sql);
oci_execute($stid);
echo "<table>\n";
while (($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>".($item !== null ? htmlentities($item, ENT_QUOTES) : " ")."</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
|