<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/oci8.setup.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'oci8.installation.php',
    1 => 'Встановлення',
    2 => 'Встановлення',
  ),
  'up' => 
  array (
    0 => 'oci8.setup.php',
    1 => 'Встановлення/налаштування',
  ),
  'prev' => 
  array (
    0 => 'oci8.requirements.php',
    1 => 'Вимоги',
  ),
  'next' => 
  array (
    0 => 'oci8.test.php',
    1 => 'Testing',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/oci8/configure.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="oci8.installation" class="section">
 <h2 class="title">Встановлення</h2>


<div class="section" id="oci8.configure">
<h2 class="title">Configuring PHP with OCI8</h2>
 <p class="para">
  Review the
  previous <a href="oci8.requirements.php" class="link">Requirements</a>
  section before configuring OCI8.
 </p>
 <p class="para">
  Before starting the web server, OCI8 typically requires several
  Oracle environment variables (see below) to locate libraries, point
  to configuration files, and set some basic properties such as the
  character set used by Oracle libraries.  The variables must be set
  <em>before</em> any PHP process starts.
 </p>
 <p class="para">
  The PHP binary must link with the same, or more recent, major version of
  Oracle libraries as it was configured with.  For example, if you build
  OCI8 with Oracle 19 libraries, then PHP should also be deployed
  and run with Oracle 19 libraries. PHP applications can connect to other
  versions of Oracle Database, since Oracle has client-server cross-version compatibility.
 </p>
</div>
<div class="section">
 <h2 class="title">Installing OCI8 from PECL Using the pecl Command</h2>
 <p class="para">
  The OCI8 extension can be added to an existing PHP installation by using
  the <a href="https://pecl.php.net/package/oci8" class="link external">&raquo;&nbsp;PECL</a> repository.
 </p>
 <p class="para">
  <ul class="itemizedlist">
   <li class="listitem">
    <p class="para">
     If you are behind a firewall, set PEAR&#039;s proxy, for example:
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
pear config-set http_proxy http://my-proxy.example.com:80/
</pre></div>
      </div>
     </div>
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     Run
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
pecl install oci8
</pre></div>
      </div>
     </div>
    </p>
    <p class="para">
     For PHP 7, use <code class="literal">pecl install oci8-2.2.0</code>
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     When prompted, enter either the value of <code class="literal">$ORACLE_HOME</code>, or
     <code class="literal">instantclient,/path/to/instant/client/lib</code>.
    </p>
    <p class="para">
      Note: Do not enter variable names like <code class="literal">$ORACLE_HOME</code>
      or <code class="literal">$HOME</code> because <code class="literal">pecl</code> will not
      expand them.  Instead, enter an expanded path, for
      example <code class="literal">/opt/oracle/product/19c/dbhome_1</code>
      or <code class="literal">instantclient,/Users/myname/Downloads/instantclient_19_8</code>
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     If you get an error <code class="literal">oci8_dtrace_gen.h: No such file or
     directory</code>, it means PHP was built
     with <a href="features.dtrace.php" class="link">DTrace Dynamic Tracing</a> enabled.
     Install using:
    </p>
   <p class="para">
    <div class="informalexample">
     <div class="example-contents screen">
<div class="cdata"><pre>
$ export PHP_DTRACE=yes
$ pecl install oci8
</pre></div>
     </div>
    </div>
   </p>    
   </li>   
   <li class="listitem">
    <p class="para">
      Edit your <var class="filename">php.ini</var> file and add the line:
    </p>
    <p class="para">
      <div class="informalexample">
        <div class="example-contents screen">
          <div class="cdata"><pre>
extension=oci8.so
</pre></div>
        </div>
      </div>
    </p>
    <p class="para">
      Make sure the <var class="filename">php.ini</var>
      directive <a href="ini.core.php#ini.extension-dir" class="link">extension_dir</a> is
      set to the directory that <var class="filename">oci8.so</var> was installed
      in.
    </p>
   </li>
  </ul>
 </p>
</div>
<div class="section">
 <h2 class="title">Installing OCI8 from PECL Using phpize</h2>
 <p class="para">
  To install OCI8 on an existing PHP installation when
  the <code class="literal">pecl</code> command is not available, manually download
  the <a href="https://pecl.php.net/package/oci8" class="link external">&raquo;&nbsp;PECL</a> OCI8 package,
  e.g. <var class="filename">oci8-3.0.0.tgz</var>.
 </p>
 <p class="para">
  <ul class="itemizedlist">
   <li class="listitem">
    <p class="para">
     Extract the package:
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
tar -zxf oci8-3.0.0.tgz
cd oci8-3.0.0
</pre></div>
      </div>
     </div>
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     Prepare the package:
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
phpize
</pre></div>
      </div>
     </div>
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     Configure the package, either
     using <code class="literal">$ORACLE_HOME</code> or Instant Client
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
./configure -with-oci8=shared,$ORACLE_HOME
</pre></div>
      </div>
     </div>
    </p>
    <p class="para">
     or
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
./configure -with-oci8=shared,instantclient,/path/to/instant/client/lib
</pre></div>
      </div>
     </div>
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     Install the package:
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
make install
</pre></div>
      </div>
     </div>
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     If you get an error <code class="literal">oci8_dtrace_gen.h: No such file or
     directory</code>, it means PHP was built
     with <a href="features.dtrace.php" class="link">DTrace Dynamic Tracing</a> enabled.
     Re-run the <code class="literal">configure</code> and <code class="literal">make</code>
     commands after setting this environment variable:
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
$ export PHP_DTRACE=yes
</pre></div>
     </div>
    </div>
   </p>    
   </li>
   <li class="listitem">
    <p class="para">
      Edit your <var class="filename">php.ini</var> file and add the line:
    </p>
    <p class="para">
      <div class="informalexample">
        <div class="example-contents screen">
          <div class="cdata"><pre>
extension=oci8.so
</pre></div>
        </div>
      </div>
    </p>
    <p class="para">
      Make sure the <var class="filename">php.ini</var>
      directive <a href="ini.core.php#ini.extension-dir" class="link">extension_dir</a> is
      set to the directory that <var class="filename">oci8.so</var> was installed
      in.
    </p>
   </li>
  </ul>
 </p>
</div>
<div class="section">
 <h2 class="title">Installing OCI8 as a Shared Extension when Building PHP</h2>
 <p class="para">
  If you are building PHP from source code, the
  configuration <code class="literal">shared</code> option can be used to build OCI8 as a shared library
  that can be dynamically loaded into PHP.  Building a shared extension allows
  OCI8 to be upgraded easily without impacting the rest of PHP.
 </p>
 <p class="para">
  Configure OCI8 using one of the following configure options.
 </p>
 <p class="para">
  <ul class="itemizedlist">
   <li class="listitem">
    <p class="para">
     If using the free <a href="https://www.oracle.com/database/technologies/instant-client.html" class="link external">&raquo;&nbsp;Oracle Instant
     Client</a> libraries, then do:
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
./configure --with-oci8=shared,instantclient,/path/to/instant/client/lib
</pre></div>
      </div>
     </div>
    </p>
    <p class="para">
     If Instant Client 12.2 (or earlier) is installed from ZIP files, make sure to create
     the library symbolic link first, for example <code class="literal">ln -s
     libclntsh.so.12.1 libclntsh.so</code>.
    </p>
    <p class="para">
     If using an RPM-based installation of Oracle Instant Client, the
     configure line will look like this:
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
./configure --with-oci8=shared,instantclient,/usr/lib/oracle/&lt;version&gt;/client/lib
</pre></div>
      </div>
     </div>
    </p>
    <p class="para">
     For example, <strong class="option configure">--with-oci8=shared,instantclient,/usr/lib/oracle/19.9/client/lib</strong>
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     If using an Oracle database or full Oracle Client installation then do:
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
./configure --with-oci8=shared,$ORACLE_HOME
</pre></div>
      </div>
     </div>
    </p>
    <p class="para">
     Make sure the web server user
     (<code class="literal">nobody</code>, <code class="literal">www</code>) has access to
     the libraries, initialization files
     and <var class="filename">tnsnames.ora</var> (if used) under
     the <code class="literal">$ORACLE_HOME</code> directory.  With Oracle
     10<em>g</em>R2, you may need to run
     the <var class="filename">$ORACLE_HOME/install/changePerm.sh</var>
     utility to give directory access.
    </p>
   </li>
  </ul>
 </p>
 <p class="para">
  After configuration, follow the usual PHP building procedure,
  e.g. <em>make install</em>.  The OCI8 shared extension
  <var class="filename">oci8.so</var> library will be created.  It may need
  to be manually moved to the PHP extension directory, specified by
  the <a href="ini.core.php#ini.extension-dir" class="link">extension_dir</a> option in
  your <var class="filename">php.ini</var> file.
 </p>
 <p class="para">
  To complete installation of OCI8, edit <var class="filename">php.ini</var> and add the line:
 </p>
 <p class="para">
  <div class="informalexample">
   <div class="example-contents screen">
<div class="cdata"><pre>
extension=oci8.so
</pre></div>
   </div>
  </div>
 </p>
</div>
<div class="section">
 <h2 class="title">Installing OCI8 as a Statically Compiled Extension when Building PHP</h2>
 <p class="para">
  If you are building PHP from source code, you can configure PHP to include
  OCI8 as a static extension using one of the following configure options.
 </p>
 <p class="para">
  <ul class="itemizedlist">
   <li class="listitem">
    <p class="para">
     If using Oracle Instant Client, then do:
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
./configure --with-oci8=instantclient,/path/to/instant/client/lib
</pre></div>
      </div>
     </div>
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     If using an Oracle database or full Oracle Client installation then do:
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents screen">
<div class="cdata"><pre>
./configure --with-oci8=$ORACLE_HOME
</pre></div>
      </div>
     </div>
    </p>
   </li>
  </ul>
 </p>
 <p class="para">
  After configuration, follow the usual PHP building procedure,
  e.g. <em>make install</em>.  After successful
  compilation, you do not need to add <var class="filename">oci8.so</var> to
  <var class="filename">php.ini</var>.  No additional build steps are required.
 </p>
</div>
<div class="section">
 <h2 class="title">Installing OCI8 on Windows</h2>
 <p class="para">
  The OCI8 extension can be added to an existing PHP installation by using the
  DLLs from <a href="https://pecl.php.net/package/oci8" class="link external">&raquo;&nbsp;PECL</a> repository or
  the libraries in your PHP installation&#039;s <code class="literal">ext</code> directory.
 </p>
 <p class="para">
  With Oracle 12<em>c</em> (or later) libraries, uncomment one of
  the <var class="filename">php.ini</var> lines <code class="literal">extension=php_oci8_12c.dll</code>
  or <code class="literal">extension=php_oci8_11g.dll</code>
  or <code class="literal">extension=php_oci8.dll</code>. Only one of these DLLs may be
  enabled at a time. DLLs with higher versions may contain more
  functionality. Not all DLLs may be available for all versions of PHP.  Make
  sure <a href="ini.core.php#ini.extension-dir" class="link">extension_dir</a> is set to the
  directory containing the PHP extension DLLs.
 </p>
 <p class="para">
  If using Instant Client, set the system <var class="envar">PATH</var>
  environment variable to the Oracle library directory.
 </p>
</div>
<div class="section">
 <h2 class="title">Setting the Oracle Environment</h2>
 <p class="para">
  Before using this extension, make sure that the Oracle environment
  variables are properly set for the web daemon user.  If your web
  server is automatically started at boot time then make sure that the
  boot-time environment is also configured correctly.
 </p>
 <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
  <p class="para">
   Do not set Oracle environment variables
   using <span class="function"><a href="function.putenv.php" class="function">putenv()</a></span> in a PHP script because Oracle
   libraries may be loaded and initialized before your script
   runs. Variables set with <span class="function"><a href="function.putenv.php" class="function">putenv()</a></span> may then cause
   conflicts, crashes, or unpredictable behavior.  Some functions may
   work but others might give subtle errors. The variables should be
   set up <em>before</em> the web server is started.  
  </p>
 </p></blockquote>
 <p class="para">
  On Red Hat Linux and variants, export variables at the end of
  <var class="filename">/etc/sysconfig/httpd</var>.  Other systems with
  Apache 2 may use an <var class="filename">envvars</var> script in the
  Apache <var class="filename">bin</var> directory.  A third option, the
  Apache <code class="literal">SetEnv</code> directive
  in <var class="filename">httpd.conf</var>, may work in some systems but is
  known to be insufficient in others.
 </p>
 <p class="para">
  To check that environment variables are set correctly,
  use <span class="function"><a href="function.phpinfo.php" class="function">phpinfo()</a></span> and check
  the <em>Environment</em> (not the <em>Apache
  Environment</em>) section contains the expected variables.
 </p>
 <p class="para">
  The variables that might be needed are included in the following
  table.  Refer to the Oracle documentation for more information on
  all the available variables.
  <table class="doctable table">
   <caption><strong>Common Oracle Environment Variables</strong></caption>
   
    <thead>
     <tr>
      <th>Name</th>
      <th>Purpose</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>ORACLE_HOME</td>
      <td>Contains the directory of the full Oracle Database
      software.  Do not set this when using Oracle Instant Client as
      it is unnecessary and may cause installation problems.</td>
     </tr>

     <tr>
      <td>ORACLE_SID</td>
      <td>Contains the name of the database on the local machine to
      be connected to. There is no need to set this if you using
      Oracle Instant Client, or always pass the connection parameter
      to <span class="function"><a href="function.oci-connect.php" class="function">oci_connect()</a></span>.</td>
     </tr>

     <tr>
      <td>LD_LIBRARY_PATH</td>
      <td>Set this (or its platform equivalent, such
      as <code class="literal">LIBPATH</code>, or <code class="literal">SHLIB_PATH</code>) to the
      location of the Oracle libraries, for
      example <var class="filename">$ORACLE_HOME/lib</var>
      or <var class="filename">/usr/lib/oracle/18.5/client/lib</var>. Note with Instant
      Client ZIP files on Linux it is more reliable to
      use <var class="filename">ldconfig</var> instead, see the Instant Client
      installation instructions.  With Instant Client 19 (or later) RPM
      files, <code class="literal">ldconfig</code> is automatically run for you.  Some
      users use
      <code class="literal">LD_PRELOAD</code> instead
      of <code class="literal">LD_LIBRARY_PATH</code>.</td>
     </tr>

     <tr>
      <td>NLS_LANG</td>
      <td>This is the primary variable for setting the character
      set and globalization information used by the Oracle
      libraries.</td>
     </tr>

     <tr>
      <td>ORA_SDTZ</td>
      <td>Sets the Oracle session timezone.</td>
     </tr>

     <tr>
      <td>TNS_ADMIN</td>
      <td>Contains the directory where the Oracle Net Services configuration
      files such as <var class="filename">tnsnames.ora</var>
      and <var class="filename">sqlnet.ora</var> are kept.  Not needed if
      the <span class="function"><a href="function.oci-connect.php" class="function">oci_connect()</a></span> connection string uses the Easy
      Connect naming syntax such as <code class="literal">localhost/XE</code>.  Not needed
      if the network configuration files are in one of the default locations
      such
      as <var class="filename">/usr/lib/oracle/VERSION/client/lib/network/admin</var>, <var class="filename">$ORACLE_HOME/network/admin</var>
      or <var class="filename">/etc</var>.</td>
     </tr>

    </tbody>
   
  </table>

   Less frequently used Oracle environment variables include
   <code class="literal">TWO_TASK</code>, <code class="literal">ORA_TZFILE</code>, and the
   various Oracle globalization settings
   like <code class="literal">NLS*</code> and the <code class="literal">ORA_NLS_*</code>
   variables.  
 </p>
</div>
<div class="section">
 <h2 class="title">Troubleshooting</h2>
 <p class="para">
  The most common problem with installing OCI8 is not having the
  Oracle environment correctly set.  This typically appears as a
  problem using <span class="function"><a href="function.oci-connect.php" class="function">oci_connect()</a></span>
  or <span class="function"><a href="function.oci-pconnect.php" class="function">oci_pconnect()</a></span>.  The error may be a PHP error
  such as <em>Call to undefined function
  oci_connect()</em>, an Oracle error such as ORA-12705, or even
  an Apache crash.  Check the Apache log files for startup errors and
  see the sections above to resolve this problem.
 </p>
 <p class="para">
  While network errors like ORA-12154 or ORA-12514 indicate an Oracle
  network naming or configuration issue, the root cause may be because
  the PHP environment is incorrectly set up and Oracle libraries are
  unable to locate the <var class="filename">tnsnames.ora</var> configuration
  file.
 </p>
 <p class="para">
  On Windows, having multiple versions of Oracle on the one machine
  can easily cause library clashes unless care is taken to make sure
  PHP only uses the correct version of Oracle.
 </p>
 <p class="para">
  A utility to examine what libraries are being looked for and loaded
  can help resolve missing or clashing library issues, particularly on
  Windows.
 </p>
 <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
  <strong>If the web server doesn&#039;t start or crashes at
  startup</strong><br />
  <p class="para">
   Check that Apache is linked with the pthread library:
  </p>
  <p class="para">
   <div class="informalexample">
    <div class="example-contents screen">
<div class="cdata"><pre>
# ldd /www/apache/bin/httpd
  libpthread.so.0 =&gt; /lib/libpthread.so.0 (0x4001c000)
  libm.so.6 =&gt; /lib/libm.so.6 (0x4002f000)
  libcrypt.so.1 =&gt; /lib/libcrypt.so.1 (0x4004c000)
  libdl.so.2 =&gt; /lib/libdl.so.2 (0x4007a000)
  libc.so.6 =&gt; /lib/libc.so.6 (0x4007e000)
  /lib/ld-linux.so.2 =&gt; /lib/ld-linux.so.2 (0x40000000)
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   If the libpthread is not listed, then reinstall Apache:
  </p>
  <p class="para">
   <div class="informalexample">
    <div class="example-contents screen">
<div class="cdata"><pre>
# cd /usr/src/apache_1.3.xx
# make clean
# LIBS=-lpthread ./config.status
# make
# make install
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   Please note that on some systems like UnixWare, it is libthread
   instead of libpthread. PHP and Apache have to be configured with
   EXTRA_LIBS=-lthread.
  </p>
 </p></blockquote>
</div>


</div><?php manual_footer($setup); ?>