我正在尝试对我的网站进行 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
PHP、MySQL PDOException 的死锁异常代码?Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死锁异常代码?)
PHP PDO MySQL 可滚动游标不起作用PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滚动游标不起作用)
PHP PDO ODBC 连接PHP PDO ODBC connection(PHP PDO ODBC 连接)
使用 PDO::FETCH_CLASS 和魔术方法Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔术方法)
php pdo 只从 mysql 获取一个值;等于变量的值php pdo get only one value from mysql; value that equals to variable(php pdo 只从 mysql 获取一个值;等于变量的值)
MSSQL PDO 找不到驱动程序MSSQL PDO could not find driver(MSSQL PDO 找不到驱动程序)