I've installed PHP:latest Docker container using the docker-compose command. It installed php-7.1.6-fpm in my Docker. When I tried to install php7-pgsql extension it failed to find that package, instead found pdo and pdo_pgsql packages. That will not satisfy my need. When I search for the available packages in the installed PHP container, I could not find any related pgsql packages for php7, instead, I saw php5-pgsql package, that will not work with php7-fpm.
Finally, I installed php-5.6-fpm container after removing the old one targeting to use php5-pgsql package. But now I disappointed again that I could not find php5-pgsql package in the newly installed container.
I know I'll be missing some important points. Whether Alpine Linux does not have php-pgsql extension. What are the possible ways to include this extension in my PHP container. I've also included Nginx and Postgres in my docker-compose.yml
I've only 3-day theory knowledge in Docker and first-day practical experience.
Thanks for reading.
I ran into the same issue when I was settings up a new project to use pgsql.
I am using php7, so you should be able to use it as well. On your Dockerfile ensure you're covering the following steps.
Ensure you have the dependencies installed:
RUN apt-get update && apt-get install -y libpq-dev
Configure the extension:
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
Install the extension:
RUN docker-php-ext-install pdo pdo_pgsql
This is an old question i know, but i ran into this today and believe the above solution has changed with php:7.4-fpm-alpine
So where it used to be:
RUN apt-get update && apt-get install -y libpq-dev
Should now be:
RUN apt-get update && apt-get install -y postgresql-dev
Hopefully this helps anyone that runs into the same issue.
Related
I'm trying to install pdo-mysql to PHP container
I tried to install it using command line as:
apt install pdo pdo_mysql
but the extension not installed and provide a lot of errors.
But When I use
docker-php-ext-install pdo pdo_mysql
The extension was installed successfully
So what is the difference between them, and when must use each of them?
apt is a softwar for Debian-like Linux distributions to manage packages. It can install pre-compiled packages for your distribution. It can do it for PHP-related packages as well. If you installed PHP using apt you can also install additional packages for it like that:
sudo apt install -y php-pdo-mysql
The exact package name will depend on the distribution you used and/or how you installed PHP in the first place.
The docker-php-ext-install is a special shell script in the official PHP Docker image where PHP was installed from the source. It will compile and install the necessary extensions.
Since you are using this Docker image docker-php-ext-install is the way to go.
To sum it up: it all depends on how PHP was installed in your Docker image in the first place. If a package manager was used - then apt is the way to go. If you use the official PHP Docker image it compiles PHP from the source code and provides a shortcut to compile additional extensions using docker-php-ext-install.
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 was trying to find any information about using Memcached with PHP7, but I failed. The only valuable information is short Readme.md of php-memcached repo.
Unfortunately, its travis build failed as well as 30/126 tests on my machine.
However make install command was successful and created memcached.so file. Does it mean I can use this extension in production or it still has bugs and is not recommended for using?
I will very appreciate any advice or working solution.
You need to use the php7 branch; see here, Travis is passing.
This should be the complete set of steps to install the memcached extension on a Debian/Ubuntu OS:
sudo apt-get update
sudo apt-get install -y libmemcached-dev libmemcached11 git build-essential
git clone https://github.com/php-memcached-dev/php-memcached
cd php-memcached
git checkout php7
git pull
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
make
sudo make install
You may need to change some of the paths if you have them installed at different locations.
To install memcached on the latest ubuntu for the latest php use:
sudo apt-get install php-memcached
For Debian 8 users, you can use:
sudo apt-get install php7.0-memcached
I came to this question via an issue with getting artisan to work in the Laravel Lumen framework.
I'm using PHP 7. PHP 7.0.15-0ubuntu0.16.04.4 to be precise.
I found the only solution was to install what appears to be the PHP 5 version* with memcached†:
sudo apt install memcached php-memcached
*
php-memcached/xenial,now 2.2.0-51-ge573a6e+2.2.0-2build2 amd64 [installed]
memcached extension module for PHP5, uses libmemcached
†If you find you then get the error: [RuntimeException] Could not establish Memcached connection., you need to install the memcached extension as the above sudo apt install memcached (if you're on 16.04+, use apt-get if < 16.04)