简体   繁体   English

在我的in-webserver php副本中启用mysqli

[英]Enable mysqli in my in-webserver copy of php

As is discussed here: mysqli works when run directly but not when via js-ajax 正如这里所讨论的: mysqli在直接运行时有效,但在通过js-ajax运行时无效

I may need to enable mysqli in my webserver php copy. 我可能需要在我的webserver php副本中启用mysqli。 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? 我如何确定是否在特定的php副本中启用了mysqli,如果不是,我该如何安装它?

My webserver is running Ubuntu 14.04.2 LTS. 我的网络服务器正在运行Ubuntu 14.04.2 LTS。

I have now tried having the following extensions in my php.ini file: 我现在尝试在php.ini文件中使用以下扩展名:

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: 我已经尝试单独运行它们,重新启动mysql和apache,运行sudo php5enmod mysqli然后我再次运行该页面,但同样的错误一直在/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. 除非我从服务器端运行insert.php,否则不会将任何内容添加到sql表中。

When I have all three extension in the php.ini file I get the following errors are well: 当我在php.ini文件中有所有三个扩展名时,我得到以下错误:

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

From your comments it appears your extension_dir was set to /usr/lib64/php/modules but this folder did not exist on your system. 从您的评论看来,您的extension_dir设置为/usr/lib64/php/modules但您的系统上不存在此文件夹。

On your system the mysqli.so module was actually found in /usr/lib/php5/20121212/mysqli.so 在你的系统上,mysqli.so模块实际上是在/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. 要解决此问题,可以将extension_dir设置为/usr/lib/php5/20121212以便extension=mysqli.so行能够找到共享对象。

You need to recompile your PHP and add the code --enable-all to the end. 您需要重新编译PHP并将代码--enable-all添加到最后。 (I think that command is right. If not the concept is) Your shared objects are not installed. (我认为该命令是正确的。如果不是,那么)您的共享对象未安装。

您需要从apache服务器打开mysqli服务,然后重启apache服务器

Follow this guide. 请遵循本指南。

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04 . 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. 跳过关于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. 请注意,php cli(命令行界面)的配置与您的Web服务器使用的php的配置位于不同的文件中。 If you need to configure php for apache, the default path is /etc/php5/apache2/php.ini on UBUNTU 14.02. 如果需要为apache配置php,则默认路径为UBUNTU 14.02上的/etc/php5/apache2/php.ini

If you continue to experience issues with ioncude follow this link https://www.digitalocean.com/community/tutorials/how-to-install-ioncube-loader 如果您仍然遇到ioncude问题,请点击此链接https://www.digitalocean.com/community/tutorials/how-to-install-ioncube-loader

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM