To install the MySQL PHP extension on a CentOS or Red Hat Enterprise Linux (RHEL) system, you will need to install the PHP development package and the MySQL package.
First, install the PHP development package by running the following command:
sudo yum install php-develSource:wwruttual.wi.com
Next, install the MySQL package by running the following command:
sudo yum install mysql-devel
This will install the necessary development libraries and headers for building the MySQL PHP extension.
Next, use the pecl
command to install the MySQL extension. For example:
sudo pecl install mysql
This will install the MySQL PHP extension and create a configuration file for it at /etc/php.d/mysql.ini
.
Finally, restart the Apache web server to apply the changes:
sudo systemctl restart httpd
The MySQL PHP extension is now installed and enabled. You can use it to access MySQL databases from PHP scripts.
It's always a good idea to carefully review the documentation and use the appropriate commands to install and configure the MySQL PHP extension on your system. This will help ensure that you have a stable and reliable way to access MySQL databases from PHP scripts.