I want to install php-zip on my docker image (the end goal is to use the PhpWord Library). I use the php:7.4-fpm, which runs on Debian.
In my dockerfile, i use the command :
RUN apt-get update docker-php-ext-install zip
When executed, the script crashes because it can't find /usr/src/php/ext/libzip.
So i add a good old "apt-get install libzip", but it can't locate the package. Same thing if it try to install "libzip4" :
checking for libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0... no
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:
No package 'libzip' found
No package 'libzip' found
No package 'libzip' 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 LIBZIP_CFLAGS and LIBZIP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
ERROR: Service 'webapi' failed to build : The command '/bin/sh -c apt-get update && apt-get install libzip4 && docker-php-ext-install zip' returned a non-zero code: 1
I assume either libzip4 isn't a valid version or it can't make the link between libzip and libzip4.
The main issue is that, without that library, i'm stuck and can't install the extension at all. Also i'm quiet a rookie when it comes to docker so i call out your help !
Thanks for your time !
Ok, so the issue is that you have to guess that the package you need to install is called "libzip-dev", not just "libzip".
So the solution was :
RUN apt-get update \
&& apt-get install -y libzip-dev \
&& docker-php-ext-install zip
Related
I'm trying to install php-zip but I get a conflict error:
Problem: conflicting requests
- nothing provides libzip(x86-64) >= 1.8.0 needed by php-pecl-zip-1.19.5-1.fc34.remi.8.0.x86_64
- nothing provides libzip(x86-64) >= 1.8.0 needed by php-pecl-zip-1.20.0-1.fc34.remi.8.0.x86_64
This library is available in "remi" repository, which seems to not be enabled.
https://rpms.remirepo.net/fedora/34/remi/x86_64/repoview/libzip.html
No need pear package, just use the below command.
sometime need check os version then use compatible repo
$ dnf install libzip-dev libzip php-zip php-devel -y
$ php -m | grep zip
> zip
I'm writing some unit tests for our application and we're using GitLab CI with GitLab Runner v11.11.1 and using Docker executor with image php:7.1.
When running composer install (our composer version is 1.10.17) I get the following error on a few required packages:
the requested PHP extension gd is missing from your system
I've tried a couple things like on our gitlab-ci.yml:
apt-get update -yqq
apt-get install -yqq libpng-dev
But that also produced the same error.
I also tried requiring ext-gd from the composer.json file:
composer require ext-gd
But I got this error:
The requested PHP extension ext-gd ^7.1 is missing from your system. Install or enable PHP's gd extension.
The last attempt I made was:
apt-get install php-common
phpenmod gd
But this gave me this error:
Unable to locate package php-common
Does anyone know how to simply enable the PHP extension gd so I can run my unit tests?
I fixed the errors when I added this to my gitlab-ci.yml file:
...
before_script:
- apt-get update -yqq
- apt-get install libjpeg-dev libpng-dev -yqq
- docker-php-ext-install gd
...
You need PHP GD library. For Debian and Debian based systems, e.g. Ubuntu, as well as Debian based Docker containers use:
apt-get install -qy php-gd
If it's still unclear, or you have older/other system just search
apt-cache search php gd
and will find out possible package candidates.
For Docker containers it seems you need a different route, so Dockerfile:
FROM php:7.1-apache-buster
RUN apt-get update
RUN apt-get upgrade -qqy
RUN php -v
RUN apt-get install -qy libpng-dev
RUN docker-php-ext-install gd
I'm trying to install php on Centos 7 following instructions from: https://www.php.net/manual/en/install.unix.nginx.php.
My nginx version: nginx/1.19.0
I downloaded php-7.4.6.tar.gz from https://www.php.net/downloads
but
at the step:
./configure --enable-fpm --with-mysqli
I got this error:
checking for sqlite3 > 3.7.4... no
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
No package 'sqlite3' 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 SQLITE_CFLAGS
and SQLITE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
I do have sqlite3 up and running:
# sqlite3
SQLite version 3.7.17
So, how should I set the environment variable (in configure file?)?
Thanks!
To compile from source, dependencies need to be available as a linkable library (and sometimes headers which the new program uses for building). -devel packages install these libraries, so to build PHP from source with SQLite support, you need to install sqlite-devel.
If you have Ubuntu >= 20.04, install this package libsqlite3-dev to satisfy the dev dependency/package requirements.
sudo apt install libsqlite3-dev will work. To know which libraries to install you may find apt search sqlite3 useful.
for ubuntu21.04 I needed to use sudo apt install libsqlite3-dev
sudo apt-get install -y libbz2-dev sqlite3 libsqlite3-dev libssl-dev libcurl4-openssl-dev libjpeg-dev libonig-dev libreadline-dev libtidy-dev libxslt-dev libzip-dev
The command sudo apt-get install sqlite3 works for ubuntu.
On Ubuntu 22.04 I had the same problem after installing :-
sudo apt-get install sqlite3 libsqlite3-dev
To get round this :-
sudo find / -name sqlite3.pc
Then add the folder that contains that file to :-
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig/
I am having problems installing yaml support on my php docker configuraiton.
Here is my dockerbuild file:
FROM php:7.2.2-apache
RUN docker-php-ext-install mysqli
# Install YAML extension
RUN pecl install yaml && echo "extension=yaml.so" > /usr/local/etc/php/conf.d/ext-yaml.ini && docker-php-ext-enable yaml
But I am getting error:
configure: error: Please install libyaml
I googled, but haven`t found working solution yet. Any ideas how should I do it?
Note:
RUN apt-get install libyaml
Havent worked, got message E: Unable to locate package libyaml
And also this command havent worked:
yum install libyaml-devel
error: yum install libyaml-devel
First you need to run the update and then install the required package that is libyaml-dev.
FROM php:7.2.2-apache
RUN docker-php-ext-install mysqli
# Install YAML extension
RUN apt-get update -y
RUN apt-get install libyaml-dev -y
RUN pecl install yaml && echo "extension=yaml.so" > /usr/local/etc/php/conf.d/ext-yaml.ini && docker-php-ext-enable yaml
How do I install the yaml package for Python?
I found also different way, maybe for someone easier because adding php extension is really simple.
https://github.com/mlocati/docker-php-extension-installer
And here is my final Dockerfile
FROM php:7.2.2-apache
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions mysqli yaml
I am trying to install memcached in Dockerfile but I keep getting th same error. Everything was working fine but looks like some layers were cached I and the images was being built with no problems at all. But since I cleared the cache I can't build the image. Here is some of it's content:
FROM php:5-apache
RUN apt-get install -y libmemcached11 libmemcachedutil2 build-essential libmemcached-dev libz-dev
RUN pecl install memcached
RUN echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini
There are many other things that are installed but as I said everything was working before. The error is that memcached requires php7 to run. I dont know if something has changed in the recent builds of the library but looks like it refuses to work with php5. Here is the error:
pecl/memcached requires PHP (version >= 7.0.0), installed version is 5.6.30
pecl/memcached can optionally use PHP extension "igbinary" (version >= 2.0)
pecl/memcached can optionally use PHP extension "msgpack" (version >= 2.0)
No valid packages found
install failed
The command '/bin/sh -c pecl install memcached' returned a non-zero code: 1
The PECL memcached package introduced the dependency on PHP 7 in version 3.0.0. You can still install the 2.x version of that package:
FROM php:5-apache
RUN apt-get update && apt-get install -y libmemcached11 libmemcachedutil2 build-essential libmemcached-dev libz-dev
RUN pecl install memcached-2.2.0
RUN echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini