Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install pdo_psql with docker-php-ext-install #221

Closed
zot24 opened this issue Apr 13, 2016 · 15 comments
Closed

Can't install pdo_psql with docker-php-ext-install #221

zot24 opened this issue Apr 13, 2016 · 15 comments

Comments

@zot24
Copy link

zot24 commented Apr 13, 2016

I was trying to install pdo_psql on fpm-alpine flavour like:

docker-php-ext-install pdo pdo_pgsql

I was getting first the following error:

configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

So I decide to install libpq:

RUN echo "@edge http://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
RUN apk --no-cache add \
    libpq@edge

Same error after that and then I try installing postgresql like:

RUN echo "@edge http://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
RUN apk --no-cache add \
    postgresql \
    libpq@edge

And then getting different error:

configure: error: Unable to build the PDO PostgreSQL driver: a newer libpq is required

That's why I'm trying with the edge version of libpq but...

And I'm get stuck in this step not sure what could be wrong but I can't install pdo_pgsql

btw my infrastructure it's have one container per thing, so I have a container for nginx and a container for php-fpm and another container with postgres so my goal it's have everything split between containers

@zot24
Copy link
Author

zot24 commented Apr 14, 2016

Could this issue be related with the C libraries on Alpine? I have notice you are using g++ and gcc

@zot24
Copy link
Author

zot24 commented Apr 14, 2016

Ok! fix my issue! :)

It's kind of related with this https://bugs.alpinelinux.org/issues/3642 and this https://bugs.alpinelinux.org/issues/4109

And what I did to fix it was install first postgresql-dev like so:

FROM php:fpm-alpine

RUN set -ex \
  && apk --no-cache add \
    postgresql-dev

RUN docker-php-ext-install pdo pdo_pgsql

And that works! :) the links suggest that we should have a small package to satisfy that dependency and be able to install the pdo_psql

@zot24 zot24 closed this as completed Apr 14, 2016
@Aliance
Copy link

Aliance commented Oct 17, 2016

The same issue but on php:5.6-fpm, not alpine.

FROM php:5.6-fpm

RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
    && docker-php-ext-install pgsql pdo_pgsql

configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path


The solution as above is:

FROM php:5.6-fpm

RUN apt-get update

# Install Postgre PDO
RUN apt-get install -y libpq-dev \
    && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
    && docker-php-ext-install pdo pdo_pgsql pgsql

@isuftin
Copy link

isuftin commented May 3, 2017

@Aliance This also fixes the issue for php:apache 👍

9034725985 added a commit to openroom/phpci that referenced this issue Aug 18, 2017
set -ex \
      && apk --no-cache add \
        postgresql-dev

        docker-library/php#221
zdenekdrahos added a commit to costlocker/integrations that referenced this issue Aug 31, 2017
https://hub.docker.com/_/php/
docker-library/php#221

https://stackoverflow.com/a/39501539
docker-compose -f docker-compose.yml up --build -d queue_daemon
docker logs basecamp-costlocker-queue -f
furkle pushed a commit to furkle/twinepm-server-heroku that referenced this issue Sep 16, 2017
@robov
Copy link

robov commented Dec 4, 2017

I am facing the same issue, but when I follow zot24 advice... the pdo is installed and seems to work BUT
when I then run psql in the shell I get

Error relocating /usr/bin/psql: PQresultVerboseErrorMessage: symbol not found
Error relocating /usr/bin/psql: PQsetErrorContextVisibility: symbol not found
Error relocating /usr/bin/psql: PQencryptPasswordConn: symbol not found

Any suggestions

@robov
Copy link

robov commented Dec 4, 2017

Basically when I add postgresql-dev to my current installation pf postgresql (10.1) then I no longer can use psql command... drives me nuts

@robov
Copy link

robov commented Dec 4, 2017

I now solved it like this:

#... install postgres pdo
set -ex \
  && apk --no-cache add \
    postgresql-dev

docker-php-ext-install pdo pdo_pgsql
apk del postgresql-dev
apk add --upgrade postgresql --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/main/

@inta
Copy link

inta commented May 1, 2018

I got stuck on the same problem and your comments did help me to get it running, but you do not need to install the complete postgres package, postgres-libs is sufficient (pdo is already installed, but I needed to install the pgsql extension):

RUN set -ex \
	&& apk --no-cache add postgresql-libs postgresql-dev \
	&& docker-php-ext-install pgsql pdo_pgsql \
	&& apk del postgresql-dev

@acodercat
Copy link

apt-get install libpq-dev

@stevleibelt
Copy link

Thanks @acodercat ,
your solution is still "doing the trick" if you are using the docker container "php:7.1-cli".

apt-get install libpq-dev
&& docker-php-ext-install pdo_pgsql

@tianon
Copy link
Member

tianon commented Nov 6, 2018 via email

@PedroDiSanti
Copy link

The same issue but on php:5.6-fpm, not alpine.

FROM php:5.6-fpm

RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
    && docker-php-ext-install pgsql pdo_pgsql

configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

The solution as above is:

FROM php:5.6-fpm

RUN apt-get update

# Install Postgre PDO
RUN apt-get install -y libpq-dev \
    && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
    && docker-php-ext-install pdo pdo_pgsql pgsql

Thank you so much, mate.

paxcodes pushed a commit to paxcodes/topanswers that referenced this issue Feb 27, 2020
Without lines 6-8, I get an error
`configure: error: Cannot find libpq-fe.h. Please specify correct
PostgreSQL installation path`

Applied fix suggested in
docker-library/php#221 (comment)

Re: `--no-cache option` in `apk` command, see
https://stackoverflow.com/questions/49118579/
alpine-dockerfile-advantages-of-no-cache-vs-rm-var-cache-apk
jackdouglas pushed a commit to topanswers/topanswers that referenced this issue Mar 2, 2020
Without lines 6-8, I get an error
`configure: error: Cannot find libpq-fe.h. Please specify correct
PostgreSQL installation path`

Applied fix suggested in
docker-library/php#221 (comment)

Re: `--no-cache option` in `apk` command, see
https://stackoverflow.com/questions/49118579/
alpine-dockerfile-advantages-of-no-cache-vs-rm-var-cache-apk
@luispabon
Copy link

luispabon commented Mar 19, 2020

If somebody stumbles upon this and you're using one of the debian based images:

FROM php:apache

RUN apt-get update; \
    apt-get install -y libpq5 libpq-dev; \
    docker-php-ext-install pdo pdo_pgsql; \
    apt-get autoremove --purge -y libpq-dev; \
    apt-get clean ; \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

Note: you must leave libpq5 for the psql extension to function. Its dev headers though are only needed for compiling the php extension and can and should be removed.

@hung5s
Copy link

hung5s commented Apr 4, 2020

My addition of pdo_pgsql for urbit/lumen-php-fpm:

FROM urbit/lumen-php-fpm

RUN apk --no-cache --update --repository http://dl-
cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/ add \
    postgresql-dev

RUN docker-php-ext-install pdo_pgsql

StefanSchoof added a commit to StefanSchoof/volkszaehler.org that referenced this issue Jul 13, 2021
This reduces the image size in my tests from 426 MB to 110 MB
the steps are taken from
docker-library/php#221 (comment)
StefanSchoof added a commit to StefanSchoof/volkszaehler.org that referenced this issue Jul 14, 2021
This reduces the image size in my tests from 426 MB to 110 MB
the steps are taken from
docker-library/php#221 (comment)
andig pushed a commit to volkszaehler/volkszaehler.org that referenced this issue Jul 14, 2021
This reduces the image size in my tests from 426 MB to 110 MB
the steps are taken from
docker-library/php#221 (comment)
@oyepez003
Copy link

RUN apt-get install -y libpq-dev \
    && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
    && docker-php-ext-install pdo pdo_pgsql pgsql

@docker-library docker-library locked as resolved and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests