Home >Backend Development >PHP Problem >How to install PHP PDO extension under linux (centos)
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.
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.
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/
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
(/usr/local/php/ is my PHP installation directory, you can modify it according to the actual situation)
After executing the above command, we will find that the configure file appears in the current pdo_msyql directory.
However, we execute the following command:
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql/
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
Continue to compile and install:
make && make install
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:
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
(This is the pdo_mysql.so directory I demonstrated, you can add it according to your actual directory when setting up)
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.
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!