Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

russellxu's avatar

How to install intl extension of php8 on docker?

so,here is my dockerfile

FROM php:8.1.3-apache

ENV APACHE_DOCUMENT_ROOT /var/www/html/public

RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/ [star symbol].conf 


RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/[star symbol].conf  


RUN apt-get clean
RUN apt-get update && apt-get install -y \
        zlib1g-dev libicu-dev g++ \
        libjpeg62-turbo-dev \
        libzip-dev \
        libpng-dev \
        libwebp-dev \
        libfreetype6-dev \
    	libxml2-dev \
    	git \
    	zip \
    	unzip \
    && docker-php-ext-install pdo_mysql \
    && docker-php-ext-configure gd --with-webp=/usr/include/webp --with-jpeg=/usr/include --with-freetype=/usr/include/freetype2/ \
    && docker-php-ext-install -j$(nproc) gd \
    && docker-php-ext-install -j$(nproc) zip \
    && docker-php-ext-configure intl \
    && docker-php-ext-install intl


    
RUN pecl install -o -f redis \
    && rm -rf /tmp/pear \ 
    && docker-php-ext-enable redis
RUN pecl install xdebug \
    && docker-php-ext-enable xdebug
RUN curl -sS https://getcomposer.org/installer | php \
    && mv composer.phar /usr/local/bin/composer \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
RUN a2enmod rewrite
RUN a2enmod expires

#RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
#RUN apt-get install -y nodejs

so,the zlib1g-dev libicu-dev g++ \ and && docker-php-ext-configure intl \ && docker-php-ext-install intl is what I googled and pasted in.. It didn't work. anyone knows how to install it?

1 like
5 replies
Sinnbeck's avatar

Did you rebuild after the change? For every change you need to rebuild and restart the container

Sinnbeck's avatar

@russellxu and you saw it build the intl part? It shows exactly what it does

Be aware if there is any error, it rolls back

shmolf's avatar

First of all, thank you for posting this build file. I've been building my app using different containers, which doesn't work if you want to publish an app image.

  1. For Composer, I use this trick (from their docs - hub.docker.com/_/composer) to copy from the official composer container:
COPY --from=composer:2.1.3 /usr/bin/composer /usr/bin/composer

With regard to internationalization, what seems to have worked for me is

RUN apt-get update && apt-get install -y \
    libicu-dev \
    libonig-dev \
    libzip-dev \
    zip \
    unzip \
    git \
    && docker-php-ext-configure intl \
    && docker-php-ext-install intl \
    && docker-php-ext-install mbstring \
    && docker-php-ext-install zip
RUN docker-php-ext-enable intl mbstring zip

You may not need zip, and you may need other libraries that I don't. (Untested) But I think the relevant pieces are

RUN apt-get update && apt-get install -y \
    libicu-dev \
    libonig-dev \
    && docker-php-ext-configure intl \
    && docker-php-ext-install intl \
    && docker-php-ext-install mbstring
RUN docker-php-ext-enable intl mbstring
1 like

Please or to participate in this conversation.