Reputation: 1083
Can anyone help me with this problem.
When i try to create a docker image from a dockerfile for laravel application i get this error:
checking for oniguruma... no configure: error: Package requirements (oniguruma) were not met:
No package 'oniguruma' found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables ONIG_CFLAGS and ONIG_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.
The command '/bin/sh -c docker-php-ext-install pdo mbstring' returned a non-zero code: 1
Here is my Dockerfile:
FROM php:7
RUN apt-get update -y && apt-get install -y openssl zip unzip git
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo mbstring
WORKDIR /app
COPY app /app # this copies all the app files to a folder called `app`
RUN composer install
CMD php artisan serve --host=0.0.0.0 --port=8000
EXPOSE 8000
and the docker command to build the Dockerfile
sudo docker build -t test .
Upvotes: 107
Views: 101995
Reputation: 11
On AlmaLinux 9 (el9 base):
dnf --enablerepo=crb install oniguruma-devel
Where CRB is CodeReady Linux Builder repository contains additional packages for use by developers.
For related information, visit: oniguruma-devel-6.9.6-1.el9.5.i686.rpm - Description
Upvotes: 1
Reputation: 4884
On Centos 8:
$ yum install dnf-plugins-core
$ yum config-manager --set-enabled powertools
$ yum install oniguruma-devel
This will install the required oniguruma library and satisfies dependency.
Upvotes: 1
Reputation: 2208
For ALPINE-based images e.g. FROM php:8.0.24-fpm-alpine3.16
you have to add the package oniguruma-dev
like:
FROM php:8.0.24-fpm-alpine3.16
...
RUN apk update && apk add oniguruma-dev
...
RUN docker-php-ext-install -j$(nproc) mbstring
...
As @katalabe & @kgx already mentioned: mbstring requires any kind of oniguruma installed.
For Debian-based images please see @kgx answer above: https://stackoverflow.com/a/59373581/6852290
Upvotes: 8
Reputation: 4610
for phpbrew user
You can solve this error by removing the mbstring
variant from the installation command using -mbstring
parameter.
Example:
phpbrew install php-7.4 +default -mbstring
Upvotes: 1
Reputation: 1129
If your are using a distro with yum package manager. Execute this command:
sudo yum install -y oniguruma-devel
Upvotes: 2
Reputation: 2246
What @kalatabe said is correct. But in case you absolutely wanted to make sure mbstring gets installed, you can also add libonig-dev
to your apt-get install
Upvotes: 213
Reputation: 2989
Just remove mbstring
from the docker-php-ext-install
instruction.
The error is caused by a dependency problem - the mbstring
extension requires the oniguruma
library to make multibyte regular expression functions work. From the installation guide:
Oniguruma is necessary for the regular expression functions with multibyte character support. Oniguruma is bundled with mbstring. As of PHP 5.4.0, if Oniguruma is already installed on the system, --with-onig[=DIR] can be specified to use the installed library.
However, in the image that you're using, the extension is already installed and configured, so you don't need to do anything else:
$> docker run --rm -it php:7 php -r "var_dump(mb_ereg_match('^99.*', '123456'));"
bool(false)
$> docker run --rm -it php:7 php -r "var_dump(mb_ereg_match('^12.*', '123456'));"
bool(true)
Upvotes: 172