Home > System Tutorial > LINUX > Install PDO extension for PHP on CentOS

Install PDO extension for PHP on CentOS

WBOY
Release: 2024-01-04 12:00:45
forward
1052 people have browsed it

PHP Data Object PDO extension defines a lightweight consistent interface for PHP to access the database. PDO provides a data access abstraction layer, which means that no matter which database is used, the same functions (methods) can be used to query and obtain data.

environment:

Server system: Centos6.5 (virtual machine demonstration)

PHP software package storage directory:/data/php-5.6.14/

PHP installation directory:/usr/local/php/

mysql installation directory:/usr/local/mysql/

Operating procedures:

Through the phpinfo() function we can check whether the PDO extension is installed on the server. If the PDO extension information is not found, then we install it through the following steps:
Find your PHP installation package (mine is placed in the /data/php-5.6.14/ directory), enter the pdo_mysql directory of the PHP extension, and run the following command:

/usr/local/php/bin/phpize
Copy after login

(/usr/local/php/ is my PHP installation directory, you can modify it according to the actual situation)

Install PDO extension for PHP on CentOS
After executing the above command, we will find that the configure file appears in the current pdo_msyql directory.

Install PDO extension for PHP on CentOS
However, we execute the following command:

./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql/
Copy after login

Parameter Description:
--with-php-config=/usr/local/php/bin/php-config Specifies the configuration when installing PHP
--with-pdo-MySQL=/usr/local/mysql/ Specify the installation directory location of the MySQL database
(The specific installation directory of PHP and msyql here depends on your actual situation)

Continue to compile and install:

make && make install
Copy after login

After the command is executed, the effect is as follows:
Install PDO extension for PHP on CentOS

The directory that is sufficient for the last line will be used later. The pdo_mysql.so file generated at this time is in this directory:

Install PDO extension for PHP on CentOS

Next we modify the PHP configuration file, open your php.ini file, and add a line of code:

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/pdo_mysql.so
Copy after login

(Here is the pdo_mysql.so directory I demonstrated. You can add it according to your actual directory when setting up)

Install PDO extension for PHP on CentOS

Finally save and launch, and restart the service. Then use the phpinfo() function to check whether the PDO extension is installed successfully. The results are as follows, indicating that the PDO extension is installed successfully.
Install PDO extension for PHP on CentOS

The above is the detailed content of Install PDO extension for PHP on CentOS. For more information, please follow other related articles on the PHP Chinese website!

source:linuxprobe.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template