[英]Docker-php-ext-install vs apt install?
I'm trying to install pdo-mysql to PHP container I tried to install it using command line as:我正在尝试将 pdo-mysql 安装到 PHP 容器我尝试使用命令行安装它:
apt install pdo pdo_mysql
but the extension not installed and provide a lot of errors.但未安装扩展并提供了很多错误。
But When I use但是当我使用
docker-php-ext-install pdo pdo_mysql
The extension was installed successfully扩展安装成功
So what is the difference between them, and when must use each of them?那么它们之间有什么区别,什么时候必须使用它们呢?
apt
is a softwar for Debian-like Linux distributions to manage packages. apt
是一个类似 Debian 的 Linux 发行版管理软件包的软件。 It can install pre-compiled packages for your distribution.它可以为您的发行版安装预编译的软件包。 It can do it for PHP-related packages as well.
它也可以用于 PHP 相关的包。 If you installed PHP using
apt
you can also install additional packages for it like that:如果您使用
apt
安装了 PHP ,您还可以为它安装其他软件包,如下所示:
sudo apt install -y php-pdo-mysql
The exact package name will depend on the distribution you used and/or how you installed PHP in the first place.确切的 package 名称将取决于您使用的发行版和/或首先安装 PHP 的方式。
The docker-php-ext-install
is a special shell script in the official PHP Docker image where PHP was installed from the source. The
docker-php-ext-install
is a special shell script in the official PHP Docker image where PHP was installed from the source. It will compile and install the necessary extensions.它将编译并安装必要的扩展。
Since you are using this Docker image docker-php-ext-install
is the way to go.由于您正在使用此 Docker 图像 docker
docker-php-ext-install
是 go 的方式。
To sum it up: it all depends on how PHP was installed in your Docker image in the first place.总结一下:这一切都取决于 PHP 首先是如何安装在您的 Docker 映像中的。 If a package manager was used - then
apt
is the way to go.如果使用了 package 管理器 - 那么
apt
就是通往 go 的方法。 If you use the official PHP Docker image it compiles PHP from the source code and provides a shortcut to compile additional extensions using docker-php-ext-install
.如果您使用官方 PHP Docker 映像,它会从源代码编译 PHP 并提供使用
docker-php-ext-install
编译其他扩展的快捷方式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.