[英]Enable EXIF support when running Wordpress Docker container
I'm trying to run a Wordpress site inside the official Wordpress Docker container .我正在尝试在官方 Wordpress Docker 容器中运行 Wordpress 站点。
The Wordpress site that I've built relies on using exif_read_data
to extract meta information from photos.我建立的 Wordpress 站点依赖于使用exif_read_data
从照片中提取元信息。 I understand that PHP needs to be configured with the --with-exif
flag for this to work.我知道 PHP 需要配置--with-exif
标志才能工作。
This is the Configure Command section of <?php phpinfo() ?>
's output when I'm running my site from the Docker container: './configure' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--disable-cgi' '--enable-ftp' '--enable-mbstring' '--enable-mysqlnd' '--with-curl' '--with-libedit' '--with-openssl' '--with-zlib' '--with-apxs2' 'CFLAGS=-fstack-protector-strong '-fpic' '-fpie' '-O2'' 'LDFLAGS=-Wl,-O1 '-Wl,--hash-style=both' '-pie'' 'CPPFLAGS=-fstack-protector-strong '-fpic' '-fpie' '-O2''
这是当我从 Docker 容器运行我的站点时<?php phpinfo() ?>
的输出的配置命令部分: './configure' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--disable-cgi' '--enable-ftp' '--enable-mbstring' '--enable-mysqlnd' '--with-curl' '--with-libedit' '--with-openssl' '--with-zlib' '--with-apxs2' 'CFLAGS=-fstack-protector-strong '-fpic' '-fpie' '-O2'' 'LDFLAGS=-Wl,-O1 '-Wl,--hash-style=both' '-pie'' 'CPPFLAGS=-fstack-protector-strong '-fpic' '-fpie' '-O2''
How can I reconfigure PHP to have EXIF support enabled?如何重新配置 PHP 以启用 EXIF 支持? I'd like to keep using the official Wordpress Docker container because it seems to be working really well otherwise.我想继续使用官方的 Wordpress Docker 容器,因为否则它似乎工作得很好。
My docker-compose.yml
is here: https://github.com/quis/quis.cc/blob/d89efebefc20f688afbd70f8d7a58e35380581e9/docker-compose.yml我docker-compose.yml
在这里: https : //github.com/quis/quis.cc/blob/d89efebefc20f688afbd70f8d7a58e35380581e9/docker-compose.yml
OK, I figured it out.好的,我想通了。
EXIF support can be enabled by running the docker-php-ext-install exif
command.可以通过运行docker-php-ext-install exif
命令来启用 EXIF 支持。 This command only works when building the container.此命令仅在构建容器时有效。
I can't modify the official container;我无法修改官方容器; the Docker way to do this (which is the part I didn't understand) is to build my own container on top of the official one. Docker 执行此操作的方法(这是我不理解的部分)是在官方容器之上构建我自己的容器。 Then when I build my own container I can run the command to enable EXIF support.然后当我构建自己的容器时,我可以运行命令来启用 EXIF 支持。 Everything else is inherited from the official Wordpress container.其他一切都继承自官方的 Wordpress 容器。 So I made a file called Dockerfile
containing this:所以我制作了一个名为Dockerfile
的文件, Dockerfile
包含:
FROM wordpress:latest
RUN docker-php-ext-install exif
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["apache2-foreground"]
Then I ran this shell command to build an image from this file:然后我运行这个 shell 命令从这个文件构建一个图像:
docker build -t wordpress-exif .
Then it's just a case of pointing the Docker compose file at my custom container, rather than the generic one.那么这只是将 Docker compose 文件指向我的自定义容器而不是通用容器的一种情况。 So in docker-compose.yml
I changed image: wordpress:latest
to image: wordpress-exif
.所以在docker-compose.yml
我将image: wordpress:latest
更改为image: wordpress-exif
。
I tried installing and enabling exif like other answers, but not luck.我尝试像其他答案一样安装和启用 exif,但不是运气。
Finally, it worked by adding the package.最后,它通过添加包来工作。
RUN apk add --no-cache php7-exif
I used php:7.4-alpine
我用过php:7.4-alpine
If you are using PHP 7.2+ the exif extension may already be installed but disabled.如果您使用的是 PHP 7.2+,exif 扩展可能已经安装但被禁用。 Add this line to Dockerfile to enable it:将此行添加到 Dockerfile 以启用它:
RUN docker-php-ext-enable exif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.