Install PHP 7.4 & OCI8 on Centos 7

If you are planning to use PHP to connect to an Oracle database, then the best possible option is to use OCI8, a PHP extension for Oracle.

I will show you how to install PHP 7.4 with OCI8 support on your Centos 7 (This may be applicable on other Linux distributions also).

Watch this video to understand how to enable OCI8 support for PHP:

Add EPEL & REMI Repositories

Run the commands below to add required repositories: yum -y install epel-release yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

Set Config Manager for PHP 7.4

Enable REMI for PHP 7.4 using the commands below: yum -y install yum-utils yum-config-manager –enable remi-php74

Install PHP 7.4

Install PHP 7.4 and required on CentOS 7. yum install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json

Install OCI8

yum install php-oci8

Then edit the php.ini file as follows: vi /etc/php.ini

Then add this line to the file: extension=oci8.so

Save the file and quit.

Then to check if PHP 7.4 is installed correct, issue this command: php -v

Here you’ll see some errors. We have to install Oracle Instant Client packages to solve these errors.

Install Oracle Instant Client

To download latest Oracle Instant Client packages Click here

As of now latest version is 19.8.

You need to download for your the following 2 files for Centos 7:

oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm

oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

Make sure they are in your present working directory, then install with the following commands: yum install oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm yum install oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

Now create links to Oracle Instant Client sh -c “echo /usr/lib/oracle/19.8/client64/lib/ > /etc/ld.so.conf.d/oracle-instantclient.conf” ldconfig

Then issue the following command to verify PHP is installed correctly: php -v

Now the previous errors should have gone!

Restart Apache: systemctl restart httpd

That’s all!

Leave a Comment