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
基础教程推荐
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何替换eregi() 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
