MySQLi not found dockerized php(MySQLi 未找到 dockerized php)
问题描述
我正在尝试对我的网站进行 dockerize.我已经启动并运行了 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQLi 未找到 dockerized php


- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Laravel 仓库 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01