Skip to content

Commit 4e96325

Browse files
init
0 parents  commit 4e96325

File tree

6 files changed

+121
-0
lines changed

6 files changed

+121
-0
lines changed

.env

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
APP_NAME=myapp
2+
MYSQL_ROOT_PASSWORD=rootpass

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Docker Compose LEMP Stack
2+
3+
This repository contains a little `docker-compose` configuration to start a `LEMP (Linux, Nginx, MariaDB, PHP)` stack.
4+
5+
## Details
6+
7+
The following versions are used.
8+
9+
* PHP 7.2 (FPM)
10+
* Nginx 1.13.6
11+
* MariaDB 10.3.9
12+
13+
## Configuration
14+
15+
The Nginx configuration can be found in `config/nginx/`.
16+
17+
You can also set the following environment variables, for example in the included `.env` file:
18+
19+
| Key | Description |
20+
|-----|-------------|
21+
|APP_NAME|The name used when creating a container.|
22+
|MYSQL_ROOT_PASSWORD|The MySQL root password used when creating the container.|
23+
24+
## Usage
25+
26+
To use it, simply follow the following steps:
27+
28+
##### Clone this repository.
29+
30+
Clone this repository with the following command: `git clone https://github.com/stevenliebregt/docker-compose-lemp-stack.git`.
31+
32+
##### Start the server.
33+
34+
Start the server using the following command inside the directory you just cloned: `docker-compose up`.

app/index.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
$magicNumbers = [
4+
rand(0, 100),
5+
rand(100, 200),
6+
rand(0, 1000),
7+
];
8+
9+
?>
10+
<!DOCTYPE html>
11+
<html>
12+
<head>
13+
<meta name="author" content="Steven Liebregt" />
14+
<title>Hello, world!</title>
15+
<style>
16+
table, th, td {
17+
border: 1px solid black;
18+
border-collapse: collapse;
19+
}
20+
</style>
21+
</head>
22+
<body>
23+
<h1>Hello, world!</h1>
24+
<p>Your magic numbers are:</p>
25+
<table>
26+
<tr>
27+
<th>#</th>
28+
<th>Number</th>
29+
<tr>
30+
<?php foreach ($magicNumbers as $index => $number): ?>
31+
<tr>
32+
<td><?php echo $index; ?></td>
33+
<td><?php echo $number; ?></td>
34+
</tr>
35+
<?php endforeach; ?>
36+
</table>
37+
<p>If you can see this properly, then it means PHP is working fine.</p>
38+
</body>
39+
</html>

config/nginx/nginx.conf

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
server {
2+
index index.php index.html;
3+
server_name localhost;
4+
error_log /var/log/nginx/error.log;
5+
access_log /var/log/nginx/access.log;
6+
root /var/www/html;
7+
8+
location / {
9+
try_files $uri $uri/ /index.php$is_args$query_string;
10+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
11+
fastcgi_pass php:9000;
12+
fastcgi_index index.php;
13+
include fastcgi_params;
14+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
15+
fastcgi_param PATH_INFO $fastcgi_path_info;
16+
}
17+
}

docker-compose.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: '3'
2+
services:
3+
php:
4+
image: 'php:7.2-fpm'
5+
container_name: ${APP_NAME:?err}-php
6+
volumes:
7+
- './app:/var/www/html'
8+
9+
nginx:
10+
image: 'nginx:1.13.6'
11+
container_name: ${APP_NAME:?err}-nginx
12+
ports:
13+
- '80:80'
14+
- '443:443'
15+
links:
16+
- 'php'
17+
volumes:
18+
- './app:/var/www/html'
19+
- './config/nginx:/etc/nginx/conf.d'
20+
21+
mariadb:
22+
image: 'mariadb:10.3.9'
23+
container_name: ${APP_NAME:?err}-mariadb
24+
restart: 'on-failure'
25+
environment:
26+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?err}
27+
volumes:
28+
- ${PWD}

0 commit comments

Comments
 (0)