Install instant client
First, from/technetwork/topics/Download the basic and devel rpm package or zip compressed package corresponding to the corresponding database version. I'll choose the rpm package here. Then install:
rpm -Uvh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
rpm -Uvh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
In this way, the instant client tool has been installed. Next is PHP's extension oci8.
Install the oci8 extension
Regarding the installation method of oci8, there is a detailed introduction in the official PHP document, online address/manual/en/. I chose pecl installation here. Run the command directly:
pecl install oci8
Note that if you are using PHP7.0 or above like me, then use the above command. If it is another version, you can see the Oci8 page of Pecl.
Use 'pecl install oci8-2.0.12' to install
for PHP 5.2 - PHP 5.6. Use 'pecl install oci8-1.4.10' to install for
PHP 4.3.9 - PHP 5.1
After running the installation command, you will prompt to enter the instant client path, and the original prompt is:
Please provide the path to the ORACLE_HOME directory.
Use 'instantclient,/path/to/instant/client/lib' if you're compiling
with Oracle Instant Client [autodetect] :
The default path is /usr/lib/oracle/11.2/client64/lib. Note that you need to add instantclient before, and the complete input is:
instantclient,/usr/lib/oracle/11.2/client64/lib
When I first installed it, I didn't read it carefully. I just saw the last autodetect and went straight to the car, which caused the subsequent test to connect to the database to fail. After waiting for installation, the last step is to add configuration extension= or start a new .ini file to restart php-fpm
service php-fpm restart
Now you can connect to the Oracle database and the local development environment is also built.