Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable mysqli in my in-webserver copy of php

As is discussed here: mysqli works when run directly but not when via js-ajax

I may need to enable mysqli in my webserver php copy. It is enabled in the command line already.

How do I figure out if mysqli is enabled in a specific php copy, and if it's not, how do I install it?

My webserver is running Ubuntu 14.04.2 LTS.

I have now tried having the following extensions in my php.ini file:

extension=mysqli.so
extension=pdo_mysql.so
extension=php_mysqli.so

I have tried running them all separately, restarted mysql and apache, ran sudo php5enmod mysqli and then I run the page again, but the same error keeps popping up in /var/log/apache/error.log:

PHP Fatal error:  Class 'mysqli' not found in /var/www/html/..

And nothing gets added to the sql table unless I run the insert.php from the server side.

When I have all three extension in the php.ini file I get the following errors are well:

Failed loading /usr/lib64/php/modules/ioncube_loader_lin.so:  /usr/lib64/php/modules/ioncube_loader_lin.so: cannot open shared object file: No such file or directory
Failed loading /usr/lib64/php/modules/ixed.lin:  /usr/lib64/php/modules/ixed.lin: cannot open shared object file: No such file or directory
Failed loading /usr/lib64/php/modules/ZendOptimizer.so:  /usr/lib64/php/modules/ZendOptimizer.so: cannot open shared object file: No such file or directory
Failed loading /usr/lib64/php/modules/opcache.so:  /usr/lib64/php/modules/opcache.so: cannot open shared object file: No such file or directory
like image 960
john-jones Avatar asked Jul 21 '15 09:07

john-jones


1 Answers

From your comments it appears your extension_dir was set to /usr/lib64/php/modules but this folder did not exist on your system.

On your system the mysqli.so module was actually found in /usr/lib/php5/20121212/mysqli.so

To resolve the issue, you can set the extension_dir to /usr/lib/php5/20121212 so that the extension=mysqli.so line is able to find the shared object.

like image 184
ssnobody Avatar answered Nov 15 '22 10:11

ssnobody