I am using docker to build my dev enviroment, a very simple env where all i have is nginx and php-fpm.
So following docker docks I have created a docker-compose.yml:
web:
image: nginx:latest
ports:
- "80:80"
volumes:
- ./code:/code
- ./site.conf:/etc/nginx/conf.d/site.conf
links:
- php
php: image: php:7-fpm volumes: - ./code:/code
So what happens here i call nginx image and pgp-fpm image and link them.
I have also created a site.conf file:
server {
index index.php;
server_name php-docker.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /code;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
So here is all the server stuff.
with this set up i have sucesfully runned phpinfo(). When i However aded my app code i get an error complaning about pdo pdo_mysql extensions. So i did more research and found out i need a Dockerfile.
I created a docker file and and inside it added this commands:
FROM php:7
RUN docker-php-ext-install pdo pdo_mysql
Of course this does not work, I mean where does this install the extensions and how does my php-fpm supoose to see these extensions...?
This Dockerfile help me:
FROM php:fpm
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq-dev \
&& docker-php-ext-install mysqli pdo_pgsql pdo_mysql
And this is part my docker-composer.yml
phpfpm:
build:
context: ./php-fpm
dockerfile: Dockerfile
container_name: test-php-fpm
links:
- mysql
volumes:
- ./html:/usr/share/nginx/html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With