Linux php with oracle

eSkiSo / install_oci8_ubuntu20_php7.4.md

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, continue) sudo ln -s libocci.so.21.1 libocci.so (It may already exist, continue)

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/oracle.conf

Install php-dev php-pear build-essential and libaio1

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

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
sudo echo "extension=oci8.so" >> /etc/php/7.4/cli/php.ini
sudo systemctl restart apache2

Add to mods-available

cd /etc/php/7.4/mods-available/ sudo nano oci.ini

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
sudo systemctl restart apache2

Check if OCI is loaded in PHP

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

Based on a post from Carlos Juan

Hi
Before step 5, you should add

because step 5 (and the following) will fail if you’re not as root in shell

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!!

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!!

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.

Читайте также:  What file system is used in linux

Thanks, it worked for Kubuntu 20 with php 7.3 and Nginx (adapting some values to my scenario).

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 

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)

/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`

Источник

PHP Packages for Oracle Linux

This page describes PHP and related packages for current releases of Oracle Linux. For Oracle Linux 8, the packages are provided via AppStream modules and are covered under Oracle Linux support. Consult the Application Stream Module Life Cycle appendix in the Managing Software in Oracle Linux manual for support timelines. For Oracle Linux 7, these packages are published in developer repositories, for which support is limited to package installation assistance only.

Читайте также:  Linux объединение сетевых интерфейсов

Available PHP Releases

PHP Version Oracle Linux Release Repository/Module Name
8.0 Oracle Linux 9 OL9 AppStream / php:8.0
8.0 Oracle Linux 8 OL8 AppStream / php:8.0
7.4 Oracle Linux 8 OL8 AppStream / php:7.4
7.3 Oracle Linux 8 OL8 AppStream / php:7.3
7.2 Oracle Linux 8 OL8 AppStream / php:7.2
7.4 Oracle Linux 7 OL7 Developer / php74

Installation on Oracle Linux 7

These are the steps to install PHP.

Set up Required Repositories

To configure the yum repositories shown above on your system, install the repository setup packageoracle-php-release-el7. After installing this package, the default enabled repository is that for the latest available PHP release. To install the repository setup package for Oracle Linux 7:

$ sudo yum install -y oracle-php-release-el7

Installing PHP

Then, to install the latest available release of PHP on Oracle Linux 7:

Updating PHP

If you have PHP already installed, and a newer release has been published, make sure you update oracle-php-release-el7 first.

$ sudo yum update oracle-php-release-el7
$ sudo yum update php

Connecting PHP to Oracle Database with the PHP OCI8 Extension

The PHP OCI8 database extention enables access to Oracle Database with support for SQL, PL/SQL, bind variables, large object (LOB) types as well connection pooling and result caching features of Oracle Database. Read this blog post for a complete example connecting a PHP 7.4 application to Oracle Database.

Installing PHP OCI8

Each PHP release has its own repository on Oracle Linux yum server and each of those repositories also contains a corresponding RPM for the OCI8 extension, built for a specific major release of Oracle Instant Client. These RPMs follow this naming scheme: php-oci8 . For example, on Oracle Linux 7, the PHP OCI8 RPM for PHP 7.4 is built with Instant Client 19c and is named: php-oci8-19c. To install it:

$ sudo yum install php-oci8-19c

About Oracle Instant Client

PHP OCI8 depends on Oracle Instant Client. Starting with Oracle Instant Client 21c, yum/dnf configuration files are delivered via the packages oracle-instantclient-release-el8 and oracle-instantclient-release-el7, respectively. Oracle Instant Client packages up to release 19c are in the ol7_oracle_instantclient and ol8_oracle_instantclient repositories, configured with release packages oracle-release-el7 and oracle-release-el8. Assuming you have enabled the repository for Oracle Instant Client appropriate for your Oracle Linux release, it will be installed as a dependency. More details about Oracle Instant Client on this yum server.

Installing PHP on Oracle Linux 8 via AppStream Modules

Oracle Linux 8 introduces the concept of Application Streams, where multiple versions of user-space components can be delivered and updated more frequently than the core operating system packages in RPM format or groups of related RPMs called Modules. Oracle Linux 8 offers several independently updated versions of PHP via Module Streams. For mode details, please refer to the documentation.

Читайте также:  Linux bash script if example

To list available Module Streams for PHP:

Installing PHP OCI8 on Oracle Linux 8

To install the PHP OCI8 on Oracle Linux 8, enable both the php:7.4 and the php-oci8 modules.

$ sudo dnf install oraclelinux-developer-release-el8 oracle-instantclient-release-el8
$ sudo dnf module enable php:7.4 php-oci8
$ sudo dnf install php-oci8-21c

Installation on Oracle Linux 9

To install the latest available release of PHP on Oracle Linux 9:

PHP in Containers

  • PHP Command Line Interface tool (PHP CLI)
  • PHP via FastCGI Process Manager (FPM)
  • PHP via Apache HTTP Server with mod_php
  • Variants of each of the above with Oracle Database connectivity via PHP-OCI8

Getting Help

For help with PHP on Oracle Linux, please visit the PHP space in the Oracle Developer Community.

Источник

roshandelpoor / install_oci8_ubuntu20_php7.4.md

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, continue) sudo ln -s libocci.so.21.1 libocci.so (It may already exist, continue)

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/oracle.conf

Install php-dev php-pear build-essential and libaio1

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

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
sudo echo "extension=oci8.so" >> /etc/php/7.4/cli/php.ini
sudo systemctl restart apache2

Add to mods-available

cd /etc/php/7.4/mods-available/ sudo nano oci.ini

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
sudo systemctl restart apache2

Check if OCI is loaded in PHP

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

Based on a post from Carlos Juan

Источник

Оцените статью
Adblock
detector