Skip to content

Instantly share code, notes, and snippets.

@hewerthomn
Created February 22, 2017 14:45
Show Gist options
  • Star 55 You must be signed in to star a gist
  • Fork 27 You must be signed in to fork a gist
  • Save hewerthomn/81eea2935051eb2500941a9309bca703 to your computer and use it in GitHub Desktop.
Save hewerthomn/81eea2935051eb2500941a9309bca703 to your computer and use it in GitHub Desktop.
How to install OCI8 on Ubuntu 16.04 and PHP 7.1

How to install OCI8 on Ubuntu 16.04 and PHP 7.1

Source: http://www.syahzul.com/2016/04/06/how-to-install-oci8-on-ubuntu-14-04-and-php-5-6/

Install Oracle Instant Client and SDK

Step 1

Download the Oracle Instant Client and SDK from Oracle website. (Need to login in Oracle page)

http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

Files: instantclient-basic-linux.x64-12.1.0.2.0.zip and instantclient-sdk-linux.x64-12.1.0.2.0.zip.

Step 2

Create a new folder to store Oracle Instant Client zip files on your server.

Upload the Instant Clients files inside this folder.

mkdir /opt/oracle

Step 3

Now we need to extract the files.

cd /opt/oracle
unzip instantclient-basic-linux.x64-12.1.0.2.0.zip
unzip instantclient-sdk-linux.x64-12.1.0.2.0.zip

Step 4

Next, we need to create a symlink to Instant Client files.

ln -s /opt/oracle/instantclient_12_1/libclntsh.so.12.1 /opt/oracle/instantclient_12_1/libclntsh.so
ln -s /opt/oracle/instantclient_12_1/libocci.so.12.1 /opt/oracle/instantclient_12_1/libocci.so

Step 5

Add the folder to our ldconfig.

echo /opt/oracle/instantclient_12_1 > /etc/ld.so.conf.d/oracle-instantclient

Step 6

Update the Dynamic Linker Run-Time Bindings

ldconfig

Done. Now we can proceed to the next part.

Install Additional Packages

To install the OCI8 extension, we need to install some additional package on our server.

Step 1

Run these command:

apt-get install php-dev php-pear build-essential libaio1

Step 2

Once installed, we need to get the OCI8 file.

pecl install oci8

When you are prompted for the Instant Client location, enter the following:

instantclient,/opt/oracle/instantclient_12_1

Step 3

We need to tell PHP to load the OCI8 extension.

echo "extension = oci8.so" >> /etc/php/7.1/fpm/php.ini
echo "extension = oci8.so" >> /etc/php/7.1/cli/php.ini

Step 4

Check if the extension is enabled.

php -m | grep 'oci8'

If returns oci8, its works!

Step 5

Restart the PHP-FPM

service php7.1-fpm restart

Now you can connect to Oracle DBMS from your PHP applications.

@arsenanai
Copy link

arsenanai commented Nov 1, 2017

Hello, I've done everything that you instruct here, but I couldn't connect to oracle database. I used wrong connection test example or drivers installed incorrectly. Please help me. OS: Ubuntu 16.04 LTS desktop. "php -i" results:

phpinfo()
PHP Version => 7.1.11-1+ubuntu16.04.1+deb.sury.org+1

System => Linux rsa-hp 4.10.0-38-generic #42~16.04.1-Ubuntu SMP Tue Oct 10 16:32:20 UTC 2017 x86_64
Build Date => Oct 27 2017 13:49:56
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc/php/7.1/cli
Loaded Configuration File => /etc/php/7.1/cli/php.ini
Scan this dir for additional .ini files => /etc/php/7.1/cli/conf.d
Additional .ini files parsed => /etc/php/7.1/cli/conf.d/10-opcache.ini,
/etc/php/7.1/cli/conf.d/10-pdo.ini,
/etc/php/7.1/cli/conf.d/15-xml.ini,
/etc/php/7.1/cli/conf.d/20-calendar.ini,
/etc/php/7.1/cli/conf.d/20-ctype.ini,
/etc/php/7.1/cli/conf.d/20-dom.ini,
/etc/php/7.1/cli/conf.d/20-exif.ini,
/etc/php/7.1/cli/conf.d/20-fileinfo.ini,
/etc/php/7.1/cli/conf.d/20-ftp.ini,
/etc/php/7.1/cli/conf.d/20-gettext.ini,
/etc/php/7.1/cli/conf.d/20-iconv.ini,
/etc/php/7.1/cli/conf.d/20-json.ini,
/etc/php/7.1/cli/conf.d/20-phar.ini,
/etc/php/7.1/cli/conf.d/20-posix.ini,
/etc/php/7.1/cli/conf.d/20-readline.ini,
/etc/php/7.1/cli/conf.d/20-shmop.ini,
/etc/php/7.1/cli/conf.d/20-simplexml.ini,
/etc/php/7.1/cli/conf.d/20-sockets.ini,
/etc/php/7.1/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.1/cli/conf.d/20-sysvsem.ini,
/etc/php/7.1/cli/conf.d/20-sysvshm.ini,
/etc/php/7.1/cli/conf.d/20-tokenizer.ini,
/etc/php/7.1/cli/conf.d/20-wddx.ini,
/etc/php/7.1/cli/conf.d/20-xmlreader.ini,
/etc/php/7.1/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.1/cli/conf.d/20-xsl.ini

PHP API => 20160303
PHP Extension => 20160303
Zend Extension => 320160303
Zend Extension Build => API320160303,NTS
PHP Extension Build => API20160303,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => enabled
Zend Memory Manager => enabled
Zend Multibyte Support => disabled
IPv6 Support => enabled
DTrace Support => available, disabled

Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters => zlib., string.rot13, string.toupper, string.tolower, string.strip_tags, convert., consumed, dechunk, convert.iconv.*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.11-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies


Configuration

calendar

Calendar support => enabled

Core

PHP Version => 7.1.11-1+ubuntu16.04.1+deb.sury.org+1

Directive => Local Value => Master Value
allow_url_fopen => On => On
allow_url_include => Off => Off
arg_separator.input => & => &
arg_separator.output => & => &
auto_append_file => no value => no value
auto_globals_jit => On => On
auto_prepend_file => no value => no value
browscap => no value => no value
default_charset => UTF-8 => UTF-8
default_mimetype => text/html => text/html
disable_classes => no value => no value
disable_functions => no value => no value
display_errors => Off => Off
display_startup_errors => Off => Off
doc_root => no value => no value
docref_ext => no value => no value
docref_root => no value => no value
enable_dl => Off => Off
enable_post_data_reading => On => On
error_append_string => no value => no value
error_log => no value => no value
error_prepend_string => no value => no value
error_reporting => 22527 => 22527
expose_php => On => On
extension_dir => /usr/lib/php/20160303 => /usr/lib/php/20160303
file_uploads => On => On
hard_timeout => 2 => 2
highlight.comment => #FF8000 => #FF8000
highlight.default => #0000BB => #0000BB
highlight.html => #000000 => #000000
highlight.keyword => #007700 => #007700
highlight.string => #DD0000 => #DD0000
html_errors => Off => Off
ignore_repeated_errors => Off => Off
ignore_repeated_source => Off => Off
ignore_user_abort => Off => Off
implicit_flush => On => On
include_path => .:/usr/share/php => .:/usr/share/php
input_encoding => no value => no value
internal_encoding => no value => no value
log_errors => On => On
log_errors_max_len => 1024 => 1024
mail.add_x_header => On => On
mail.force_extra_parameters => no value => no value
mail.log => no value => no value
max_execution_time => 0 => 0
max_file_uploads => 20 => 20
max_input_nesting_level => 64 => 64
max_input_time => -1 => -1
max_input_vars => 1000 => 1000
memory_limit => -1 => -1
open_basedir => no value => no value
output_buffering => 0 => 0
output_encoding => no value => no value
output_handler => no value => no value
post_max_size => 8M => 8M
precision => 14 => 14
realpath_cache_size => 4096K => 4096K
realpath_cache_ttl => 120 => 120
register_argc_argv => On => On
report_memleaks => On => On
report_zend_debug => Off => Off
request_order => GP => GP
sendmail_from => no value => no value
sendmail_path => /usr/sbin/sendmail -t -i => /usr/sbin/sendmail -t -i
serialize_precision => -1 => -1
short_open_tag => Off => Off
SMTP => localhost => localhost
smtp_port => 25 => 25
sql.safe_mode => Off => Off
sys_temp_dir => no value => no value
track_errors => Off => Off
unserialize_callback_func => no value => no value
upload_max_filesize => 2M => 2M
upload_tmp_dir => no value => no value
user_dir => no value => no value
user_ini.cache_ttl => 300 => 300
user_ini.filename => .user.ini => .user.ini
variables_order => GPCS => GPCS
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
zend.assertions => -1 => -1
zend.detect_unicode => On => On
zend.enable_gc => On => On
zend.multibyte => Off => Off
zend.script_encoding => no value => no value
zend.signal_check => Off => Off

ctype

ctype functions => enabled

date

date/time support => enabled
timelib version => 2016.05
"Olson" Timezone Database Version => 0.system
Timezone Database => internal
Default timezone => UTC

Directive => Local Value => Master Value
date.default_latitude => 31.7667 => 31.7667
date.default_longitude => 35.2333 => 35.2333
date.sunrise_zenith => 90.583333 => 90.583333
date.sunset_zenith => 90.583333 => 90.583333
date.timezone => no value => no value

dom

DOM/XML => enabled
DOM/XML API Version => 20031129
libxml Version => 2.9.4
HTML Support => enabled
XPath Support => enabled
XPointer Support => enabled
Schema Support => enabled
RelaxNG Support => enabled

exif

EXIF Support => enabled
EXIF Version => 1.4 $Id: 8bdc0c8f27c2c9dd1f7551f1f9fe3ab57a06a4b1 $
Supported EXIF Version => 0220
Supported filetypes => JPEG,TIFF

Directive => Local Value => Master Value
exif.decode_jis_intel => JIS => JIS
exif.decode_jis_motorola => JIS => JIS
exif.decode_unicode_intel => UCS-2LE => UCS-2LE
exif.decode_unicode_motorola => UCS-2BE => UCS-2BE
exif.encode_jis => no value => no value
exif.encode_unicode => ISO-8859-15 => ISO-8859-15

fileinfo

fileinfo support => enabled
version => 1.0.5
libmagic => 522

filter

Input Validation and Filtering => enabled
Revision => $Id: cdc5e15bb616f10210b94ecd8789e66c927a375f $

Directive => Local Value => Master Value
filter.default => unsafe_raw => unsafe_raw
filter.default_flags => no value => no value

ftp

FTP support => enabled
FTPS support => enabled

gettext

GetText Support => enabled

hash

hash support => enabled
Hashing Engines => md2 md4 md5 sha1 sha224 sha256 sha384 sha512/224 sha512/256 sha512 sha3-224 sha3-256 sha3-384 sha3-512 ripemd128 ripemd160 ripemd256 ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,4 tiger192,4 snefru snefru256 gost gost-crypto adler32 crc32 crc32b fnv132 fnv1a32 fnv164 fnv1a64 joaat haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,5 haval224,5 haval256,5

MHASH support => Enabled
MHASH API Version => Emulated Support

iconv

iconv support => enabled
iconv implementation => glibc
iconv library version => 2.23

Directive => Local Value => Master Value
iconv.input_encoding => no value => no value
iconv.internal_encoding => no value => no value
iconv.output_encoding => no value => no value

json

json support => enabled
json version => 1.5.0

libxml

libXML support => active
libXML Compiled Version => 2.9.4
libXML Loaded Version => 20904
libXML streams => enabled

oci8

OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.8
Revision => $Id: 8a26cf66ca0f9556b6376408c8f71ead69bdbcbf $
Oracle Run-time Client Library Version => 12.2.0.1.0
Oracle Compile-time Instant Client Version => 12.2

Directive => Local Value => Master Value
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

Statistics =>
Active Persistent Connections => 0
Active Connections => 0

openssl

OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.1.0f 25 May 2017
OpenSSL Header Version => OpenSSL 1.1.0f 25 May 2017
Openssl default config => /usr/lib/ssl/openssl.cnf

Directive => Local Value => Master Value
openssl.cafile => no value => no value
openssl.capath => no value => no value

pcntl

pcntl support => enabled

pcre

PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE Library Version => 8.41 2017-07-05
PCRE JIT Support => enabled

Directive => Local Value => Master Value
pcre.backtrack_limit => 1000000 => 1000000
pcre.jit => 1 => 1
pcre.recursion_limit => 100000 => 100000

PDO

PDO support => enabled
PDO drivers =>

Phar

Phar: PHP Archive support => enabled
Phar EXT version => 2.0.2
Phar API version => 1.1.1
SVN revision => $Id: 59c11f4e29768bfbbf6f41cb469abd81d8655850 $
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
gzip compression => enabled
bzip2 compression => disabled (install pecl/bz2)
Native OpenSSL support => enabled

Phar based on pear/PHP_Archive, original concept by Davey Shafik.
Phar fully realized by Gregory Beaver and Marcus Boerger.
Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.
Directive => Local Value => Master Value
phar.cache_list => no value => no value
phar.readonly => On => On
phar.require_hash => On => On

posix

Revision => $Id: b691ca925e7a085e6929579c4eba8fed0732e0ef $

readline

Readline Support => enabled
Readline library => EditLine wrapper

Directive => Local Value => Master Value
cli.pager => no value => no value
cli.prompt => \b > => \b >

Reflection

Reflection => enabled
Version => $Id: fa936d2e1587e7b6b6c0f7235f4d9df7564a77ad $

session

Session Support => enabled
Registered save handlers => files user
Registered serializer handlers => php_serialize php php_binary wddx

Directive => Local Value => Master Value
session.auto_start => Off => Off
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_domain => no value => no value
session.cookie_httponly => Off => Off
session.cookie_lifetime => 0 => 0
session.cookie_path => / => /
session.cookie_secure => Off => Off
session.gc_divisor => 1000 => 1000
session.gc_maxlifetime => 1440 => 1440
session.gc_probability => 0 => 0
session.lazy_write => On => On
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => files => files
session.save_path => /var/lib/php/sessions => /var/lib/php/sessions
session.serialize_handler => php => php
session.sid_bits_per_character => 5 => 5
session.sid_length => 26 => 26
session.upload_progress.cleanup => On => On
session.upload_progress.enabled => On => On
session.upload_progress.freq => 1% => 1%
session.upload_progress.min_freq => 1 => 1
session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix => upload_progress_ => upload_progress_
session.use_cookies => On => On
session.use_only_cookies => On => On
session.use_strict_mode => Off => Off
session.use_trans_sid => 0 => 0

shmop

shmop support => enabled

SimpleXML

Simplexml support => enabled
Revision => $Id: 50413b12ac745b94b27ffbdd5454e6e0d7809909 $
Schema support => enabled

sockets

Sockets Support => enabled

SPL

SPL support => enabled
Interfaces => Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject
Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException

standard

Dynamic Library Support => enabled
Path to sendmail => /usr/sbin/sendmail -t -i

Directive => Local Value => Master Value
assert.active => 1 => 1
assert.bail => 0 => 0
assert.callback => no value => no value
assert.exception => 0 => 0
assert.quiet_eval => 0 => 0
assert.warning => 1 => 1
auto_detect_line_endings => 0 => 0
default_socket_timeout => 60 => 60
from => no value => no value
session.trans_sid_hosts => no value => no value
session.trans_sid_tags => a=href,area=href,frame=src,form= => a=href,area=href,frame=src,form=
url_rewriter.hosts => no value => no value
url_rewriter.tags => form= => form=
user_agent => no value => no value

sysvmsg

sysvmsg support => enabled
Revision => $Id: 37aa0d90288b1385356784f17694f4c700575736 $

sysvsem

Version => 7.1.11-1+ubuntu16.04.1+deb.sury.org+1

sysvshm

Version => 7.1.11-1+ubuntu16.04.1+deb.sury.org+1

tokenizer

Tokenizer Support => enabled

wddx

WDDX Support => enabled
WDDX Session Serializer => enabled

xml

XML Support => active
XML Namespace Support => active
libxml2 Version => 2.9.4

xmlreader

XMLReader => enabled

xmlwriter

XMLWriter => enabled

xsl

XSL => enabled
libxslt Version => 1.1.28
libxslt compiled against libxml Version => 2.9.3
EXSLT => enabled
libexslt Version => 1.1.28

Zend OPcache

Opcode Caching => Disabled
Optimization => Disabled
SHM Cache => Enabled
File Cache => Disabled
Startup Failed => Opcode Caching is disabled for CLI

Directive => Local Value => Master Value
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 0 => 0
opcache.file_cache => no value => no value
opcache.file_cache_consistency_checks => 1 => 1
opcache.file_cache_only => 0 => 0
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 8 => 8
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 10000 => 10000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On

zlib

ZLib Support => enabled
Stream Wrapper => compress.zlib://
Stream Filter => zlib.inflate, zlib.deflate
Compiled Version => 1.2.8
Linked Version => 1.2.8

Directive => Local Value => Master Value
zlib.output_compression => Off => Off
zlib.output_compression_level => -1 => -1
zlib.output_handler => no value => no value

Additional Modules

Module Name

Environment

Variable => Value
XDG_VTNR => 7
LC_PAPER => kk_KZ.UTF-8
LC_ADDRESS => kk_KZ.UTF-8
XDG_SESSION_ID => c2
XDG_GREETER_DATA_DIR => /var/lib/lightdm-data/rsa
LC_MONETARY => kk_KZ.UTF-8
CLUTTER_IM_MODULE => xim
SESSION => ubuntu
GPG_AGENT_INFO => /home/rsa/.gnupg/S.gpg-agent:0:1
TERM => xterm-256color
VTE_VERSION => 4205
XDG_MENU_PREFIX => gnome-
SHELL => /bin/bash
DERBY_HOME => /usr/lib/jvm/java-8-oracle/db
QT_LINUX_ACCESSIBILITY_ALWAYS_ON => 1
WINDOWID => 60817414
LC_NUMERIC => kk_KZ.UTF-8
UPSTART_SESSION => unix:abstract=/com/ubuntu/upstart-session/1000/2008
GNOME_KEYRING_CONTROL =>
PDO_OCI_LIB_DIR => /opt/oracle/instantclient_12_2
GTK_MODULES => gail:atk-bridge:unity-gtk-module
VBOX_INSTALL_PATH => /usr/lib/virtualbox
USER => rsa
LS_COLORS => rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:.tar=01;31:.tgz=01;31:.arc=01;31:.arj=01;31:.taz=01;31:.lha=01;31:.lz4=01;31:.lzh=01;31:.lzma=01;31:.tlz=01;31:.txz=01;31:.tzo=01;31:.t7z=01;31:.zip=01;31:.z=01;31:.Z=01;31:.dz=01;31:.gz=01;31:.lrz=01;31:.lz=01;31:.lzo=01;31:.xz=01;31:.bz2=01;31:.bz=01;31:.tbz=01;31:.tbz2=01;31:.tz=01;31:.deb=01;31:.rpm=01;31:.jar=01;31:.war=01;31:.ear=01;31:.sar=01;31:.rar=01;31:.alz=01;31:.ace=01;31:.zoo=01;31:.cpio=01;31:.7z=01;31:.rz=01;31:.cab=01;31:.jpg=01;35:.jpeg=01;35:.gif=01;35:.bmp=01;35:.pbm=01;35:.pgm=01;35:.ppm=01;35:.tga=01;35:.xbm=01;35:.xpm=01;35:.tif=01;35:.tiff=01;35:.png=01;35:.svg=01;35:.svgz=01;35:.mng=01;35:.pcx=01;35:.mov=01;35:.mpg=01;35:.mpeg=01;35:.m2v=01;35:.mkv=01;35:.webm=01;35:.ogm=01;35:.mp4=01;35:.m4v=01;35:.mp4v=01;35:.vob=01;35:.qt=01;35:.nuv=01;35:.wmv=01;35:.asf=01;35:.rm=01;35:.rmvb=01;35:.flc=01;35:.avi=01;35:.fli=01;35:.flv=01;35:.gl=01;35:.dl=01;35:.xcf=01;35:.xwd=01;35:.yuv=01;35:.cgm=01;35:.emf=01;35:.ogv=01;35:.ogx=01;35:.aac=00;36:.au=00;36:.flac=00;36:.m4a=00;36:.mid=00;36:.midi=00;36:.mka=00;36:.mp3=00;36:.mpc=00;36:.ogg=00;36:.ra=00;36:.wav=00;36:.oga=00;36:.opus=00;36:.spx=00;36:.xspf=00;36:
LC_TELEPHONE => kk_KZ.UTF-8
QT_ACCESSIBILITY => 1
LD_LIBRARY_PATH => /opt/oracle/instantclient_12_2
XDG_SESSION_PATH => /org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH => /org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK => /run/user/1000/keyring/ssh
DEFAULTS_PATH => /usr/share/gconf/ubuntu.default.path
XDG_CONFIG_DIRS => /etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg
DESKTOP_SESSION => ubuntu
PATH => /home/rsa/bin:/home/rsa/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/rsa/.config/composer/vendor/bin
QT_IM_MODULE => ibus
QT_QPA_PLATFORMTHEME => appmenu-qt5
LC_IDENTIFICATION => kk_KZ.UTF-8
XDG_SESSION_TYPE => x11
PWD => /etc/php/7.1/fpm
JOB => unity-settings-daemon
XMODIFIERS => @im=ibus
JAVA_HOME => /usr/lib/jvm/java-8-oracle
GNOME_KEYRING_PID =>
LANG => en_US.UTF-8
GDM_LANG => en
MANDATORY_PATH => /usr/share/gconf/ubuntu.mandatory.path
LC_MEASUREMENT => kk_KZ.UTF-8
COMPIZ_CONFIG_PROFILE => ubuntu
IM_CONFIG_PHASE => 1
PAPERSIZE => a4
GDMSESSION => ubuntu
SESSIONTYPE => gnome-session
GTK2_MODULES => overlay-scrollbar
SHLVL => 1
HOME => /home/rsa
XDG_SEAT => seat0
LANGUAGE => en
GNOME_DESKTOP_SESSION_ID => this-is-deprecated
UPSTART_INSTANCE =>
UPSTART_EVENTS => xsession started
XDG_SESSION_DESKTOP => ubuntu
LOGNAME => rsa
COMPIZ_BIN_PATH => /usr/bin/
DBUS_SESSION_BUS_ADDRESS => unix:abstract=/tmp/dbus-ASHNM9X4BF
J2SDKDIR => /usr/lib/jvm/java-8-oracle
XDG_DATA_DIRS => /usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
QT4_IM_MODULE => xim
LESSOPEN => | /usr/bin/lesspipe %s
INSTANCE =>
UPSTART_JOB => unity7
XDG_RUNTIME_DIR => /run/user/1000
DISPLAY => :0
ORACLE_HOME => /opt/oracle
XDG_CURRENT_DESKTOP => Unity
GTK_IM_MODULE => ibus
J2REDIR => /usr/lib/jvm/java-8-oracle/jre
LESSCLOSE => /usr/bin/lesspipe %s %s
LC_TIME => kk_KZ.UTF-8
LC_NAME => kk_KZ.UTF-8
XAUTHORITY => /home/rsa/.Xauthority
_ => /usr/local/bin/php
OLDPWD => /home/rsa

PHP Variables

Variable => Value
$_SERVER['XDG_VTNR'] => 7
$_SERVER['LC_PAPER'] => kk_KZ.UTF-8
$_SERVER['LC_ADDRESS'] => kk_KZ.UTF-8
$_SERVER['XDG_SESSION_ID'] => c2
$_SERVER['XDG_GREETER_DATA_DIR'] => /var/lib/lightdm-data/rsa
$_SERVER['LC_MONETARY'] => kk_KZ.UTF-8
$_SERVER['CLUTTER_IM_MODULE'] => xim
$_SERVER['SESSION'] => ubuntu
$_SERVER['GPG_AGENT_INFO'] => /home/rsa/.gnupg/S.gpg-agent:0:1
$_SERVER['TERM'] => xterm-256color
$_SERVER['VTE_VERSION'] => 4205
$_SERVER['XDG_MENU_PREFIX'] => gnome-
$_SERVER['SHELL'] => /bin/bash
$_SERVER['DERBY_HOME'] => /usr/lib/jvm/java-8-oracle/db
$_SERVER['QT_LINUX_ACCESSIBILITY_ALWAYS_ON'] => 1
$_SERVER['WINDOWID'] => 60817414
$_SERVER['LC_NUMERIC'] => kk_KZ.UTF-8
$_SERVER['UPSTART_SESSION'] => unix:abstract=/com/ubuntu/upstart-session/1000/2008
$_SERVER['GNOME_KEYRING_CONTROL'] =>
$_SERVER['PDO_OCI_LIB_DIR'] => /opt/oracle/instantclient_12_2
$_SERVER['GTK_MODULES'] => gail:atk-bridge:unity-gtk-module
$_SERVER['VBOX_INSTALL_PATH'] => /usr/lib/virtualbox
$_SERVER['USER'] => rsa
$_SERVER['LS_COLORS'] => rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:.tar=01;31:.tgz=01;31:.arc=01;31:.arj=01;31:.taz=01;31:.lha=01;31:.lz4=01;31:.lzh=01;31:.lzma=01;31:.tlz=01;31:.txz=01;31:.tzo=01;31:.t7z=01;31:.zip=01;31:.z=01;31:.Z=01;31:.dz=01;31:.gz=01;31:.lrz=01;31:.lz=01;31:.lzo=01;31:.xz=01;31:.bz2=01;31:.bz=01;31:.tbz=01;31:.tbz2=01;31:.tz=01;31:.deb=01;31:.rpm=01;31:.jar=01;31:.war=01;31:.ear=01;31:.sar=01;31:.rar=01;31:.alz=01;31:.ace=01;31:.zoo=01;31:.cpio=01;31:.7z=01;31:.rz=01;31:.cab=01;31:.jpg=01;35:.jpeg=01;35:.gif=01;35:.bmp=01;35:.pbm=01;35:.pgm=01;35:.ppm=01;35:.tga=01;35:.xbm=01;35:.xpm=01;35:.tif=01;35:.tiff=01;35:.png=01;35:.svg=01;35:.svgz=01;35:.mng=01;35:.pcx=01;35:.mov=01;35:.mpg=01;35:.mpeg=01;35:.m2v=01;35:.mkv=01;35:.webm=01;35:.ogm=01;35:.mp4=01;35:.m4v=01;35:.mp4v=01;35:.vob=01;35:.qt=01;35:.nuv=01;35:.wmv=01;35:.asf=01;35:.rm=01;35:.rmvb=01;35:.flc=01;35:.avi=01;35:.fli=01;35:.flv=01;35:.gl=01;35:.dl=01;35:.xcf=01;35:.xwd=01;35:.yuv=01;35:.cgm=01;35:.emf=01;35:.ogv=01;35:.ogx=01;35:.aac=00;36:.au=00;36:.flac=00;36:.m4a=00;36:.mid=00;36:.midi=00;36:.mka=00;36:.mp3=00;36:.mpc=00;36:.ogg=00;36:.ra=00;36:.wav=00;36:.oga=00;36:.opus=00;36:.spx=00;36:.xspf=00;36:
$_SERVER['LC_TELEPHONE'] => kk_KZ.UTF-8
$_SERVER['QT_ACCESSIBILITY'] => 1
$_SERVER['LD_LIBRARY_PATH'] => /opt/oracle/instantclient_12_2
$_SERVER['XDG_SESSION_PATH'] => /org/freedesktop/DisplayManager/Session0
$_SERVER['XDG_SEAT_PATH'] => /org/freedesktop/DisplayManager/Seat0
$_SERVER['SSH_AUTH_SOCK'] => /run/user/1000/keyring/ssh
$_SERVER['DEFAULTS_PATH'] => /usr/share/gconf/ubuntu.default.path
$_SERVER['XDG_CONFIG_DIRS'] => /etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg
$_SERVER['DESKTOP_SESSION'] => ubuntu
$_SERVER['PATH'] => /home/rsa/bin:/home/rsa/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/rsa/.config/composer/vendor/bin
$_SERVER['QT_IM_MODULE'] => ibus
$_SERVER['QT_QPA_PLATFORMTHEME'] => appmenu-qt5
$_SERVER['LC_IDENTIFICATION'] => kk_KZ.UTF-8
$_SERVER['XDG_SESSION_TYPE'] => x11
$_SERVER['PWD'] => /etc/php/7.1/fpm
$_SERVER['JOB'] => unity-settings-daemon
$_SERVER['XMODIFIERS'] => @im=ibus
$_SERVER['JAVA_HOME'] => /usr/lib/jvm/java-8-oracle
$_SERVER['GNOME_KEYRING_PID'] =>
$_SERVER['LANG'] => en_US.UTF-8
$_SERVER['GDM_LANG'] => en
$_SERVER['MANDATORY_PATH'] => /usr/share/gconf/ubuntu.mandatory.path
$_SERVER['LC_MEASUREMENT'] => kk_KZ.UTF-8
$_SERVER['COMPIZ_CONFIG_PROFILE'] => ubuntu
$_SERVER['IM_CONFIG_PHASE'] => 1
$_SERVER['PAPERSIZE'] => a4
$_SERVER['GDMSESSION'] => ubuntu
$_SERVER['SESSIONTYPE'] => gnome-session
$_SERVER['GTK2_MODULES'] => overlay-scrollbar
$_SERVER['SHLVL'] => 1
$_SERVER['HOME'] => /home/rsa
$_SERVER['XDG_SEAT'] => seat0
$_SERVER['LANGUAGE'] => en
$_SERVER['GNOME_DESKTOP_SESSION_ID'] => this-is-deprecated
$_SERVER['UPSTART_INSTANCE'] =>
$_SERVER['UPSTART_EVENTS'] => xsession started
$_SERVER['XDG_SESSION_DESKTOP'] => ubuntu
$_SERVER['LOGNAME'] => rsa
$_SERVER['COMPIZ_BIN_PATH'] => /usr/bin/
$_SERVER['DBUS_SESSION_BUS_ADDRESS'] => unix:abstract=/tmp/dbus-ASHNM9X4BF
$_SERVER['J2SDKDIR'] => /usr/lib/jvm/java-8-oracle
$_SERVER['XDG_DATA_DIRS'] => /usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
$_SERVER['QT4_IM_MODULE'] => xim
$_SERVER['LESSOPEN'] => | /usr/bin/lesspipe %s
$_SERVER['INSTANCE'] =>
$_SERVER['UPSTART_JOB'] => unity7
$_SERVER['XDG_RUNTIME_DIR'] => /run/user/1000
$_SERVER['DISPLAY'] => :0
$_SERVER['ORACLE_HOME'] => /opt/oracle
$_SERVER['XDG_CURRENT_DESKTOP'] => Unity
$_SERVER['GTK_IM_MODULE'] => ibus
$_SERVER['J2REDIR'] => /usr/lib/jvm/java-8-oracle/jre
$_SERVER['LESSCLOSE'] => /usr/bin/lesspipe %s %s
$_SERVER['LC_TIME'] => kk_KZ.UTF-8
$_SERVER['LC_NAME'] => kk_KZ.UTF-8
$_SERVER['XAUTHORITY'] => /home/rsa/.Xauthority
$SERVER[''] => /usr/local/bin/php
$_SERVER['OLDPWD'] => /home/rsa
$_SERVER['PHP_SELF'] =>
$_SERVER['SCRIPT_NAME'] =>
$_SERVER['SCRIPT_FILENAME'] =>
$_SERVER['PATH_TRANSLATED'] =>
$_SERVER['DOCUMENT_ROOT'] =>
$_SERVER['REQUEST_TIME_FLOAT'] => 1509535366.0526
$_SERVER['REQUEST_TIME'] => 1509535366
$_SERVER['argv'] => Array
(
)

