Document type | Technical information
Category | Interface/Integration
Applicable product version | Tibero 7
Document number | TIITI072
Overview
This document provides instructions for connecting PHP and Tibero using TBOCI.
It describes the procedure for connecting to Tibero 7 FS02 PS06 using OCI8 3.0.1 and Oracle Client 10.2 in a PHP 8.4.26 environment.
Test environment: RHEL 8.4 / PHP 8.4.26 / OCI8 3.0.1 / Oracle Client 10.2 / Tibero 7 FS02 PS06
*** When integrating TBOCI, Oracle Client 10.x must be used according to Tibero's compatibility assurance scope.
Method
1. Check OS packages
Check the packages required to build PHP.
[root@Gdb1 ~]# rpm -q gcc gcc-c++ make autoconf bison re2c \ pkgconf-pkg-config libxml2-devel openssl-devel \ zlib-devel oniguruma-devel sqlite-devel glibc-devel
Check the packages required to integrate the Oracle Client and TBOCI libraries.
[root@Gdb1 ~]# rpm -q libaio libaio-devel
2. Create a user and set environment variables
Create an account to use for PHP installation and integration.
[root@Gdb1 ~]# useradd php84
Set the user's environment variables.
[root@Gdb1 ~]# su - php84
[php84@Gdb1:/home/php84]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
stty erase ^H
### User ENV ###
export PS1="[`whoami`@`hostname`:\$PWD]$ "
export EDITOR=vim
### JAVA ENV ###
export JAVA_HOME=/etc/alternatives/jre_1.8.0
export JDK_HOME=$JAVA_HOME
### PHP ENV ###
export PHP_HOME=/home/php84/php84
export PHP_SRC=/home/php84/php-8.4.26
### Oracle Instant Client 10.2 ###
export ORACLE_HOME=/home/php84/instantclient_10_2
### Tibero Client ###
export TB_HOME=/home/php84/tibero7
export TB_SID=tibero
### Library Path ###
export LD_LIBRARY_PATH=$TB_HOME/lib:$TB_HOME/client/lib:$ORACLE_HOME
### Include Path ###
export C_INCLUDE_PATH=$TB_HOME/client/include:$ORACLE_HOME/include
### PATH ###
export PATH=$JAVA_HOME/bin:$TB_HOME/bin:$TB_HOME/client/bin:$PHP_HOME/bin:/bin:/usr/local/bin:/usr/bin:/webserver/bin:/lib/system:/home/php84/.local/bin:/home/php84/bin:/usr/local/sbin:/usr/sbin
[php84@Gdb1:/home/php84]$ source ~/.bash_profile
3. Install PHP
Extract the PHP source package.
[php84@Gdb1:/home/php84]$ cd /home/php84
[php84@Gdb1:/home/php84]$ tar -xzf php-8.4.26.tar.gz
Move to the PHP source directory and run configure.
[php84@Gdb1:/home/php84]$ cd /home/php84/php-8.4.26
[php84@Gdb1:/home/php84/php-8.4.26]$ CFLAGS="-fPIE" \
LDFLAGS="-pie" \
./configure \
--prefix=/home/php84/php84 \
--enable-fpm \
--with-config-file-path=/home/php84/php84/etc \
--with-config-file-scan-dir=/home/php84/php84/etc/php.d \
--enable-mbstring \
--enable-pdo \
--with-pdo-mysql \
--enable-sockets \
--with-zlib \
--with-libdir=lib64
Note
CFLAGS and LDFLAGS are specified to resolve the PIE-related linker error that occurred when compiling PHP in the test environment. Whether these settings are required may vary depending on the OS and compiler environment.
Compile and install the PHP source.
[php84@Gdb1:/home/php84/php-8.4.26]$ make -j2
[php84@Gdb1:/home/php84/php-8.4.26]$ make install
Check the PHP version.
[php84@Gdb1:/home/php84/php-8.4.26]$ $PHP_HOME/bin/php -v
PHP 8.4.26 (cli) (built: Nov 2 2026 16:10:52) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.26, Copyright (c) Zend Technologies
4. Install Oracle Client 10.2
Extract the Oracle Client SDK and Basic packages.
[php84@Gdb1:/home/php84/php-8.4.26]$ cd
[php84@Gdb1:/home/php84]$ unzip sdk-10.2.0.5.0-linux-x64.zip
[php84@Gdb1:/home/php84]$ unzip basic-10.2.0.5.0-linux-x64.zip
Check the Oracle Client installation.
[php84@Gdb1:/home/php84]$ cd $ORACLE_HOME
[php84@Gdb1:/home/php84/instantclient_10_2]$ ls -al
total 108378
drwxr-xr-x 3 php84 dba 4096 Nov 3 13:47 .
drwx------ 17 php84 dba 4096 Nov 3 13:47 ..
-rw-rw-r-- 1 php84 dba 228 Apr 20 2010 BASIC_README
-r--r--r-- 1 php84 dba 1621582 Apr 20 2010 classes12.jar
-rwxrwxr-x 1 php84 dba 70742 Apr 20 2010 genezi
-rwxrwxr-x 1 php84 dba 25306574 Apr 20 2010 libclntsh.so.10.1
-r-xr-xr-x 1 php84 dba 7856305 Apr 20 2010 libnnz10.so
-rwxrwxr-x 1 php84 dba 1669888 Apr 20 2010 libocci.so.10.1
-rwxrwxr-x 1 php84 dba 72703820 Apr 20 2010 libociei.so
-r-xr-xr-x 1 php84 dba 150417 Apr 20 2010 libocijdbc10.so
-r--r--r-- 1 php84 dba 1569316 Apr 20 2010 ojdbc14.jar
drwxrwxr-x 4 php84 dba 4096 Apr 20 2010 sdk
5. Install and configure Tibero Client
Extract the Tibero Client package.
[php84@Gdb1:/home/php84/instantclient_10_2]$ cd
[php84@Gdb1:/home/php84]$ tar xvzf tibero7-bin-FS02_PS06-linux64_4.18-322442-20260806141521.tar.gz
Check the Tibero Client installation.
[php84@Gdb1:/home/php84]$ cd $TB_HOME
[php84@Gdb1:/home/php84/tibero7]$ ls -al
total 12
drwxr-xr-x 9 php84 dba 4096 Aug 6 14:47 .
drwx------ 18 php84 dba 4096 Nov 3 13:49 ..
drwxr-xr-x 3 php84 dba 4096 Aug 6 14:47 bin
drwxr-xr-x 7 php84 dba 4096 Aug 6 14:47 client
drwxr-xr-x 2 php84 dba 4096 Aug 6 14:47 config
drwxr-xr-x 2 php84 dba 4096 Aug 6 14:47 lib
drwxr-xr-x 3 php84 dba 4096 Aug 6 14:47 license
drwxr-xr-x 3 php84 dba 4096 Aug 6 14:47 nls
drwxr-xr-x 7 php84 dba 8192 Aug 6 14:47 scripts
Create the Tibero environment configuration file.
[php84@Gdb1:/home/php84/tibero7]$ sh $TB_HOME/config/gen_tip.sh
Set the database connection information.
[php84@Gdb1:/home/php84/tibero7]$ vi $TB_HOME/client/config/tbdsn.tbr
tibero=(
(INSTANCE=(HOST=localhost)
(PORT=8629)
(DB_NAME=tibero7)
)
)
6. Install OCI8 and integrate TBOCI
Extract the OCI8 source package.
[php84@Gdb1:/home/php84/tibero7]$ cd
[php84@Gdb1:/home/php84]$ tar -xvzf oci8-3.0.1.tgz
Modify the OCI8 source.
[php84@Gdb1:/home/php84]$ cd /home/php84/oci8-3.0.1
[php84@Gdb1:/home/php84/oci8-3.0.1]$ grep -n 'php_strtolower' oci8.c
1042: php_strtolower(ZSTR_VAL(hashed_details.s), ZSTR_LEN(hashed_details.s));
2160: php_strtolower(ZSTR_VAL(spool_hashed_details.s), ZSTR_LEN(spool_hashed_details.s));
[php84@Gdb1:/home/php84/oci8-3.0.1]$ sed -i 's/php_strtolower(/zend_str_tolower(/g' oci8.c
[php84@Gdb1:/home/php84/oci8-3.0.1]$ grep -n 'tolower' oci8.c
1042: zend_str_tolower(ZSTR_VAL(hashed_details.s), ZSTR_LEN(hashed_details.s));
2160: zend_str_tolower(ZSTR_VAL(spool_hashed_details.s), ZSTR_LEN(spool_hashed_details.s));
Note
To resolve the source compatibility issue that occurred when building PHP 8.4.26 and OCI8 3.0.1, change the php_strtolower() calls in the oci8.c file to zend_str_tolower(). This modification was applied in the test environment and requires separate verification with other PHP and OCI8 versions.
After modifying the source, create the configuration files required to build the PHP extension module.
[php84@Gdb1:/home/php84/oci8-3.0.1]$ /home/php84/php84/bin/phpize
Configuring for:
PHP Version: 8.4
PHP Api Version: 20240924
Zend Module Api No: 20240924
Zend Extension Api No: 420240924
Copy the Oracle Client SDK header files to the Tibero Client include directory.
[php84@Gdb1:/home/php84/oci8-3.0.1]$ cd
[php84@Gdb1:/home/php84]$ cp $ORACLE_HOME/sdk/include/* $TB_HOME/client/include/
Copy the provided TBOCI library and version information file to the Tibero Client client/lib directory.
[php84@Gdb1:/home/php84]$ cp libtboci.so $TB_HOME/client/lib/
[php84@Gdb1:/home/php84]$ cp libtbOCI_info $TB_HOME/client/lib/
Note
The TBOCI library is not included in the Tibero engine, so the library file (libtboci.so) and version information file (libtbOCI_info) must be provided separately.
These files can be downloaded from the official Tibero download page.
Check whether the TBOCI library and version information file have been placed correctly.
[php84@Gdb1:/home/php84]$ ls -l $TB_HOME/client/lib/libtboci.so
[php84@Gdb1:/home/php84]$ ls -l $TB_HOME/client/lib/libtbOCI_info
[php84@Gdb1:/home/php84]$ cd $TB_HOME/client/lib
[php84@Gdb1:/home/php84/tibero7/client/lib]$ ./libtbOCI_info
Get tbOCI Build Version Success!!!
Build Version: 7 r305427
Create symbolic links so that the TBOCI library can be referenced using the Oracle Client library name.
[php84@Gdb1:/home/php84]$ cd $TB_HOME/client/lib
[php84@Gdb1:/home/php84/tibero7/client/lib]$ ln -s libtboci.so libclntsh.so.10.1
[php84@Gdb1:/home/php84/tibero7/client/lib]$ ln -s libclntsh.so.10.1 libclntsh.so
[php84@Gdb1:/home/php84/tibero7/client/lib]$ ln -s /home/php84/instantclient_10_2/libnnz10.so libnnz10.so
Check the symbolic link creation results.
[php84@Gdb1:/home/php84/tibero7/client/lib]$ ls -l | grep '^l'
lrwxrwxrwx 1 php84 dba 17 Nov 2 16:56 libclntsh.so -> libclntsh.so.10.1
lrwxrwxrwx 1 php84 dba 11 Nov 2 16:56 libclntsh.so.10.1 -> libtboci.so
lrwxrwxrwx 1 php84 dba 42 Nov 2 16:57 libnnz10.so -> /home/php84/instantclient_10_2/libnnz10.so
Move to the OCI8 source directory and run configure.
[php84@Gdb1:/home/php84/tibero7/client/lib]$ cd /home/php84/oci8-3.0.1
[php84@Gdb1:/home/php84/oci8-3.0.1]$ ./configure \
--with-php-config=/home/php84/php84/bin/php-config \
--with-oci8=shared,/home/php84/tibero7/client
Check whether the OCI8 extension module references the TBOCI library.
[php84@Gdb1:/home/php84/oci8-3.0.1]$ make -j2
[php84@Gdb1:/home/php84/oci8-3.0.1]$ make install
Installing shared extensions: /home/php84/php84/lib/php/extensions/no-debug-non-zts-20240924/
Compile and install the OCI8 extension module.
[php84@Gdb1:/home/php84/oci8-3.0.1]$ ldd /home/php84/php84/lib/php/extensions/no-debug-non-zts-20240924/oci8.so
linux-vdso.so.1 (0x00007ffda43af000)
libtboci.so => /home/php84/tibero7/client/lib/libtboci.so (0x00001519dfd6e000)
libc.so.6 => /lib64/libc.so.6 (0x00001519df998000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00001519df778000)
libdl.so.2 => /lib64/libdl.so.2 (0x00001519df574000)
libm.so.6 => /lib64/libm.so.6 (0x00001519df1f2000)
librt.so.1 => /lib64/librt.so.1 (0x00001519defea000)
/lib64/ld-linux-x86-64.so.2 (0x00001519e1cda000)
Create the PHP configuration directory and copy the default PHP configuration file.
[php84@Gdb1:/home/php84/oci8-3.0.1]$ cd
[php84@Gdb1:/home/php84]$ mkdir -p /home/php84/php84/etc/php.d
[php84@Gdb1:/home/php84]$ cp /home/php84/php-8.4.26/php.ini-development /home/php84/php84/etc/php.ini
Modify the php.ini file to register the OCI8 extension module.
[php84@Gdb1:/home/php84]$ vi /home/php84/php84/etc/php.ini
extension=oci8.so
Check whether the OCI8 module loads normally.
[php84@Gdb1:/home/php84]$ /home/php84/php84/bin/php --ri oci8
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 3.0.1
Oracle Run-time Client Library Version => 10.2.0.0.0
Oracle Compile-time Version => 10.2
Compile-time ORACLE_HOME => /home/php84/tibero7/client
Libraries Used => -Wl,-rpath,/home/php84/tibero7/client/lib -L/home/php84/tibero7/client/lib -lclntsh
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.events => Off => Off
Statistics =>
Active Persistent Connections => 0
Active Connections => 0
7. Test the Tibero connection
Create a Tibero connection test script using OCI8.
[php84@Gdb1:/home/php84]$ vi /home/php84/oci_test.php
<?php
$conn = oci_connect('sys', 'tibero', 'tibero');
if (!$conn) {
$e = oci_error();
echo "Connection failed: " . $e['message'] . PHP_EOL;
exit(1);
}
echo "Tibero OCI8 Connection Success" . PHP_EOL;
$sql = "SELECT 'Tibero OCI8 Test' AS MSG FROM DUAL";
$stmt = oci_parse($conn, $sql);
if (!oci_execute($stmt)) {
$e = oci_error($stmt);
echo "SQL Error: " . $e['message'] . PHP_EOL;
exit(1);
}
$row = oci_fetch_assoc($stmt);
print_r($row);
oci_free_statement($stmt);
oci_close($conn);
?>
Run the test script to check the Tibero connection and SQL execution results.
[php84@Gdb1 ~]$ $PHP_HOME/bin/php /home/php84/oci_test.php
Tibero OCI8 Connection Success
Array
(
[MSG] => Tibero OCI8 Test
)