Ubuntu PHP 致命错误:调用 PHP 脚本时调用未定义的函数 mysqli_connect() in..
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24290589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ubuntu PHP Fatal error: Call to undefined function mysqli_connect() in.. when calling PHP script
提问by jt123
I run Ubuntu desktop 14.04LTS (Trusty Tahr), and I am trying to setup Apache 2, MySQL server and PHP, but I keep gettin the following error:
我运行Ubuntu 桌面 14.04LTS (Trusty Tahr),并且我正在尝试设置 Apache 2、MySQL 服务器和 PHP,但我不断收到以下错误:
PHP Fatal error: Call to undefined function mysqli_connect() in..
PHP 致命错误:调用未定义的函数 mysqli_connect() in..
What I have done is these changes in the correct php.ini:
我所做的是在正确的 php.ini 中进行了这些更改:
uncomment:
取消注释:
extension=msqli.so
扩展名=msqli.so
set path aquired from phpinfo():
设置从 phpinfo() 获取的路径:
extension_dir = "./usr/lib/php5/20121212+lfs"
extension_dir = "./usr/lib/php5/20121212+lfs"
Why is the mysqli function to connect to the database still undefined?
为什么连接数据库的mysqli函数还是undefined?
回答by syyu
In my case php5-mysql was missing from my Ubuntu server. After installing the package it is working fine with mysqli adapter.
在我的情况下,我的 Ubuntu 服务器中缺少 php5-mysql。安装软件包后,它可以与 mysqli 适配器一起正常工作。
sudo apt-get install php5-mysql
It resolved my CodeIgniter 3.0 mysqli connection valid.
它解决了我的 CodeIgniter 3.0 mysqli 连接有效。
回答by Andrew
running updates is usually recommended
通常建议运行更新
sudo apt-get update
then install needed version
然后安装需要的版本
sudo apt-get install php5-mysql
sudo apt-get install php7.0-mysql
sudo apt-get install php7.1-mysql
sudo apt-get install php7.2-mysql
restart apache
重启阿帕奇
sudo service apache2 restart