Skip to content

Commit c0caec5

Browse files
committed
ngixn and fpm
1 parent d2bc2d3 commit c0caec5

File tree

10 files changed

+125
-1
lines changed

10 files changed

+125
-1
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
# lemp-docker-compose
2-
Docker compose LEMP environment
2+
3+
Fully LEMP working environment for Docker compose.
4+
5+
## Pre-requisites
6+
7+
You must have docker desktop running on your computer. Follow instalation instructions from here:
8+
9+
https://docs.docker.com/desktop/
10+
11+
## Configuration
12+
13+
Check docker-compose.yml and change the volume for nginx and php-fpm where you have your code, by default it's serving from `src/` folder a default phpinfo() file.
14+
15+
## Get up & running
16+
17+
Just run `docker-compose up`

docker-compose.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: '3'
2+
3+
services:
4+
# database:
5+
# build:
6+
# context: ./database
7+
# environment:
8+
# - MYSQL_DATABASE=${DATABASE_NAME}
9+
# - MYSQL_USER=${DATABASE_USER}
10+
# - MYSQL_PASSWORD=${DATABASE_PASSWORD}
11+
# - MYSQL_ROOT_PASSWORD=${DATABASE_ROOT_PASSWORD}
12+
# ports:
13+
# - "3306:3306"
14+
# volumes:
15+
# - ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
16+
# - ./database/data:/var/lib/mysql
17+
18+
php-fpm:
19+
build:
20+
context: ./php-fpm
21+
# depends_on:
22+
# - database
23+
# environment:
24+
# - APP_ENV=${APP_ENV}
25+
# - APP_SECRET=${APP_SECRET}
26+
# - DATABASE_URL=mysql://${DATABASE_USER}:${DATABASE_PASSWORD}@database:3306/${DATABASE_NAME}?serverVersion=5.7
27+
volumes:
28+
- ./src/:/var/www/
29+
30+
nginx:
31+
build:
32+
context: ./nginx
33+
volumes:
34+
- ./src/:/var/www/
35+
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
36+
- ./nginx/conf.d/:/etc/nginx/conf.d/
37+
- ./logs:/var/log
38+
depends_on:
39+
- php-fpm
40+
ports:
41+
- "80:80"

logs/nginx/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

nginx/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM nginx:1.18
2+
WORKDIR /var/www
3+
CMD ["nginx"]
4+
EXPOSE 80

nginx/conf.d/default.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
server {
2+
listen 80 default_server;
3+
listen [::]:80 default_server ipv6only=on;
4+
5+
server_name localhost;
6+
root /var/www/;
7+
index index.php index.html index.htm;
8+
9+
location / {
10+
try_files $uri $uri/ /index.php$is_args$args;
11+
}
12+
13+
location ~ \.php$ {
14+
try_files $uri /index.php =404;
15+
fastcgi_pass php-upstream;
16+
fastcgi_index index.php;
17+
fastcgi_buffers 16 16k;
18+
fastcgi_buffer_size 32k;
19+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
20+
fastcgi_read_timeout 600;
21+
include fastcgi_params;
22+
}
23+
24+
location ~ /\.ht {
25+
deny all;
26+
}
27+
}

nginx/conf.d/php-fpm.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
upstream php-upstream {
2+
server php-fpm:9000;
3+
}

nginx/nginx.conf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
user nginx;
2+
worker_processes 4;
3+
daemon off;
4+
5+
error_log /var/log/nginx/error.log warn;
6+
pid /var/run/nginx.pid;
7+
8+
events {
9+
worker_connections 1024;
10+
}
11+
12+
13+
http {
14+
include /etc/nginx/mime.types;
15+
default_type application/octet-stream;
16+
access_log /var/log/nginx/access.log;
17+
sendfile on;
18+
keepalive_timeout 65;
19+
20+
include /etc/nginx/conf.d/*.conf;
21+
}

php-fpm/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:7.4.14-fpm
2+
WORKDIR /var/www
3+
COPY --from=composer /usr/bin/composer /usr/bin/composer
4+
RUN curl -sS https://get.symfony.com/cli/installer | bash
5+
RUN echo "export PATH=\"$HOME/.symfony/bin:$PATH\"" > ~/.bashrc
6+
RUN cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini
7+
CMD ["php-fpm"]
8+
EXPOSE 9000

src/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hola!

src/phpinfo.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
phpinfo();

0 commit comments

Comments
 (0)