Enable mysqli in my in-webserver copy of php

百般思念 提交于 2019-12-19 18:52:09

问题


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

回答1:


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.




回答2:


You need to recompile your PHP and add the code --enable-all to the end. (I think that command is right. If not the concept is) Your shared objects are not installed.




回答3:


You need open mysqli service from apache server and then restart apache server




回答4:


Follow this guide.

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04.

Skip first step wich is about apache web srver. Note that configuration for php cli (command line interface) is in a different file from the configuration for the php that your webserver uses. If you need to configure php for apache, the default path is /etc/php5/apache2/php.ini on UBUNTU 14.02.

If you continue to experience issues with ioncude follow this link https://www.digitalocean.com/community/tutorials/how-to-install-ioncube-loader



来源:https://stackoverflow.com/questions/31535173/enable-mysqli-in-my-in-webserver-copy-of-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!