14/08/2023, 21:03 Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.
4 · GitHub
Instantly share code, notes, and snippets.
eSkiSo / install_oci8_ubuntu20_php7.4.md
Created 2 years ago
Star
Code Revisions 1 Stars 33 Forks 16
Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.4
install_oci8_ubuntu20_php7.4.md
Install OCI8 on Ubuntu 20.04 with PHP
7.4
Step 1
Download Oracle Instant Client and SDK from Oracle:
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
Download files:
Basic Package (ZIP): instantclient-basic-linux.x64-21.1.0.0.0.zip
SDK Package (ZIP): instantclient-sdk-linux.x64-21.1.0.0.0.zip
Step 2
Create new folders for Oracle Instant Client on server
sudo mkdir /usr/lib/oracle
sudo mkdir /usr/lib/oracle/21.1
sudo mkdir /usr/lib/oracle/21.1/client64
https://gist.github.com/eSkiSo/781269c79b4dd740e90fcc059c1985ae 1/10
14/08/2023, 21:03 Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.4 · GitHub
Step 3
Extract files
sudo cp instantclient-basic-linux.x64-21.1.0.0.0.zip /usr/lib/oracle/2
sudo cp instantclient-sdk-linux.x64-21.1.0.0.0.zip /usr/lib/oracle/21.
cd /usr/lib/oracle/21.1/client64
sudo unzip instantclient-basic-linux.x64-21.1.0.0.0.zip
sudo unzip instantclient-sdk-linux.x64-21.1.0.0.0.zip
sudo mv instantclient_21_1 lib
Step 4
Create symbolic link to the new Instant Client files:
cd /usr/lib/oracle/21.1/client64/lib/
sudo ln -s libclntsh.so.21.1 libclntsh.so (It may already exist, conti
sudo ln -s libocci.so.21.1 libocci.so (It may already exist, continue)
Step 5
Edit/Create this file with the path to the lib (for LDCONFIG):
sudo echo /usr/lib/oracle/21.1/client64/lib > /etc/ld.so.conf.d/or
Step 6
Update Dynamic Linker
ldconfig
Step 7
Install php-dev php-pear build-essential and libaio1
https://gist.github.com/eSkiSo/781269c79b4dd740e90fcc059c1985ae 2/10
14/08/2023, 21:03 Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.4 · GitHub
sudo apt-get install php-dev php-pear build-essential libaio1
Step 8
Update PECL to install OCI8 from it
sudo pecl channel-update pecl.php.net
Install OCI8 from PCEL (desired version, default seems not to find it for me, i used
php7.)
sudo pecl install oci8 (php 8)
sudo pecl install oci8-2.2.0 (php 7.)
During install it will require the path to Instant Client, write this:
instantclient,/usr/lib/oracle/21.1/client64/lib
At the end something like this should appear:
Build process completed successfully
Installing '/usr/lib/php/20190902/oci8.so'
install ok: channel://pecl.php.net/oci8-2.2.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini
Step 9
Load OCI8 into PHP
sudo echo "extension=oci8.so" >> /etc/php/7.4/cli/php.ini
Restart Apache
sudo systemctl restart apache2
https://gist.github.com/eSkiSo/781269c79b4dd740e90fcc059c1985ae 3/10
14/08/2023, 21:03 Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.4 · GitHub
Step 10
Add to mods-available
cd /etc/php/7.4/mods-available/
sudo nano oci.ini
Add this to the file:
extension = oci8.so
Step 11
Create sym link to the created ini file
cd /etc/php/7.4/apache2/conf.d
sudo ln -s /etc/php/7.4/mods-available/oci.ini 20-oci.ini
Restart Apache
sudo systemctl restart apache2
Step 12 (Testing)
Check if OCI is loaded in PHP
php -i | grep oci
Should output something like this:
oci8
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
https://gist.github.com/eSkiSo/781269c79b4dd740e90fcc059c1985ae 4/10
14/08/2023, 21:03 Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.4 · GitHub
Credits
Based on a post from Carlos Juan
https://www.cjorellana.net/2020/12/como-instalar-oci8-en-ubuntu-2004-y-
php.html
kabeza commented on Feb 18, 2022
Hi
Before step 5, you should add
sudo su -
because step 5 (and the following) will fail if you're not as root in shell
marcoriccine commented on Mar 9, 2022
Hi the process work fine till step 8, when i run "sudo pecl install oci8-2.2.0" i have got this response
Notice: Trying to access array offset on value of type bool in PEAR/REST.php on line 187
PHP Notice: Trying to access array offset on value of type bool in
/usr/share/php/PEAR/REST.php on line 187 No releases available for package
"pecl.php.net/oci8" install failed
and can't find any way to go further!!
eSkiSo commented on Mar 9, 2022
Hi the process work fine till step 8, when i run "sudo pecl install oci8-2.2.0" i have got this
response
Notice: Trying to access array offset on value of type bool in PEAR/REST.php on line
187 PHP Notice: Trying to access array offset on value of type bool in
/usr/share/php/PEAR/REST.php on line 187 No releases available for package
"pecl.php.net/oci8" install failed and can't find any way to go further!!
You on PHP7 or 8?
marcoriccine commented on Mar 10, 2022
I'm on PHP 7.4.2, have found how to "Manually Installing OCI8 on Linux as a Shared Extension"
here , but i'd like understand the pecl problem.
https://gist.github.com/eSkiSo/781269c79b4dd740e90fcc059c1985ae 5/10
14/08/2023, 21:03 Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.4 · GitHub
Episodio1 commented on Apr 25, 2022
Thanks, it worked for Kubuntu 20 with php 7.3 and Nginx (adapting some values to my scenario).
enboig commented on Jun 14, 2022
It fails for me, using kubuntu 20.04, OCI 21.6, and php7.2 (from
https://launchpad.net/~ondrej/+archive/ubuntu/php)
The error occurs on sudo pecl install oci8-2.2.0 :
...................
libtool: compile: cc -I. -I/tmp/pear/temp/oci8 -I/tmp/pear/temp/pear-build-
rootD9uBmD/oci8-2.2.0/include -I/tmp/pear/temp/pear-build-rootD9uBmD/oci8-2.2.0/main -
I/tmp/pear/temp/oci8 -I/usr/include/php/20210902 -I/usr/include/php/20210902/main -
I/usr/include/php/20210902/TSRM -I/usr/include/php/20210902/Zend -
I/usr/include/php/20210902/ext -I/usr/include/php/20210902/ext/date/lib -
I/usr/lib/oracle/21.6/client64/lib/sdk/include -DHAVE_CONFIG_H -g -O2 -
DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/oci8/oci8_interface.c -MMD -MF
oci8_interface.dep -MT oci8_interface.lo -fPIC -DPIC -o .libs/oci8_interface.o
/tmp/pear/temp/oci8/oci8_interface.c: In function ‘zif_oci_fetch_all’:
/tmp/pear/temp/oci8/oci8_interface.c:1476:3: warning: implicit declaration of function
‘Z_PARAM_ZVAL_DEREF_EX’; did you mean ‘Z_PARAM_ZVAL_EX’? [-Wimplicit-function-
declaration]
1476 | Z_PARAM_ZVAL_DEREF_EX(array, 0, 1)
| ^~~~~~~~~~~~~~~~~~~~~
| Z_PARAM_ZVAL_EX
/tmp/pear/temp/oci8/oci8_interface.c:1476:37: error: expected ‘;’ before ‘_optional’
1476 | Z_PARAM_ZVAL_DEREF_EX(array, 0, 1)
| ^
| ;
make: *** [Makefile:222: oci8_interface.lo] Error 1
ERROR: `make' failed
Any idea?
ahmadasjad commented on Jul 22, 2022
getting error for:
Ubuntu
Linux *** 5.15.0-1013-oracle #17-Ubuntu SMP Fri Jun 24 10:14:16 UTC 2022 aarch64 aarch64
aarch64 GNU/Linux
PHP 8.1.2 (cli) (built: Jun 13 2022 13:52:54) (NTS)
Followed instruction:
https://docs.oracle.com/en/cloud/paas/autonomous-database/dedicated/adbbw/index.html
https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
https://gist.github.com/eSkiSo/781269c79b4dd740e90fcc059c1985ae 6/10
14/08/2023, 21:03 Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.4 · GitHub
/bin/bash /tmp/pear/temp/pear-build-rootJI40hE/oci8-3.2.1/libtool --mode=link cc -shared -
I/tmp/pear/temp/pear-build-rootJI40hE/oci8-3.2.1/include -I/tmp/pear/temp/pear-build-
rootJI40hE/oci8-3.2.1/main -I/tmp/pear/temp/oci8 -I/usr/include/php/20210902 -
I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM -
I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext -
I/usr/include/php/20210902/ext/date/lib -I/opt/oracle/instantclient_21_7/sdk/include -
DHAVE_CONFIG_H -g -O2 -o oci8.la -export-dynamic -avoid-version -prefer-pic -module -
rpath /tmp/pear/temp/pear-build-rootJI40hE/oci8-3.2.1/modules oci8.lo oci8_lob.lo
oci8_statement.lo oci8_collection.lo oci8_interface.lo oci8_failover.lo -Wl,-
rpath,/opt/oracle/instantclient_21_7 -L/opt/oracle/instantclient_21_7 -lclntsh libtool:
link: cc -shared -fPIC -DPIC .libs/oci8.o .libs/oci8_lob.o .libs/oci8_statement.o
.libs/oci8_collection.o .libs/oci8_interface.o .libs/oci8_failover.o -
L/opt/oracle/instantclient_21_7 -lclntsh -g -O2 -Wl,-rpath -
Wl,/opt/oracle/instantclient_21_7 -Wl,-soname -Wl,oci8.so -o .libs/oci8.so /usr/bin/ld:
skipping incompatible /opt/oracle/instantclient_21_7/libclntsh.so when searching for -
lclntsh /usr/bin/ld: cannot find -lclntsh: No such file or directory /usr/bin/ld: skipping
incompatible /opt/oracle/instantclient_21_7/libclntsh.so when searching for -lclntsh
collect2: error: ld returned 1 exit status make: *** [Makefile:224: oci8.la] Error 1
ERROR: make' failed`
ahmadasjad commented on Jul 24, 2022
https://stackoverflow.com/a/73094708/2605183
enboig commented on Jul 26, 2022
My problem was having multiple PHP versions installed, it was using the wrong php-dev version.
It fails for me, using kubuntu 20.04, OCI 21.6, and php7.2 (from
https://launchpad.net/~ondrej/+archive/ubuntu/php) The error occurs on sudo pecl install
oci8-2.2.0 :
...................
libtool: compile: cc -I. -I/tmp/pear/temp/oci8 -I/tmp/pear/temp/pear-build-
rootD9uBmD/oci8-2.2.0/include -I/tmp/pear/temp/pear-build-rootD9uBmD/oci8-
2.2.0/main -I/tmp/pear/temp/oci8 -I/usr/include/php/20210902 -
I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM -
I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext -
I/usr/include/php/20210902/ext/date/lib -
I/usr/lib/oracle/21.6/client64/lib/sdk/include -DHAVE_CONFIG_H -g -O2 -
DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/oci8/oci8_interface.c -MMD -MF
oci8_interface.dep -MT oci8_interface.lo -fPIC -DPIC -o .libs/oci8_interface.o
/tmp/pear/temp/oci8/oci8_interface.c: In function ‘zif_oci_fetch_all’:
/tmp/pear/temp/oci8/oci8_interface.c:1476:3: warning: implicit declaration of
function ‘Z_PARAM_ZVAL_DEREF_EX’; did you mean ‘Z_PARAM_ZVAL_EX’? [-Wimplicit-
function-declaration]
1476 | Z_PARAM_ZVAL_DEREF_EX(array, 0, 1)
| ^~~~~~~~~~~~~~~~~~~~~
https://gist.github.com/eSkiSo/781269c79b4dd740e90fcc059c1985ae 7/10
14/08/2023, 21:03 Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.4 · GitHub
| Z_PARAM_ZVAL_EX
/tmp/pear/temp/oci8/oci8_interface.c:1476:37: error: expected ‘;’ before
‘_optional’
1476 | Z_PARAM_ZVAL_DEREF_EX(array, 0, 1)
| ^
| ;
make: *** [Makefile:222: oci8_interface.lo] Error 1
ERROR: `make' failed
Any idea?
fxcosta commented on Jul 29, 2022
thanks a lot!!!!
fxcosta commented on Jul 29, 2022
Just in case it wasn't clear, you also need to add the oci8.so module in the fpm php.ini:
sudo echo "extension=oci8.so" >> /etc/php/7.4/fpm/php.ini
service php7.4-fpm restart
For me it only worked after that because the cli configuration files are different from the ones used
in http
Ahmadfauzi1111 commented on Aug 3, 2022
any Idea ??
/tmp/pear/temp/oci8/oci8_interface.c: In function ‘zif_oci_fetch_all’:
/tmp/pear/temp/oci8/oci8_interface.c:1476:3: warning: implicit declaration of function
‘Z_PARAM_ZVAL_DEREF_EX’; did you mean ‘Z_PARAM_ZVAL_EX’? [-Wimplicit-function-declaration]
1476 | Z_PARAM_ZVAL_DEREF_EX(array, 0, 1)
| ^~~~~~~~~~~~~~~~~~~~~
| Z_PARAM_ZVAL_EX
/tmp/pear/temp/oci8/oci8_interface.c:1476:37: error: expected ‘;’ before ‘_optional’
1476 | Z_PARAM_ZVAL_DEREF_EX(array, 0, 1)
|^
|;
make: *** [Makefile:222: oci8_interface.lo] Error 1
ERROR: `make' failed
eSkiSo commented on Aug 3, 2022
any Idea ??
https://gist.github.com/eSkiSo/781269c79b4dd740e90fcc059c1985ae 8/10
14/08/2023, 21:03 Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.4 · GitHub
/tmp/pear/temp/oci8/oci8_interface.c: In function ‘zif_oci_fetch_all’:
/tmp/pear/temp/oci8/oci8_interface.c:1476:3: warning: implicit declaration of function
‘Z_PARAM_ZVAL_DEREF_EX’; did you mean ‘Z_PARAM_ZVAL_EX’? [-Wimplicit-function-
declaration] 1476 | Z_PARAM_ZVAL_DEREF_EX(array, 0, 1) | ^~~~~~~~~~~~~~~~~~~~~ |
Z_PARAM_ZVAL_EX /tmp/pear/temp/oci8/oci8_interface.c:1476:37: error: expected ‘;’ before
‘_optional’ 1476 | Z_PARAM_ZVAL_DEREF_EX(array, 0, 1) | ^ | ; make: *** [Makefile:222:
oci8_interface.lo] Error 1 ERROR: `make' failed
Are you using php v7.4?
That error seems like the one “enboig” was having
https://gist.github.com/eSkiSo/781269c79b4dd740e90fcc059c1985ae?
permalink_comment_id=4244857#gistcomment-4244857
Ahmadfauzi1111 commented on Aug 3, 2022
yes I have changed several instant clients but still the same error
eSkiSo commented on Aug 3, 2022
What version of PHP are you using?
aashestakov commented on Aug 25, 2022
If there are several php versions in your system or you are using version 7.4 for example then try
to claim version via special flag:
sudo pecl -d php_suffix=7.4 install oci8-2.2.0
lakatosgabor commented on Dec 28, 2022
Hi.
My error:
No releases available for package "pecl.php.net/oci8"
Install failed
If the pecl install not working, try it donwload manuality.
Check this website: https://www.php.net/manual/en/oci8.installation.php
I used phpize "Installing OCI8 from PECL Using phpize"
Good luck
G.
eSkiSo commented on Jan 19
https://gist.github.com/eSkiSo/781269c79b4dd740e90fcc059c1985ae 9/10
14/08/2023, 21:03 Install OCI8 (Oracle) in Ubuntu 20 with PHP 7.4 · GitHub
You maybe were missing to update the pecl list:
sudo pecl channel-update pecl.php.net
lakatosgabor commented on Jan 19
No, i did try update the pecl. It's not working. I did download with manuality, and it's fine.
lhervi commented on Mar 1 • edited
aashestakov
God bless you aashestakov :)
diegoolipa commented on Apr 11
https://medium.com/@diegoolipa/prueba-levantar-proyecto-php-ce5ef419ac78
ngoanhphong19730708 commented on Apr 27 • edited
I installed, all the step are the same guide. After that php not working . I can not run any php file.
Pls tell me why ?. Thanks
acaciobernardo commented on Jun 11
Thank you!!
https://gist.github.com/eSkiSo/781269c79b4dd740e90fcc059c1985ae 10/10