$_SERVER['argc'] => 0

PHP License
This program is free software; you can redistribute it and/or modify
it under the terms of the PHP License as published by the PHP Group
and included in the distribution in the file: LICENSE

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you did not receive a copy of the PHP license, or have any
questions about PHP licensing, please contact license@php.net.

When calling phpinfo(); browser says:
screenshot from 2017-11-01 17-37-59
No topic about OCI8 there, but I enabled oci8.so extension in both php fpm and cli.

php test code that I've used:

<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');

$conn = oci_connect('USERNAME', 'PASSWORD', 'DATABASE');

$stid = oci_parse($conn, 'select count(*) from SOME_TABLE');
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 ? htmlspecialchars($item, ENT_QUOTES) : "&nbsp;")."</td>\n";
    }
    echo "</tr>\n";
}
echo "</table>\n";

?>

result on browser:

Fatal error: Uncaught Error: Call to undefined function oci_connect() in /var/www/html/test.php:6 Stack trace: #0 {main} thrown in /var/www/html/test.php on line 6

That code I got from here:
#Connecting to an Oracle Database
What I'm doing wrong?

@quincykwende
Copy link

Hello, I followed the above tutorials and I am still getting an error. :)

@rcojoe
Copy link

rcojoe commented Dec 7, 2017

