The steps for php to install the mysql extension are: 1. Download the mysql extension and unzip it; 2. Initialize using the phpize tool; 3. Configure; 4. Compile and install; 5. Edit the php.ini configuration file and add [ extension=pdo_mysql.so]; 6. Restart the service.
The specific steps are as follows:
(Video tutorial recommendation: php video tutorial)
1 , download the mysql extension
2. Unzip it and use the phpize tool to initialize it (phpize is usually under the PHP installation directory /bin/) and execute it in the folder after the extension is decompressed
/www/server/php/71/bin/phpize
3. configure
./configure --with-php-config=/www/server/php/71/bin/php-config
4. Compile and install
make && make install
After this step, the system will prompt:
Installing shared extensions: /www/server/php/71/lib/php/extensions/no-debug-non-zts-20160303/
The mysql.so we want is in this path.
This path is also the default extension_dir:
PHP default extension_dir path
5. Modify php.ini
Add a line in the php.ini file:
extension=pdo_mysql.so
Save and restart the service.
Tip: If you modify extension_dir, you need to copy the mysql.so file to the corresponding path.
Related recommendations: php training
The above is the detailed content of What are the steps to install mysql extension in php. For more information, please follow other related articles on the PHP Chinese website!