Skip to content

Instantly share code, notes, and snippets.

@piotrekkr
Last active October 26, 2023 21:14
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save piotrekkr/c7ed9197a3e72e896f7248fcd0813411 to your computer and use it in GitHub Desktop.
Save piotrekkr/c7ed9197a3e72e896f7248fcd0813411 to your computer and use it in GitHub Desktop.
Installing OCI8 from PECL with multiple PHP FPM versions from Ondrej Sury repo in Ubuntu 16.04

Download instant client 12.2 basic and basic devel rpm from oracle

Convert rpm to deb using alien command

alien -kv oracle-instantclient12*.rpm

Install deb files

sudo dpkg -i oracle-instantclient12*.deb

Install pecl oci8 extension for PHP 7.1 and 7.2

You need php dev version installed. Use instantclient,/usr/lib/oracle/12.2/client64/lib/ when asked by pecl.

sudo pecl -d php_suffix=7.1 install oci8 ; sudo pecl uninstall -r oci8
sudo pecl -d php_suffix=7.2 install oci8 ; sudo pecl uninstall -r oci8

Add oci8 to available modules in php 7.1, 7.2

; configuration for php oci8 module
; priority=20
extension=oci8.so

Put text above in /etc/php/7.1/mods-avaiable/oci8.ini and /etc/php/7.2/mods-avaiable/oci8.ini

Enable oci8 modules

phpenmod -v 7.1 -s ALL oci8
phpenmod -v 7.2 -s ALL oci8

Restart PHP FPM

sudo systemctl restart 'php*'

Check if ok

php -m | grep oci8
oci8

Troubleshooting

No libmql1.so library

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/oci8.so' - libmql1.so: cannot open shared object file: No such file or directory in Unknown on line 0

Fix

sudo sh -c "echo /usr/lib/oracle/12.2/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf" 

sudo ldconfig
@Ahmadshoh
Copy link

PHP Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/lib/php/20190902/oci8.so (/usr/lib/php/20190902/oci8.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/oci8.so.so (/usr/lib/php/20190902/oci8.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/lib/php/20190902/oci8.so (/usr/lib/php/20190902/oci8.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/oci8.so.so (/usr/lib/php/20190902/oci8.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

@piotrekkr
Copy link
Author

@laraveldev21 Those instructions are for PHP 7 from Ondrej Sury repo. Aee you using hist apt repo or just standard PHP install from deb, or maybe docker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment