The PHP version is "PHP 7.4.30", MariaDB version (mysql Ver 15.1 Distrib 10.6.8-MariaDB, for Linux (x86_64) using readline 5.1). and I am using Centos 7.
When I run the file locally it works but when I run the same file on the browser it shows the 500 error https://passimage.in/i/9fd1937c0a5d389b447e.png and in error_log I see "PHP Fatal error" Here is the example code
$mysqli = mysqli_connect('localhost','my_user','my_password','my_db', 'port', '/path/mysql/mysql.sock');
if ($mysqli->connect_error) {
echo "Failed to connect to MySQL: (".$mysqli->connect_errno.")". $mysqli->connect_error;
exit();
}
else {
echo "connected";
}
The error i see is
[Mon Aug 08 08:07:54.188110 2022] [proxy_fcgi:error] [pid 21030] [client 59.92.251.25:56390] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /home/deep/public_html/wpinfo.php:15\nStack trace:\n#0 {main}\n thrown in /home/deep/public_html/wpinfo.php on line 15\n'
In /etc/php.ini i have uncommented extension=mysqli
the mysqli is installed https://passimage.in/i/c9a19a98cdc1627f2420.png, but the default port and path are different. but in my /etc/my.cnf
file the port and socket path is set. In the Database, I can see the port is set https://passimage.in/i/c994d99f4fc812c6a0ca.png.
Is it causing the issue? if yes how to change it?
any help would be appreciated thank you!