CENTOS6 under PHP installation Oci8 Pdo-oci

Source: Internet
Author: User



Summary: A recent project requires PHP support for Oracle, so deploy this environment.



The server is the AMP environment configured by Yum and operates on the principle of not recompiling. The native environment is PHP,APACHE,MYSQL and requires an Oracle database, so you need to open the Oracle extension. The work we need to do is to install the Oracle client, Pdo_oci extension, oci8 extension.


Pre-preparatory work:
$ sudo yum install php-pear php-devel zlib zlib-devel bc libaio glibc
$ sudo yum groupinstall "Development Tools"


Because the extension still needs to be recompiled, the compiler is also updated.


yum install gcc-c++
yum install gcc-g77


Target database is 11g, go to Oracle official website to download the corresponding version (no Oracle at least we understand that),



Website:



Http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html



Download file:



oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm



oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm



PHP extension File Download:



Http://pecl.php.net/package/PDO_OCI pdo_oci-1.0.tgz Oracle's PDO interface



Http://pecl.php.net/package/oci8 oci8-2.0.8.tgz Oracle Extensions








Installation: Installing Oraclecient


Skills:


RPM - QPL can view the paths where the RPM package will install files


1. Install the RPM package


 
 
rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm


The following commands are for reference only:


RPM - QA | grep Oracle / / check whether Oracle is installed
RPM - QA / / view all installed human RPM packages
RPM - e oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_. RPM / / uninstall the installed RPM package
RPM - IVH -- force oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_. RPM / / force the installation of RPM package


2. Configuration



Modify the/etc/ld.so.conf or add the oracle-x86_64.conf file under the Ld.so.conf.d folder and write to the LIB path where the Oracle client is installed:


#VI / etc / ld.so.conf / usr / lib / Oracle / 11.2 / client64 / lib / / / join this line and save to exit


Or


echo ‘/usr/lib/oracle/11.2/client64/lib/‘ > /etc/ld.so.conf.d/oracle-x86_64.conf


A 64-bit system needs to create a 32-bit soft link (this could be a legacy bug, or it could be a problem with a compilation later)


ln -s /usr/lib/oracle/11.2/client64 /usr/lib/oracle/11.2/client  
ln -s /usr/include/oracle/11.2/client64 /usr/include/oracle/11.2/client



Defining environment variables


vi etc/profile


Add the following lines


export ORACLE_HOME=/usr/lib/oracle/11.2/client64/  
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64:$LD_LIBRARY_PATH  
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"


Command line enter the following statement to make the environment configuration effective immediately


#source /etc/profile





It is said to be so, for reference only:



Create a file inside/etc/profile.d named oracle.sh and put this as the content:


export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib


and run it so we'll have the Ld_library_path as an environment variable.


source /etc/profile.d/oracle.sh
Installing Oci8


The error will occur when compiling:


Error:oci8_dtrace_gen.h:no such file or directory



If you need DTRACE:


yum install systemtap-sdt-develexport PHP_DTRACE=yes


If DTRACE is not required:



Modify the file ' php_oci8_int.h ', change the 48th line


#include "oci8_dtrace_gen.h" to #undef HAVE_OCI8_DTRACE





All ready, compile and install


tar -xvf oci8-2.0.8.tgz  
cd oci8-2.0.8.tgz /usr/bin/phpize
./configure --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib
make
make install


Add configuration files under the/ETC/PHP.D directory 20-oci8.ini


extension=oci8.so


Use the following command to see if it is successful:


php -i | grep oci8


You can see something similar to the following:


/etc/php.d/oci8.ini, oci8oci8.connection_class => no value  => no valueoci8.default_prefetch => 100 => < Span class= "Hljs-number" >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 => < Span class= "Hljs-number" >60 => 60 oci8.privileged_connect = > off => off oci8.statement_cache_size => 20  => 20 




Installing PDO_OCI
tar -xvf PDO_OCI-1.0.tgzcd PDO_OCI-1.0



Prevent pdo_oci against ORACLE11 support (Pdo_oci may not support oracle11g, you need to make a soft link as a oracle10 version to compile the past):


ln -s /usr/include/oracle/11.2 /usr/include/oracle/10.2.0.1  ln -s /usr/lib/oracle/11.2 /usr/lib/oracle/10.2.0.1



It's OK:
Inside the pdo_oci-1.0 folder, edit the file named Config.m4.
Find a pattern like this near line ten and add these 2 lines:


elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.11.2; then  PDO_OCI_VERSION=11.2


Find a pattern like this 101 and add these lines:


11.2)  PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)  ;;



I ran into other problems when I was compiling.


pdo_oci.c:34:error:expected ' = ', ', ', '; ', ' asm ' or ' __attribute__ ' before ' pdo_oci_functions '


In the Pdo_oci.c file


将 function_entry 改成 zend_function_entry


Everything ready, start compiling the installation


/usr/bin/phpize./configure --with-pdo-oci=instantclient,/usr,11.2makemake install


Create a new file under the/ETC/PHP.D directory 30-pdo_oci.ini
Write


extension=pdo_oci.so


Use the following command to see if the installation was successful


php -i | grep oci



You'll see something like the following


/etc/php.d/pdo_oci.ini,PDO drivers => oci, odbc, sqlite





At this end, run Phpinfo () and see.



CENTOS6 under PHP installation Oci8 Pdo-oci


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.