Installation article
First of all, PHP support Oracle I first thought of the PDO-related driver, and looked at it really, called Pdo_oci.
But also rely on Oracle Instant client, this to the Oracle official website to download:
Http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
Select the version of the corresponding system, click in, here is my 64-bit Linux, so choose Instant Client for Linux x86-64 , and then let you agree to a protocol, called Accept License agreement, check You can download it.
It is worth mentioning that if you want to download through the wget mode, you need to register an Oracle account and login, and then click on your own computer to download, get an actual URL (including a token), copy the URL to the server wget, directly wget the URL of the page is not next Remember.
You need to download two packages:
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
The version number may be different, look at the keywords: basic and devel.
These two packages are downloaded to the server and installed separately:
RPM-IVH ORACLE-INSTANTCLIENT12.1-BASIC-12.1.0.2.0-1.X86_64.RPMRPM-IVH oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
Because it is a 64-bit system, in order to prevent the compilation of PHP extension problems, the newly installed two directories to make a soft connection
Ln-s/usr/lib/oracle/12.1/client64/usr/lib/oracle/12.1/clientln-s/usr/include/oracle/12.1/client64/usr/include/ Oracle/12.1/client
OK, the next step is to start installing the pdo_oci extension.
First you should have a PHP source code, if not, please download a copy of the corresponding version of the website.
Suppose my source code is in/home/src/php56.
CD/HOME/SRC/PHP56CD ext/pdo_ociphpize #注释: If you do not have this command you need to find the PHP installation directory bin/, such as/usr/local/php/bin/phpize./configure- with-pdo-oci=instantclient,/usr,12.1--with-php-config=/usr/bin/php-config# Note: 12.1 requires a version number corresponding to the Oracle instant installed above. As with the oracle/12.1 number,--with-php-config is the same as phpize, in the PHP installation directory in the bin directory, the two should be changed to their actual situation. Make && make install
If successful, after the compilation succeeds, modify the php.ini, empty two lines at the end of the file, plus
extension=pdo_oci.so;
Well, by
Php-m
command to see if there is pdo_oci this line, there is OK.
Web Services Remember to restart Apache or PHP-FPM.
Use the article
Using the same process as PDO, I don't know much about Oracle, but I also have a problem with the inability to connect to Oracle.
Start by connecting in the following way:
$PDH = new PDO (' OCI:DBNAME=IP Address: Port number/sid ', username, password);
Error:
SQLSTATE[HY000]: Pdo_oci_handle_factory:ora-12514:tns:listener does not currently know of service requested in Connect D Escriptor
Later on the statckoverflow found a way to change to the following connection:
$tns = "(DESCRIPTION = (Address_list = (address = (PROTOCOL = TCP) (HOST = Your IP) (port = port number))) (Connect_da TA = (sid = SID of your Oracle database)) "; $db _username =" Youname "; $db _password =" YourPassword "; try{$conn = n EW PDO ("Oci:dbname=". $tns, $db _username, $db _password);} catch (Pdoexception $e) {echo ($e->getmessage ());}
That's fine.
Linux under PHP connect Oracle Tutorial