Linux CentOS Centos7 installs oci8 and PDO_OCI extensions

Source: Internet
Author: User
Tags php script


Linux Centos7 installing oci8 and Pdo_oci extensions



First, the basic environment
1, centos7_64+apache/2.4.7+php5.3.27;
2, oracle11.2 (remote)
3. Set oracle11.2 to run remote access (within the scope of Oracle settings)
4, set the firewall operating direction
5. The following steps are performed as root



Second, install OCI8 extension


1, to the oracle official website to download:
Oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm and oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm (Note: different depending on operating system and database version) version of)

2, install the above two rpm packages
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 above installation path is:
/usr/lib/oracle/11.2/client64/lib and /usr/include/oracle/11.2/client64.

The following commands may also be used:
Rpm -qpl to see which path the rpm package will install the file
Rpm -qa | grep oracle / / check whether oracle is installed
Rpm -qa / / View all installed people rpm package
Rpm -e oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm //Uninstall the installed rpm package
Rpm -ivh --force oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm //force the installation of the rpm package

3, to the php official website to download oci8-2.0.8.tgz (can not use the high version, otherwise the following may report an error) and extract the folder into oci8-2.0.8

4, execute in the oci8-2.0.8 folder

# phpize (here is the full path to the phpize command)
# ./configure --with-oci8=instantclient, /usr/lib/oracle/11.2/client64/lib ----with-php-config=php-config (here is the full path to the php-config command)

# make && make install
After successful execution, the interface will output the full path of oci8.so

5, add in the php.ini file
Extension=oci8.so (here should fill in the full path of oci8.so, this path is output in the previous command)

6, restart apache
Httpd -k restart (here is the full path to httpd)


Third, install Pdo_oci extension


First perform the above steps 1 and 2;

3. Execute #vi /etc/ld.so.conf
/usr/lib/oracle/11.2/client64/lib/ //Add this line, save and exit

4, execution

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
64-bit systems need to create 32-bit soft links (here may be a legacy bug)

5, execute 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"

6, execution
#source /etc/profile

7, execution
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
Note: Prevent pdo_oci from supporting oracle11 insufficiently

8, the official website to download php-5.3.27.tar.gz, extract the pdo_oci folder into the php extension directory (such as the main directory / ext / pdo)

9. Execute in "home directory /ext/pdo":
# phpize (here is the full path to the phpize command)
# ./configure --with-pdo-oci=instantclient, /usr,11.2 --with-php-config=php-config (here is the full path to the php-config command)

# make && make install
After successful execution, the interface will output the full path of pdo_oci.so

10, add in the php.ini file
Extension=pdo_oci.so (here should fill in the full path of pdo_oci.so, this path is output in the previous command)

11, restart apache
Httpd -k restart (here is the full path to httpd)


Fourth. test whether the installation is successful




1. Execute ./php -i |grep oci (here the full path of the php command). The output is as follows:
Oci8
......
PDO drivers => mysql, sqlite, sqlite2, oci

2, you can also use php script test
Test pdo_oci: $pdo= new PDO (‘oci:dbname=//oracle ip address: 1521/database name; charset=utf8', username, password);
Test oci8: $conn = oci_connect (username, password, oracle ip address: 1521 / database name); 


Linux CentOS Centos7 installs oci8 and PDO_OCI extensions


Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

Related Article

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.