This article describes how to compile and install the 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 articles about PDO compilation and installation that are long-winded and miscellaneous.
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
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 directory enclosed by the red line (note: the directory name 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 on this site: "Summary of php curl usage", "Summary of PHP operations and operator usage", "Summary of PHP network programming skills", "Introduction to PHP basic syntax tutorial", "Summary of PHP operating office document skills (including word, excel, access, ppt)" , "php date and time usage summary", "php object-oriented programming introductory tutorial", "php string (string) usage summary", " php mysql database operation introductory tutorial" and "php common database operation skills summary"
I hope this article will be helpful to everyone in PHP programming.