title: docker-compose simple example with nginx php and mysql
body: <p>Can someone help me to connect my PHP and MySQL
  I did manage to make it up and running, connect to DB with MySQL Workbench but when I try PDO connect from PHP file it fails for some reason...</p>
  
  <p>docker-compose</p>
  
  <pre><code>web:
      image: nginx:latest
      ports:
          - "80:80"
      volumes:
          - ./:/var/www
          - ./site.conf:/etc/nginx/conf.d/site.conf
      links:
          - php
  php:
      image: php:7-fpm
      volumes:
          - ./:/var/www
      links:
          - db
  
  db:
      image: mysql:5.7
      volumes:
       - /var/lib/mysql
      environment:
       - MYSQL_ROOT_PASSWORD=123456
       - MYSQL_DATABASE=database
      ports:
       - "3306:3306"
  </code></pre>
  
  <p>site.conf</p>
  
  <pre><code>server {
      index index.php index.html;
      server_name lara.test;
      error_log  /var/log/nginx/error.log;
      access_log /var/log/nginx/access.log;
      root /var/www;
  
      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;
      }
  }
  </code></pre>
  
  <p>and index.php</p>
  
  <pre><code>&lt;?php
  
  $database = new PDO('mysql:host=localhost;dbname=database', "root", "123456");
  echo "Connected to MySQL&lt;br /&gt;";
  
  ?&gt;
  </code></pre>
  
  <p>and error message:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught PDOException: could not find driver in
    /var/www/index.php:3 Stack trace: #0 /var/www/index.php(3):
    PDO->__construct('mysql:host=loca...', 'root', '123456') #1 {main}
    thrown in /var/www/index.php on line 3</p>
  </blockquote>
  
  <p>what do I miss in order to make this work?</p>