Steps 4 and 5 are version specific, so make sure you downloaded exactly the same version. I used tab complete on steps 4 and 5 because I had downloaded 12.2 instead of 12.1.

@IbraheemSalem
Copy link

IbraheemSalem commented Dec 14, 2017

Hello, I followed the above tutorials and I am still getting an error. :)
for the new 12.2
Fatal error: Uncaught Error: Call to undefined function oci_connect() in /var/www/html/oracle/1.php on line 2

$conn = oci_connect("user_name_db","password", "1.0.6.10:1521/data_name");
I try many tutorials but i cant solve my problem.
Please can u help me :)

@Navisho
Copy link

Navisho commented Dec 16, 2017

I had the same problem and did not find anything for a full day, until I found .... https://forum.remirepo.net/viewtopic.php?pid=9291#p9291
this is what worked for me:

systemctl edit apache2
inside we add these two lines

[Service]
Environment = LD_LIBRARY_PATH = / opt / oracle / instantclient

save and restart the apache service

service apache2 restart

and that´s it.

I have ubuntu server 17.10, orale client 12.1.0.2.0 oci8 ver. 2.1.3
I hope it works for u

@Hamfri
Copy link

Hamfri commented Jan 2, 2018

I had the same problem on Ubuntu 16.04 and this is how i resolved it.

  1. Make sure you add this line extension = oci8.so to /etc/php/7.1/apache2/php.ini to make apache aware of oci8
  2. Add the following lines to /etc/apache2/envvars
    export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2
    export ORACLE_HOME=/opt/oracle/instantclient_12_2
  3. Finally restart apache2 using the command /etc/init.d/apache2 restart

@paulovitorbal
Copy link

Thank you!

@nwaweru
Copy link

nwaweru commented May 16, 2018

Hi,

Any help with the below error will be much appreciated:

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

@cbj4074
Copy link

cbj4074 commented May 17, 2018

@nwaweru Where are you seeing that message? In the terminal, when you execute php? Or when you attempt to start the webserver? Also, which OS are you using?

If you're seeing that error in the terminal, then you need to add the Instant Client path to the environment. On Ubuntu 18.04 LTS, for example:

echo 'LD_LIBRARY_PATH="/opt/oracle/instantclient_12_2"' >> /etc/environment

You should then log out of the terminal session and then back in, and the error should disappear.

If you're seeing this error when you start the apache2 daemon, then you need to add the LD_LIBRARY_PATH value to your Apache environment, e.g.:

echo 'export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2' >> /etc/apache2/envvars

And then restart the Apache service.

For whatever reason, none of this was needed on Ubuntu 16.04 LTS, but it appears to be required in Ubuntu 18.04 LTS.

Unfortunately, I can't figure out how to apply the same solution to PHP-FPM running via NGINX. I've tried adding

env['LD_LIBRARY_PATH'] = /opt/oracle/instantclient_12_2

to the effective FPM pool configuration, and while the Environment section of phpinfo()'s output reflects the above value, the OCI8 extension simply does not load. I don't see any errors in relation to libmql1.so in the FPM log, either, even with verbosity set to debug. Really frustrating!!!

@lucassmacedo
Copy link

Hello guys, for any has this problem
"PHP Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/lib/php/20170718/oci8.so (libmql1.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/oci8.so.so (/usr/lib/php/20170718/oci8.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0"

I solved adding the following to /etc/environment:
LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH

@NenadGajic
Copy link

I also had the same PHP Warning as above and I solved it by following this tutorial:

https://medium.com/@kabeza/setup-oracle-instant-client-with-apache-and-php-7-on-ubuntu-server-17-04-66cea2297d6f

@flik
Copy link

flik commented Nov 9, 2018

