找不到MySQLi dockerized php [英] MySQLi not found dockerized php

查看:111
本文介绍了找不到MySQLi dockerized php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对我的网站进行docker化.我已经启动并运行了Nginx和PHP,并且除了无法连接数据库外,它都可以正常工作.页面加载后出现错误:

I'm trying to dockerize my website. I've got Nginx and PHP up and running and it's working find except I can't connect to a db. When the page is loaded I get the error:

Fatal error: Uncaught Error: Class 'MySQLi' not found in /private/conn.php:8 Stack trace: #0 /public_html/index.php(2): require() #1 {main} thrown in /private/conn.php on line 8

我在第8行的连接线是:

My connection line on line 8 is:

$db = new mysqli("$host", "$user", "$pass", "$db", "$port");

现在这在我的旧设置上可以正常工作,但是由于转到了新版本并安装了php7.1.5,所以我无法使其运行.现在,我还没有使用mysqlnd,所以这可能是我的误解,但是mysqlnd包含mysqli驱动程序.

Now this used to work fine on my old set up but since moving to a new one and installing php7.1.5 I can't get it running. Now, I haven't used the mysqlnd so this may be a misunderstanding on my part but the mysqlnd includes the mysqli driver.

phpinfo的输出:

Output of phpinfo:

如何运行它?还是我现在应该使用其他驱动程序?

How can I get this running? Or should I be using a different driver now?

推荐答案

您需要在Dockerfile中启用php扩展名:

You need to enable the php extension in your Dockerfile:

FROM php:7
RUN docker-php-ext-install mysqli

无需触摸php.ini.

这篇关于找不到MySQLi dockerized php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