I've getting started with Docker, using the LAMP repo from GitHub as my starting point. I need to add the libxslt lib. I've tried adding this to my Dockerfile:
RUN apt-get install libxslt-dev
RUN docker-php-ext-enable libxslt-dev
But keep getting error: E: Unable to locate package libxslt-dev
I've tried to search for the lib from the Docker container's command line apt-cache search libxslt but get no results.
Can anybody point me in the right direction to get this lib installed?
Thanks
Followed answer below (#vpalmerini) updating Dockerfile:
RUN apt update && apt-get install -y libxslt-dev
RUN docker-php-ext-enable libxslt-dev
Which I thought was working:
Step 9/13 : RUN apt update && apt-get install -y libxslt-dev
[...]
The following additional packages will be installed:
libxslt1.1
The following NEW packages will be installed:
libxslt1-dev libxslt1.1
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 756 kB of archives.
After this operation, 3001 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 libxslt1.1 amd64 1.1.32-2.2~deb10u1 [237 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 libxslt1-dev amd64 1.1.32-2.2~deb10u1 [519 kB]
Fetched 756 kB in 0s (4903 kB/s)
Selecting previously unselected package libxslt1.1:amd64.
(Reading database ... 21271 files and directories currently installed.)
Preparing to unpack .../libxslt1.1_1.1.32-2.2~deb10u1_amd64.deb ...
Unpacking libxslt1.1:amd64 (1.1.32-2.2~deb10u1) ...
Selecting previously unselected package libxslt1-dev:amd64.
Preparing to unpack .../libxslt1-dev_1.1.32-2.2~deb10u1_amd64.deb ...
Unpacking libxslt1-dev:amd64 (1.1.32-2.2~deb10u1) ...
Setting up libxslt1.1:amd64 (1.1.32-2.2~deb10u1) ...
Setting up libxslt1-dev:amd64 (1.1.32-2.2~deb10u1) ...
Processing triggers for libc-bin (2.28-10) ...
Removing intermediate container b62504aca3f9
---> b62b7af34467
Step 10/13 : RUN docker-php-ext-enable libxslt-dev
---> Running in 181191c74fe5
error: 'libxslt-dev' does not exist
Also tried changing RUN command to match package found: libxslt1-dev
RUN docker-php-ext-enable libxslt1-dev
Still unable to enable libxslt
Further info, output from:
dpkg --get-selections
includes:
libxml2-dev:amd64 install
libxrender-dev:amd64 install
libxrender1:amd64 install
libxslt1-dev:amd64 install
libxslt1.1:amd64 install
libxt-dev:amd64 install
But running RUN docker-php-ext-enable libxslt1-dev still gives
error: 'libxslt1-dev' does not exist
You are confusing the php extension called xsl with the system development package for libxslt (present on your base image Debian Linux distribution with the specific name libxslt1-dev) which is required to install that php extension.
Here is a basic Dockerfile to achieve your requirement. Note that, as a good practice, I made the install in a single run instruction with some extra cleanup at the end.
The apt-get remove line is optional but will reduce the layer size a bit more. Installing libxslt1-dev and all its dependencies (icu-devtools, libicu-dev, libicu63, libxml2, libxml2-dev, libxslt1.1) is mandatory for installing the extension. But once it is done, the dev packages can be removed.
FROM php:7.4.2-apache-buster
RUN apt-get update && \
apt-get install -y libxslt1-dev && \
docker-php-ext-install xsl && \
apt-get remove -y libxslt1-dev icu-devtools libicu-dev libxml2-dev && \
rm -rf /var/lib/apt/lists/*
The only thing missing is that you have to update the packages of your image, then you will be able to install libxslt-dev package:
RUN apt update && apt-get install -y libxslt-dev
Related
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/
How'd I enable a PHP module in official php:php-fpm docker image? Cannot install php-zip for instance:
root#122f1612f817:/var/www/html# apt-cache policy php-zip
php-zip:
Installed: (none)
Candidate: (none)
Version table:
2:7.3+69 -1
500 http://deb.debian.org/debian buster/main amd64 Packages
root#122f1612f817:/var/www/html# apt-get install php-zip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php-zip is a virtual package provided by:
php7.3-zip 7.3.4-2 [Not candidate version]
E: Package 'php-zip' has no installation candidate
You can install it as a PHP extension as it seems from the logs it not available in the repo.
FROM php:7.2-fpm
RUN apt-get update
RUN apt-get install libzip-dev -y
RUN docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip
add line to Dockerfile
RUN apt-get install php-zip -y
php-zip for PHP >= 7.3
RUN apt-get install -y \
libzip-dev \
zip \
&& docker-php-ext-install zip
I am trying to install php7.2-ldap in Laradock and I've set
WORKSPACE_INSTALL_LDAP=true
and
PHP_FPM_INSTALL_LDAP=true
and then tries to build the image like
docker-compose build workspace
And I get this error message. Part of the log
The following NEW packages will be installed:
php7.2-ldap
0 upgraded, 1 newly installed, 0 to remove and 28 not upgraded.
Need to get 23.1 kB of archives.
After this operation, 101 kB of additional disk space will be used.
Err:1 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 php7.2-ldap amd64 7.2.4-1+ubuntu16.04.1+deb.sury.org+1
404 Not Found
E: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/pool/main/p/php7.2/php7.2-ldap_7.2.4-1+ubuntu16.04.1+deb.sury.org+1_amd64.deb 404 Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
ERROR: Service 'workspace' failed to build: The command '/bin/sh -c if [ ${INSTALL_LDAP} = true ]; then apt-get install -y libldap2-dev && apt-get install -y php${PHP_VERSION}-ldap ;fi' returned a non-zero code: 100
What's happening here and why can't I install this?
I am answering my own question.
This was fixed by adding
apt-get update -yqq && \
before
apt-get install -y libldap2-dev && \
in workspace/Dockerfile and php-fpm\Dockerfile.
A complete block will look like this:
File: workspace\Dockerfile
###########################################################################
# LDAP:
###########################################################################
ARG INSTALL_LDAP=false
ARG PHP_VERSION=${PHP_VERSION}
RUN if [ ${INSTALL_LDAP} = true ]; then \
apt-get update -yqq && \
apt-get install -y libldap2-dev && \
apt-get install -y php${PHP_VERSION}-ldap \
;fi
Why did this happen?
A quote from Github issue:
What appears to be happening here is that there are a few apt-get
install commands for several packages are called while the local
package repo is out of sync with the remote. In an interactive
environment, this would be seen by the user and an appropriate apt-get
update would be run. However, the Dockerfile does not contain any
package repo update commands, as such the current layer has a
different package repo list than the remote. This is in general the
"problem" with dockers layers as they will be re-used if their command
didn't change (something I, too, had to learn the hard way).
By: Philipp Tempel
I have been unable to get soap to work with my php Docker setup.
I am using Docker CE for Windows Version 18.03.1-ce-win65 (17513). PHP version 7.2.3
I've tried running from inside the container apt-get install php-soap which results in
Reading package lists... Done
Building dependency tree
Reading state information... Done*
Package php-soap is a virtual package provided by:
* php7.0-soap 7.0.27-0+deb9u1 [Not candidate version]*
E: Package 'php-soap' has no installation candidate
Running docker-php-ext-install soap
results in the error configure: error: libxml2 not found. Please check your libxml2 installation.
However when looking at php info I see the following:
libxml2 Version => 2.9.4
You will need to install libxml2-dev as part of your dockerfile, the image is kept to a minimum and doesn't include all of the bits needed by every module. Although the image may have the main package, the -dev package includes the components needed to compile other modules which rely on it...
RUN apt-get update && \
apt-get install -y libxml2-dev
(From https://github.com/docker-library/php/issues/315)
Just to make it clear - the command
RUN docker-php-ext-install soap
will then run successfully to install the soap library.
For me, working with PHP 7.3.2, the other solutions didn't work.
Both "php-soap" and "php7.3-soap" got "phpXXX-soap has no installation candidate" error.
Alone "docker-php-ext-install soap" wanted the "libxml2-dev" so i just installed the necessities:
FROM php:7.3
RUN apt-get update -y \
&& apt-get install -y \
libxml2-dev \
&& apt-get clean -y \
&& docker-php-ext-install soap
... and it worked nicely.
The correct answer was done, but for me, I needed also to enable (docker-php-ext-enable soap) the soap module, so for If someone could be useful:
FROM php:7.4.24-apache
# your configurations ...
RUN apt-get update && \
apt-get install -y libxml2-dev
RUN docker-php-ext-install soap && docker-php-ext-enable soap
# other configurations ...
This is outside the scope of this repo.
You should get it via this approach:
RUN apt-get update -y \
&& apt-get install -y \
libxml2-dev \
php-soap \
&& apt-get clean -y \
&& docker-php-ext-install soap
I'm building pdo_firebird extension with php5 and firebird pdo on ubuntu / debian tutorial on server provisioning.
Tutorial recommends installing a bunch of extensions:
sudo apt-get install php5-dev firebird2.5-dev php-pear devscripts debget
I've checked Building extensions using phpize and other chapters from PHP Internals Book, but found nothing.
Is it safe to remove installed packages? What is a best practice?
apt-get -y remove --purge php5-dev firebird2.5-dev php-pear devscripts debget
apt-get autoremove -y
It is safe to remove *-dev packages after building is done.
But only the *-dev packages, but removing the *-dev packages will also remove any packages automatically installed with the *-dev packages as dependencies.
E. g. libmcrypt-dev also installs libmcrypt4
sudo apt-get -y install libmcrypt-dev
# run your build commands here ...
sudo apt-get -y purge libmcrypt-dev
will result in:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/mcrypt.so' - libmcrypt.so.4: cannot open shared object file: No such file or directory in Unknown on line 0
So you need to ensure your library packages are installed separate:
sudo apt-get -y install libmcrypt-dev libmcrypt4
# run your build commands here ...
sudo apt-get -y purge libmcrypt-dev
One should generally not have any problems while removing packages as they generally follow the trend they are used to while installing them even when compiling from source.
Although removing specific packages only causes trouble when these are dependent on other packages and vice versa to function correctly (it may show this warning too if there exists any such conflict) hence use autoremove that's it.
To avoid these confusions ,later install all packages separately and not what is bundled with them.