php -m | grep 'oci8'
PHP Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so (libmql1.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so.so (libmql1.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 'pdo_oci.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_oci.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_oci.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_oci.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_oci.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so (libmql1.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so.so (libmql1.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

@heinhtet123
Copy link

hi,
i am getting the error below. how to resolve it?
Warning: oci_connect(): ORA-12154: TNS:could not resolve the connect identifier specified in /app/src/public/oci8.php on line 3

Fatal error: ORA-12154: TNS:could not resolve the connect identifier specified in /app/src/public/oci8.php on line 7

@pepo-ec
Copy link

pepo-ec commented Jan 17, 2019

I had:
php -m | grep 'oci8'
PHP Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/lib/php/20180731/oci8.so (libmql1.so: cannot open shared object file: No such file or directory), /usr/lib/php/20180731/oci8.so.so (/usr/lib/php/20180731/oci8.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Then I use:
cat /etc/ld.so.conf.d/oracle-instantclient.conf
/opt/oracle/instantclient_18_3

sudo ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache

And that's all

@ZiTAL
Copy link

ZiTAL commented Feb 12, 2019

solved with:

echo "/opt/oracle-instantclient-12-2" >> /etc/ld.so.conf.d/x86_64-linux-gnu.conf
ldconfig

and restart the php-fpm service

@aenal-abie
Copy link

solved with:

echo "/opt/oracle-instantclient-12-2" >> /etc/ld.so.conf.d/x86_64-linux-gnu.conf
ldconfig

and restart the php-fpm service

Thank you

@ambevgabriel
Copy link

I had the same problem on Ubuntu 16.04 and this is how i resolved it.

  1. Make sure you add this line extension = oci8.so to /etc/php/7.1/apache2/php.ini to make apache aware of oci8
  2. Add the following lines to /etc/apache2/envvars
    export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2
    export ORACLE_HOME=/opt/oracle/instantclient_12_2
  3. Finally restart apache2 using the command /etc/init.d/apache2 restart

You Save my life Thankssssss

@luiscordero29
Copy link

Step 5

for debian 10

root@vostro:/etc/ld.so.conf.d# ls -l
total 16
-rw-r--r-- 1 root root 38 Sep 6 18:48 fakeroot-x86_64-linux-gnu.conf
-rw-r--r-- 1 root root 44 Jul 29 2019 libc.conf
-rw-r--r-- 1 root root 31 Jan 31 15:33 oracle-instantclient.conf
-rw-r--r-- 1 root root 100 Jan 10 19:21 x86_64-linux-gnu.conf
root@vostro:/etc/ld.so.conf.d# cat oracle-instantclient.conf
/opt/oracle/instantclient_12_2
root@vostro:/etc/ld.so.conf.d#

@travnewmatic
Copy link

echo /opt/oracle/instantclient_12_1 > /etc/ld.so.conf.d/oracle-instantclient
is wrong
it should be
echo /opt/oracle/instantclient_12_1 > /etc/ld.so.conf.d/oracle-instantclient.conf

@clcneogeek325
Copy link

Please check have just one version php on your server I have had because I had two versions php

@Zaidzularsya
Copy link

Zaidzularsya commented Jun 12, 2021

i had same problem. i have try all solution but nothing was work for me.

┌──(zaidsource㉿Zaid-Desktop)-[~]
└─$ php -m | grep oci8
PHP Warning:  PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/lib/php/20190902/oci8.so 
(libaio.so.1: 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

┌──(zaidsource㉿Zaid-Desktop)-[~]
└─$ ls /usr/lib/php/20190902/
build        dom.so   fileinfo.so  iconv.so  opcache.so  posix.so     simplexml.so  sysvsem.so    xmlreader.so  xsl.so
calendar.so  exif.so  ftp.so       json.so   pdo.so      readline.so  sockets.so    sysvshm.so    xml.so
ctype.so     ffi.so   gettext.so   oci8.so   phar.so     shmop.so     sysvmsg.so    tokenizer.so  xmlwriter.so

@JackelynOliveira
Copy link

The instructions above helped me a lot. I was able to get a PHP 7 application running with this Dockerfile:

FROM php:7.2.10-apache

RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
RUN apt-get update

COPY instantclient-basic-linux.x64-12.2.0.1.0 /opt/oracle/instantclient/
COPY instantclient-sdk-linux.x64-12.1.0.2.0 /opt/oracle/instantclient/

RUN ln -s /opt/oracle/instantclient/libclntsh.so.12.1 /opt/oracle/instantclient/libclntsh.so

RUN echo '/opt/oracle/instantclient' > /etc/ld.so.conf.d/oracle-instantclient.conf \
    && ldconfig

RUN apt-get install build-essential libaio1 -y
    
RUN echo 'instantclient,/opt/oracle/instantclient' | pecl install oci8-2.2.0 \
       && echo "extension=oci8.so" > /usr/local/etc/php/conf.d/php-oci8.ini

In my case, I also had to install mysql extension because of the application's requirements. So you can ignore the first RUN instruction.

@arvindwill
Copy link

# pecl install oci8
pecl/oci8 requires PHP (version >= 8.1.0), installed version is 7.0.33-0ubuntu0.16.04.16
No valid packages found
install failed

For the above failure use below command.

pecl install oci8-2.2.0

@1dajobs
Copy link

1dajobs commented Jul 15, 2023

When i ran the procedure this was my error :
PHP Warning: PHP Startup: Unable to load dynamic library 'oci8_19' (tried: /usr/lib/php/20210902/oci8_19 (/usr/lib/php/20210902/oci8_19: cannot open shared object file: No such file or directory), /usr/lib/php/20210902/oci8_19.so (/usr/lib/php/20210902/oci8_19.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/20210902/oci8.so (libclntshcore.so.19.1: cannot open shared object file: No such file or directory), /usr/lib/php/20210902/oci8.so.so (/usr/lib/php/20210902/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/20210902/oci8.so (libclntshcore.so.19.1: cannot open shared object file: No such file or directory), /usr/lib/php/20210902/oci8.so.so (/usr/lib/php/20210902/oci8.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

@icanitam
Copy link

I had: php -m | grep 'oci8' PHP Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/lib/php/20180731/oci8.so (libmql1.so: cannot open shared object file: No such file or directory), /usr/lib/php/20180731/oci8.so.so (/usr/lib/php/20180731/oci8.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Then I use: cat /etc/ld.so.conf.d/oracle-instantclient.conf /opt/oracle/instantclient_18_3

sudo ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache

And that's all

Thank you

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