0

When creating a LEMP stack using PHP-FPM I can't seem to load the PDO dirver it keeps defaulting to the sqlite driver.

Docker compose:

version: "3.5"
services:

redis:
  image: redis:alpine
  container_name: errors-redis

mysql:
  image: mysql:8.0
  container_name: errors-mysql
  working_dir: /application
  volumes:
    - .:/application
  environment:
    - MYSQL_ROOT_PASSWORD=test
    - MYSQL_DATABASE=errors
    - MYSQL_USER=test
    - MYSQL_PASSWORD=test
  ports:
    - "9011:3306"

webserver:
  image: nginx:latest
  container_name: errors-nginx
  working_dir: /application
  volumes:
      - .:/application
      - ./dev/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
  ports:
   - "9010:80"

php-fpm:
  image: php:fpm
  container_name: errors-php-fpm
  working_dir: /application
  volumes:
    - .:/application
    - ./dev/php-fpm/php-ini-overrides.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini

Docker file:

FROM phpdockerio/php72-fpm:latest
WORKDIR "/application"

# Install selected extensions and other stuff
RUN apt-get update \
    && apt-get -y --no-install-recommends install  php-memcached php7.2-mysql php-redis php-xdebug \
    && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

PHP ini

upload_max_filesize = 100M
post_max_size = 108M

Now when I check phpinfo()

PDO support enabled
PDO drivers sqlite

I've not installed sqlite at any point so I'm not sure how it's gotten it. How do I change it to use MySQL instead of sqlite?

1
  • You building image from phpdockerio/php72-fpm:latest and probably in it or its parent image sqlite is installed. Commented Mar 3, 2018 at 12:30

1 Answer 1

2

You need to add the PDO bits to your install as well...

apt-get -y --no-install-recommends install php-memcached php-redis php-xdebug mysqli pdo pdo_mysql \

Specifically the last 3. You can probably miss out the php7.2-mysql as this should be covered with the mysqli option.

Sign up to request clarification or add additional context in comments.

4 Comments

This still doesn't seem to work, I can still only see sqlite under the PDO drivers
I have done a fresh test and it has worked fine, I guess the old config is some how holding state
I'm never quite sure if you have to re-create the image when changing these settings - haven't done it for a while.
If this has solved your problem, please consider marking it as answered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.