How to install PHP PDO extension under linux (centos)

藏色散人
Release: 2023-03-02 11:54:01
Original
2801 people have browsed it

How to install PDO extension in PHP: First enter the "pdo_mysql" directory of the PHP extension; then execute the command "make && make install" to compile and install; then add the code "pdo_mysql." in the "php.ini" file. so"; finally restart the service.

How to install PHP PDO extension under linux (centos)

Install PHP's PDO extension under linux (centos)

PHP data object PDO extension is defined for PHP to access the database A lightweight consistent interface. 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. Recently, in our website building and OA system communication group, some friends who are unfamiliar with server operation and maintenance asked about the installation of PHP's PDO extension. In this article we will share with you how to install the PDO extension on the server.

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/

Operation process:

We can check whether the server is installed through the phpinfo() function PDO extension. 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), and enter PHP In the expanded pdo_mysql directory, 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)

How to install PHP PDO extension under linux (centos)

After executing the above command, we will find that the configure file appears in the current pdo_msyql directory.

How to install PHP PDO extension under linux (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/ specifies the installation directory location of the MySQL database
(Here are the specific installation directories of PHP and msyql. Depends on your actual situation)

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

Continue to compile and install:

How to install PHP PDO extension under linux (centos)

make && make install
Copy after login

After the command is executed, the effect is as follows:

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

How to install PHP PDO extension under linux (centos)

Next we modify the PHP configuration file and 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

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

How to install PHP PDO extension under linux (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.

How to install PHP PDO extension under linux (centos)

For more related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to install PHP PDO extension under linux (centos). 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template