Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save autotrof/0cebd1898d16297df7a66d7e5d7f47d0 to your computer and use it in GitHub Desktop.
Save autotrof/0cebd1898d16297df7a66d7e5d7f47d0 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment