How to configure php to connect to the database under linux

王林
Release: 2019-10-17 17:57:23
Original
4314 people have browsed it

How to configure php to connect to the database under linux

1. Install oracle-instantclient

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

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

Place it in the /usr/packages/ directory.

# rmp -ivh oracle-instantclient*
Copy after login

The /usr/lib/oracle/11.2/client/lib/ directory will be generated at this time.

2. Modify the /etc/ld.so.conf configuration file

Add the following content:

/usr/lib/oracle/11.2/client/lib/
Copy after login

Execute the command:

# ldconfig
Copy after login

3. Install oci8

Download the latest oci8 component

Download oci-2.0.8.tgz

Put it in /usr/packages/ Under contents.

# tar -xvzf oci-2.0.8.tgz # cd oci-2.0.8 # /usr/local/php/bin/phpize (用phpize生成configure配置文件) # ./configure --with-php-config=/usr/local/php/bin/php-config --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client/lib # make && make install
Copy after login

After success, you will be informed that oci8.so has been successfully placed in the following directory.

4. Configure PHP to support OCI extension

Modify the php configuration file

# vi /usr/local/php/lib/php.ini文件
Copy after login

Append the following content after the extension item

extension=oci8.so
Copy after login

5. Restart the Apache service test

# apachectl restart
Copy after login

6. Test the database connection

Write oracle.php in the root directory of the site.

The code is as follows:

"; ocilogoff($conn); } ?>
Copy after login

Enter in the browser address bar:http://192.168.1.131/oracle.php

Instructions:192.168.1.131 is the server address, which directly points to the site and directory of the server Apache.

Display Connected Oracle Successd! indicates that the database connection is successful.

Recommended tutorial:Linux video tutorial

The above is the detailed content of How to configure php to connect to the database under linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!