Skip to content

Commit 0701441

Browse files
Update README.md
1 parent 045cd65 commit 0701441

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# docker-nginx-php-fpm
22

3-
Docker image with Nginx + PHP + FPM. PHP version `7.3`. Pre-installed modules: gd, mysql and curl. All env vars located here `/var/www/.env`. Document root directory here `/var/www/html`. All PHP settings defined by default except count of fpm forks, decreased to 1 and the same for Nginx server, `worker_processes` decreased to 1. Time zone can be binded at container startup from host machine by `-v /etc/timezone:/etc/timezone:ro`. Default server port is `80`.
3+
Docker base image with Nginx + PHP + FPM. PHP version `7.3`. Pre-installed modules: gd, mysql and curl. All env vars located here `/var/www/.env`. Document root directory here `/var/www/html`. All PHP settings defined by default except count of fpm forks, decreased to 1 and the same for Nginx server, `worker_processes` decreased to 1. Time zone can be binded at container startup from host machine by `-v /etc/timezone:/etc/timezone:ro`. Default server port is `80`.
44

55
Docker image: [https://hub.docker.com/repository/docker/vladimirok5959/nginx-php-fpm](https://hub.docker.com/repository/docker/vladimirok5959/nginx-php-fpm)
66

@@ -11,3 +11,31 @@ Docker image: [https://hub.docker.com/repository/docker/vladimirok5959/nginx-php
1111
* **make docker-import** - import docker image from file
1212
* **make docker-test** - run test container
1313
* **make docker-push** - push image to docker hub
14+
15+
## Read ENVs from PHP
16+
17+
```php
18+
function LoadEnvironmentVariables() {
19+
$f = '../.env';
20+
if(file_exists($f)) {
21+
foreach(explode("\n", file_get_contents($f)) as $value) {
22+
if(trim($value) != '') {
23+
$pos = strpos($value, '=');
24+
if($pos === false) continue;
25+
$_ENV[substr($value, 0, $pos)] = substr($value, $pos + 1, strlen($value) - $pos - 1);
26+
}
27+
}
28+
}
29+
}
30+
```
31+
32+
## Running docker container
33+
34+
```sh
35+
docker run \
36+
--network host \
37+
--name my-container-name \
38+
-v /etc/timezone:/etc/timezone:ro \
39+
-v /path/to/php/files:/var/www/html \
40+
-d -it vladimirok5959/nginx-php-fpm:latest
41+
```

0 commit comments

Comments
 (0)