简体   繁体   中英

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:

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. It can install pre-compiled packages for your distribution. It can do it for PHP-related packages as well. If you installed PHP using apt you can also install additional packages for it like that:

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.

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.

To sum it up: it all depends on how PHP was installed in your Docker image in the first place. If a package manager was used - then apt is the way to 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM