Home >Backend Development >PHP Tutorial >PHP+Oracle local development environment setup

PHP+Oracle local development environment setup

藏色散人
藏色散人forward
2019-03-28 11:44:205895browse

The general environment of PHP is lamp or lnmp. Since I will be participating in a banking project in the near future, using Oracle database (the database is on a remote server), I need to build a new development environment. My original environment is based on vagrant, so I only need to install Oracle in the original environment. instant client tool and oci8 extension for PHP.

PHP+Oracle local development environment setup

Install instant client

First, from https://www.oracle.com/technetwork/topics/linuxx86- 64soft-092277.html Download the basic and devel rpm packages or zip packages corresponding to the corresponding database versions. I 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 the PHP extension oci8.

Install oci8 extension

The installation method of oci8 is detailed in the PHP official document, online address http://php.net/manual/en /oci8.installation.php. I choose pecl installation here. Run the command directly:

pecl install oci8

Note, if you are using PHP7.0 or above like me, then use the above command. If it is another version, you can see relevant instructions on pecl's oci8 page:

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 be prompted to enter the instant client path. 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 in front. The complete input is:

instantclient,/usr/lib/oracle/11.2/client64/lib

When I installed it for the first time, I didn’t read it carefully. I only saw the last autodetect and pressed Enter directly, which caused the subsequent test to fail to connect to the database. . After waiting for the installation, the last step is to add the configuration extension=oci8.so to php.ini or start a new .ini file, restart php-fpm:

service php-fpm restart

Now, you can connect The Oracle database has been installed, and the local development environment has been set up.

The above is the detailed content of PHP+Oracle local development environment setup. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:leslieli. If there is any infringement, please contact admin@php.cn delete