Reading time: 2 minutes
Today I’m going to show you how to install the PDO pdo_mysql extension to use Codeigniter or RedBeans, etc…
![](https://i0.wp.com/devcodelight.com/wp-content/uploads/2023/04/imagen-10.png?resize=753%2C267&ssl=1)
We have the following docker-compose.yml file:
version: "3.1" services: miservicio_mariadb: image: mariadb container_name: mariadb_container env_file: - ./Dockerfile/mysql.env environment: MYSQL_DATABASE: "db_prueba" MYSQL_USER: "user_prueba" MYSQL_PASSWORD: "pass_mysql" MYSQL_ROOT_PASSWORD: "contra@prueba" volumes: - ./config/mariadb:/var/lib/mysql expose: - 3306 ports: - 3306:3306 networks: - docker-network phpmyadmin: image: phpmyadmin restart: always container_name: phpmyadmin_container ports: - 8080:80 environment: - PMA_ARBITRARY=1 links: - miservicio_mariadb:db networks: - docker-network miservicio_php: build: context: ./Dockerfile dockerfile: php_file env_file: - ./Dockerfile/php.env container_name: php_container volumes: - ./www:/var/www/html - ./logs/apache:/var/log/apache2 - ./config/letsencrypt/certs:/etc/apache2/ssl/ - ./config/web/logs:/var/www/logs expose: - 80 - 443 ports: - 8000:80 - 442:443 links: - miservicio_mariadb networks: - docker-network networks: docker-network: driver: bridge external: true
And the php_container file is created from this dockerfile:
# syntax=docker/dockerfile:1 FROM php:7.0-apache RUN docker-php-ext-install mysqli #Activate Apache modules: RUN a2enmod headers RUN a2enmod rewrite RUN a2enmod ssl RUN /etc/init.d/apache2 restart
If we want to install the pdo_mysql module, we have to add the following:
RUN docker-php-ext-install pdo_mysql
Resulting in the following dockerfile:
# syntax=docker/dockerfile:1 FROM php:7.0-apache RUN docker-php-ext-install mysqli RUN docker-php-ext-install pdo_mysql #Activate Apache modules: RUN a2enmod headers RUN a2enmod rewrite RUN a2enmod ssl RUN /etc/init.d/apache2 restart
And when we run phpinfo(); the installed module appears:
![](https://i0.wp.com/devcodelight.com/wp-content/uploads/2023/04/imagen-11.png?resize=900%2C272&ssl=1)
![](https://i0.wp.com/devcodelight.com/wp-content/uploads/2023/07/cropped-light_logo-5.png?resize=100%2C100&ssl=1)