Hướng dẫn docker-php-ext-configure gd php 8 - docker-php-ext-configure gd php 8
FROM php:7.2-cli COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ RUN install-php-extensions gd xdebug1 Show
Hãy cho tôi biết nếu bạn nhận được bất kỳ lỗi nào. FROM php:7.2-cli COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ RUN install-php-extensions gd xdebug2 Cho những người bảo trì Nó sẽ hoạt động tốt. Tôi giả định rằng Apache đang sử dụng cổng tiêu chuẩn (80) - có thể bạn cần điều chỉnh điều đó. Nếu bạn có các dịch vụ/container khác nghe trên cổng 80, bạn có thể khiến container của mình nghe trên cổng khác: Bạn có muốn thực sự nói lời cảm ơn? Cho những người bảo trì Cho những người bảo trì Cho những người bảo trì Dễ dàng cài đặt các phần mở rộng PHP trong hình ảnh Php Docker chính thứcKho lưu trữ này chứa một tập lệnh có thể được sử dụng để dễ dàng cài đặt tiện ích mở rộng PHP bên trong các hình ảnh Php Docker chính thức. Tập lệnh sẽ cài đặt tất cả các gói APT/APK cần thiết; Vào cuối quá trình thực thi tập lệnh, các gói không cần thiết sẽ bị xóa để hình ảnh sẽ nhỏ hơn nhiều. Hình ảnh docker được hỗ trợ là tất cả các phiên bản Alpine/Debian, ngoại trừ Php 5.5 trong đó chúng tôi chỉ hỗ trợ Debian 8 (Jessie) (nghĩa là, docker pull mlocati/php-extension-installer0, docker pull mlocati/php-extension-installer1, docker pull mlocati/php-extension-installer2, docker pull mlocati/php-extension-installer3, docker pull mlocati/php-extension-installer4). Xem thêm các ghi chú trong phần yêu cầu đặc biệt. Cách sử dụngBạn có hai cách để sử dụng tập lệnh này trong các docker pull mlocati/php-extension-installer5 của mình: bạn có thể tải xuống tập lệnh một cách nhanh chóng hoặc bạn có thể lấy nó từ hình ảnh Docker Hub docker pull mlocati/php-extension-installer6. Với phương pháp đầu tiên, bạn chắc chắn bạn sẽ luôn nhận được phiên bản mới nhất của tập lệnh, với phương thức thứ hai, quá trình này nhanh hơn vì bạn sẽ sử dụng hình ảnh cục bộ. Ví dụ: ở đây một số docker pull mlocati/php-extension-installer5 cài đặt tiện ích mở rộng GD và XDEBUG PHP: Tải xuống kịch bảnVới DockerfileFROM php:7.2-cli ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ RUN chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug Với CurlFROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug Sao chép tập lệnh từ hình ảnh dockerFROM php:7.2-cli COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ RUN install-php-extensions gd xdebug
Cài đặt các phiên bản cụ thể của một tiện ích mở rộngĐơn giản chỉ cần nối install-php-extensions xdebug-2.9.70 vào tên mô -đun. Ví dụ: install-php-extensions xdebug-2.9.7 Kịch bản cũng hỗ trợ giải quyết các phiên bản tương thích bằng cách tiền tố phiên bản với một chăm sóc ( install-php-extensions xdebug-2.9.71). Ví dụ: # Install the most recent xdebug 2.x version (for example 2.9.8) install-php-extensions xdebug-^2 # Install the most recent xdebug 2.8.x version (for example 2.8.1) install-php-extensions xdebug-^2.8 Các phần mở rộng phiên bản trước khi phát hành có sẵn trên install-php-extensions xdebug-2.9.72 có thể được thiết lập bằng cách hậu tố tên của tiện ích mở rộng với trạng thái của nó, tức là install-php-extensions xdebug-2.9.73, install-php-extensions xdebug-2.9.74, install-php-extensions xdebug-2.9.75, install-php-extensions xdebug-2.9.76, install-php-extensions xdebug-2.9.77 hoặc install-php-extensions xdebug-2.9.78. Ví dụ: install-php-extensions xdebug-beta Mẹo: Khi phiên bản mới nhất có sẵn trên install-php-extensions xdebug-2.9.72 không ổn định và bạn muốn giữ phiên bản ổn định cuối cùng, hãy buộc nó bằng cách hậu tố tên tiện ích mở rộng với trạng thái # Install the most recent xdebug 2.x version (for example 2.9.8) install-php-extensions xdebug-^2 # Install the most recent xdebug 2.8.x version (for example 2.8.1) install-php-extensions xdebug-^2.80. Ví dụ: install-php-extensions mongodb-stable Cài đặt từ mã nguồnBạn cũng có thể cài đặt các tiện ích mở rộng PHP từ mã nguồn (miễn là nó đi kèm với tệp # Install the most recent xdebug 2.x version (for example 2.9.8) install-php-extensions xdebug-^2 # Install the most recent xdebug 2.8.x version (for example 2.8.1) install-php-extensions xdebug-^2.81 hoặc # Install the most recent xdebug 2.x version (for example 2.9.8) install-php-extensions xdebug-^2 # Install the most recent xdebug 2.8.x version (for example 2.8.1) install-php-extensions xdebug-^2.82). Các định dạng được chấp nhận là:
Cài đặt trình soạn thảoBạn cũng có thể cài đặt trình soạn thảo và bạn cũng có thể chỉ định một phiên bản chính của nó hoặc phiên bản đầy đủ. Examples: FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug1 Vấn đề với Giấy chứng nhận Let's EncryptGiấy chứng nhận CA gốc của Let Encrypt thay đổi (chi tiết hơn ở đây). Điều đó phá vỡ các bản phân phối Linux cũ, cụ thể là:
Tập lệnh này có thể khắc phục vấn đề này: Chỉ cần chuyển # Install the most recent xdebug 2.x version (for example 2.9.8) install-php-extensions xdebug-^2 # Install the most recent xdebug 2.8.x version (for example 2.8.1) install-php-extensions xdebug-^2.83 như một đối số: FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug2 Hỗ trợ các phần mở rộng PHP
zstd Số lượng tiện ích mở rộng được hỗ trợ: 127 FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug3 PS: Các tiện ích mở rộng PHP được cài đặt sẵn được loại trừ khỏi danh sách này. Bạn có thể liệt kê chúng bằng lệnh sau (thay đổi # Install the most recent xdebug 2.x version (for example 2.9.8) install-php-extensions xdebug-^2 # Install the most recent xdebug 2.8.x version (for example 2.8.1) install-php-extensions xdebug-^2.84 để phản ánh phiên bản PHP mà bạn quan tâm):Cấu hình Bạn có thể định cấu hình hành vi của tập lệnh, cũng như tinh chỉnh một số tiện ích mở rộng để phù hợp với nhu cầu của bạn, bằng cách sử dụng các biến môi trường. FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug4 Đây là một ví dụ:
RaphfRdkafka
tenxơ• Không có sẵn trong hình ảnh docker # Install from a specific commit (full commit SHA-1) install-php-extensions php-memcached-dev/[email protected] # Install from a specific commit (short commit SHA-1) install-php-extensions php-memcached-dev/[email protected] # Install from tag v3.2.0RC2 install-php-extensions php-memcached-dev/ install-php-extensions php-memcached-dev/[email protected]/tags/v3.2.0RC2 # Install from branch master install-php-extensions php-memcached-dev/[email protected] install-php-extensions php-memcached-dev/[email protected]/heads/master6 • Không có sẵn trong hình ảnh docker ____98 VIP
Bạn có thể chạy lệnh này:Ví dụ: Dành cho Debian 11 (Bullseye) Bạn sẽ thấy: FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug5 In case of failure, a message is sent to a Telegram Channel. Feel free to subscribe to it to receive failure notifications. Đối với Alpine Linux 3.14, bạn sẽ thấy: FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug6Xét nghiệmKhi gửi yêu cầu kéo, hành động GitHub được thực hiện để kiểm tra xem các tiện ích mở rộng PHP bị ảnh hưởng có thực sự hoạt động không (xem bên dưới). Hơn nữa, chúng tôi cũng kiểm tra xem các phiên bản mở rộng mới trong kho PECL vẫn sẽ hoạt động. Điều này được thực hiện trên cơ sở theo lịch trình với một hành động GitHub khác. Trong trường hợp thất bại, một tin nhắn được gửi đến một kênh điện báo. Hãy đăng ký nó để nhận thông báo thất bại. Làm thế nào để đóng góp FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug7 Định dạng mã Trước khi gửi bất kỳ yêu cầu kéo nào, bạn nên thực thi tập lệnh FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug03 trong thư mục FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug04 (hoặc FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug05 trên Windows).
Thêm hỗ trợ cho một tiện ích mở rộng PHP mới? Thay đổi tập lệnh install-php-extensions xdebug-beta0
Thêm hỗ trợ cho một tiện ích mở rộng PHP mới? Thay đổi tập lệnh install-php-extensions xdebug-beta0Cập nhật tệp FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug12, thêm một dòng mới với tay cầm của tiện ích mở rộng và danh sách các phiên bản PHP được hỗ trợ Nếu tiện ích mở rộng yêu cầu hình ảnh ZTS: Thêm một dòng mới vào tệp FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug13, với tay cầm tiện ích mở rộng theo sau là không gian và # Install from a specific commit (full commit SHA-1) install-php-extensions php-memcached-dev/[email protected] # Install from a specific commit (short commit SHA-1) install-php-extensions php-memcached-dev/[email protected] # Install from tag v3.2.0RC2 install-php-extensions php-memcached-dev/ install-php-extensions php-memcached-dev/[email protected]/tags/v3.2.0RC2 # Install from branch master install-php-extensions php-memcached-dev/[email protected] install-php-extensions php-memcached-dev/[email protected]/heads/master7 FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug8 Xem yêu cầu kéo này cho một ví dụ. FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug9 Thay đổi các phiên bản PHP được hỗ trợ cho tiện ích mở rộng PHP đã được hỗ trợ? FROM php:7.2-cli COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ RUN install-php-extensions gd xdebug0 Thêm hỗ trợ cho một tiện ích mở rộng PHP mới? Thay đổi tập lệnh install-php-extensions xdebug-beta0Cập nhật tệp FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug12, thêm một dòng mới với tay cầm của tiện ích mở rộng và danh sách các phiên bản PHP được hỗ trợ Nếu tiện ích mở rộng yêu cầu hình ảnh ZTS: Thêm một dòng mới vào tệp FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug13, với tay cầm tiện ích mở rộng theo sau là không gian và # Install from a specific commit (full commit SHA-1) install-php-extensions php-memcached-dev/[email protected] # Install from a specific commit (short commit SHA-1) install-php-extensions php-memcached-dev/[email protected] # Install from tag v3.2.0RC2 install-php-extensions php-memcached-dev/ install-php-extensions php-memcached-dev/[email protected]/tags/v3.2.0RC2 # Install from branch master install-php-extensions php-memcached-dev/[email protected] install-php-extensions php-memcached-dev/[email protected]/heads/master7 Xem yêu cầu kéo này cho một ví dụ.Thay đổi các phiên bản PHP được hỗ trợ cho tiện ích mở rộng PHP đã được hỗ trợ? Cập nhật tệp FROM php:7.2-cli RUN curl -sSLf \ -o /usr/local/bin/install-php-extensions \ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions gd xdebug12, thêm phiên bản PHP mới vào dòng hiện có tương ứng với tiện ích mở rộng được cập nhậtCải thiện mã cho một tiện ích mở rộng đã được hỗ trợ? Trước khi bạn có thể bắt đầu tạo hình ảnh với PHP, bạn cần kiểm tra xem bạn có thực sự có khả năng tạo hình ảnh trong cài đặt PHP của mình không.Trong chương này, chúng tôi sẽ thảo luận bằng cách sử dụng tiện ích mở rộng GD, cho phép PHP sử dụng thư viện đồ họa GD nguồn mở có sẵn từ http://www.boutell.com/gd/.allows PHP to use the open source GD graphics library available from http://www.boutell.com/gd/. Docker là tiêu chuẩn công nghiệp để chạy các ứng dụng container.Bằng cách sử dụng container Docker, bạn có thể tạo một cài đặt PHP nhất quán có thể chạy cục bộ hoặc từ xa mà không cần cài đặt nó trên hệ điều hành cơ bản.By using a docker container you can create a consistent install of PHP that can be run locally or remotely without needing to install it on the underlying operating system. Docker-php-ext-enable Lệnh này được sử dụng để bắt đầu phần mở rộng PHP khi chúng tôi sử dụng PECL để cài đặt tiện ích mở rộng PHP, phần mở rộng không được bắt đầu theo mặc định.Nếu bạn muốn sử dụng tiện ích mở rộng này, bạn phải định cấu hình nó trong PHP.Tệp cấu hình INI để sử dụng tiện ích mở rộng PHP này.This command is used to start PHP extension of When we use pecl to install the PHP extension, the extension is not started by default. If you want to use this extension, you must configure it in the php. ini configuration file to use this PHP extension. |