Dockerfile 中 配置安裝 php 擴展


添加redis擴展

源碼安裝方式

ARG INSTALL_PHPREDIS=true
ARG PHPREDIS_VERSION=3.1.3
RUN if [ ${INSTALL_PHPREDIS} = true ]; then \
# Install Php Redis Extension
curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/${PHPREDIS_VERSION}.tar.gz \
&& tar xfz /tmp/redis.tar.gz \
&& rm -r /tmp/redis.tar.gz \
&& mkdir -p /usr/src/php/ext \
&& mv phpredis-${PHPREDIS_VERSION} /usr/src/php/ext/redis \
&& docker-php-ext-install redis \
&& rm -rf /usr/src/php \
;fi

PECL安裝方式

ARG INSTALL_PHPREDIS=false
RUN if [ ${INSTALL_PHPREDIS} = true ]; then \
# Install Php Redis Extension
printf "\n" | pecl install -o -f redis \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis \
;fi

注:

源碼安裝方式的可以選擇版本,PECL安裝的記得注意php版本,因為默認會安裝最新的版本

swoole擴展安裝

#####################################
# Swoole EXTENSION FOR PHP 5
#####################################

ARG INSTALL_SWOOLE=false
ARG PHPSWOOLE_VERSION=1.9.23
RUN if [ ${INSTALL_SWOOLE} = true ]; then \
# Install Php Redis Extension
curl -L -o /tmp/swoole.tar https://pecl.php.net/get/swoole-${PHPSWOOLE_VERSION}.tar \
&& tar xvf /tmp/swoole.tar \
&& rm -r /tmp/swoole.tar \
&& mkdir -p /usr/src/php/ext \
&& mv swoole-${PHPSWOOLE_VERSION} /usr/src/php/ext/swoole \
&& docker-php-ext-install swoole \
&& rm -rf /usr/src/php \
;fi


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM