Home > Article > Backend Development > How to compile and install PHP extension PDO under Linux (CentOS), centospdo_PHP tutorial
This article describes how to compile and install PHP extension PDO under Linux (CentOS). Share it with everyone for your reference, the details are as follows:
Here is CentOS as an example. This should be the case for the Red Hat series of Linux methods. The steps are explained in detail below. I seriously despise the articles that are long-winded and talk about PDO compilation and installation.
1. Enter the PHP package pdo extension directory (note: not the PHP installation directory)
[root@gamejzy /]# cd /tmp/lamp/php-5.3.19/ext/pdo_mysql/
Note: My php package is under /tmp/lamp/php-5.3.19
Execute phpize command
[root@gamejzy pdo_mysql]# /usr/local/php/bin/phpize
Note: /usr/local/php is my php installation directory
After executing the phpize command, configure
will appear in the pdo_mysql directoryExecute configuration
Copy code The code is as follows: [root@gamejzy pdo_mysql]# ./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/ Specify the installation directory location of the MySQL database
Compile and install
[root@gamejzy pdo_mysql]# make && make install
After the compilation is completed, please pay attention to whether a message similar to the following picture appears
If a message appears indicating that the compilation and installation were successful, please pay close attention to the directories enclosed by the red lines (note: the directory names may be different in different time periods).
After compilation and installation are completed, the generated pdo_mysql.so file will be placed in this directory.
2. Modify the php.ini file
Use vi to open the php.ini file of your machine, add a piece of code "extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/pdo_mysql.so", and load pdo_mysql .so file
The effect is as follows:
Save and exit editing!
3. View phpinfo()
First restart the Apache server. Use the phpinfo() function to view the installation information of php. If the following figure appears, the PDO extension is successfully installed.
That’s it!
Readers who are interested in more PHP related content can check out the special topics of this site: "php curl usage summary", "PHP operation and operator usage summary", "PHP network programming skills summary", "PHP basic syntax introductory tutorial" ", "Summary of PHP office document operation skills (including word, excel, access, ppt)", "Summary of PHP date and time usage", "Introduction to PHP object-oriented programming tutorial", "Summary of PHP string (string) usage" , "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"
I hope this article will be helpful to everyone in PHP programming.