Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
Docker Compose LAMP stack 1.8.0:
Browse files Browse the repository at this point in the history
* Updated README, fixed issue with latest MySQL image.
* Added new ENV variables `LINES`, `COLUMNS` for PHP-FPM container.
* Fixed Dockerfile for LAMP build MySQL image.
* Added `htdocs/db.php` as example of connection to MySQL.
  • Loading branch information
akhomy committed Jun 15, 2018
1 parent 3ca9c1a commit 961c289
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@
* Switched to docker-compose 3 version.
* Added example of installing XHProf for PHP-7 and necessary utils.
* Update docker-compose, some common typos and example of PHP-FPM-XHPROF container.

## Docker Compose LAMP stack 1.7.0
* Updated README, fixed issue with latest MySQL image.
* Added new ENV variables `LINES`, `COLUMNS` for PHP-FPM container.
* Fixed Dockerfile for LAMP build MySQL image.
* Added db.php to test connection.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ The custom PHP-FPM image sample is located in the directory - `docker/images/php

For running multiple instances on your local machine, you can update the IP range or ports inside **docker-compose.yml**. For this, on your instance, change IPs to another range, e.g. from `172.55` to `172.54.*`. The same are for ports.

### How connect to MySQL, PostgreSQL, other DBs.

Check `htdocs/db.php` as example of connection to MySQL. However, the main difference is in the host,
you need to use service name as host.


## Documentation
See READMEs for more details, like environment variables for images:
Expand Down
15 changes: 15 additions & 0 deletions htdocs/db.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

$servername = "mysql";
$username = "testdrive";
$password = "testdrive";

try {
$conn = new PDO("mysql:host=$servername;dbname=testdrive", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}

0 comments on commit 961c289

Please sign in to comment.