Steps to Install MySQLi Extension for PHP
Identify Installed PHP Version:
First, identify the PHP version currently installed on your system. You can do this by running:
php -v
This command will display the installed PHP version. Note down the version number (e.g., PHP 7.4, PHP 8.0, etc.).
Install MySQLi Extension for the PHP Version:
Based on your PHP version, install the corresponding MySQLi package. Replace phpX.X with your PHP version (e.g., php7.4-mysql for PHP 7.4):
sudo apt-get install php7.4-mysql # Replace with your PHP version
Ensure that you use the correct package name that matches your PHP version installed on your system.
Restart Apache:
After installing the MySQLi extension, restart Apache to apply the changes:
sudo systemctl restart apache2
Verify Installation:
Create a PHP info file to verify that the MySQLi extension is now enabled:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/phpinfo.php
Access phpinfo.php via your web browser (http://your-ec2-instance-public-dns/phpinfo.php) and search for "mysqli" to confirm that the extension is enabled.
0 More Answers