简体   繁体   English

Docker-php-ext-install 与 apt 安装?

[英]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.

相关问题 如何通过 docker-php-ext-install 安装 php 的扩展? - How to install extension for php via docker-php-ext-install? Docker-php-ext-install mcrypt 缺少文件夹 - Docker-php-ext-install mcrypt missing folder docker-php-ext-configure、docker-php-ext-install 和 docker-php-ext-enable 有什么作用? - What do docker-php-ext-configure, docker-php-ext-install and docker-php-ext-enable do? 无法使用 docker-php-ext-install 安装 pdo_mysql - Can't install pdo_mysql with docker-php-ext-install docker-php-ext-install bz2失败(在php:7.0-fpm-alpine上,使用alpine 3.4) - Failure with `docker-php-ext-install bz2` (on php:7.0-fpm-alpine, with alpine 3.4) 如何在我的 docker 镜像中添加辅助脚本 docker-php-ext-configure、docker-php-ext-install - How can I add helper scripts docker-php-ext-configure, docker-php-ext-install in my docker image 为什么 docker-php-ext-install 不包含一些扩展,并且比 pecl 有优势? - Why docker-php-ext-install does not contains some extensions, and has it advantages over pecl? 全球PHP安装包:apt-get与composer - PHP install package globally: apt-get vs composer Docker:如何安装 PHP 7.4 扩展 ext-http? - Docker: How to install PHP 7.4 extension ext-http? Docker 容器无法通过 apt 安装任何 package 之前使用 apt 更新 - Docker container cant install any package by apt with apt update before
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM