Skip to content

Instantly share code, notes, and snippets.

@tounan
Created August 20, 2021 01:27
Show Gist options
  • Save tounan/353d30cd267ba633fd336f171333c257 to your computer and use it in GitHub Desktop.
Save tounan/353d30cd267ba633fd336f171333c257 to your computer and use it in GitHub Desktop.
Simple, no bullsh*t nginx+php+mariadb (lnmp) with docker-compose
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/host.access.log main;
location / {
root /var/www/html;
index index.html index.htm index.php;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on engine:9000
#
location ~ \.php$ {
root /var/www/html;
fastcgi_pass engine:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
services:
webserver:
image: nginx
volumes:
- ./conf.d:/etc/nginx/conf.d
- ./www:/var/www/html
ports:
- "8000:80"
engine:
# uncomment to use official image
#image: php:7.4-fpm
build:
context: .
dockerfile: ./php.dockerfile
# or custom build to add exts
volumes:
- ./www:/var/www/html
database:
image: mariadb
restart: always
volumes:
- ./import.sql:/docker-entrypoint-initdb.d/import.sql
environment:
- MYSQL_ROOT_PASSWORD=p4ssw0rd
- MYSQL_DATABASE=dbname
FROM php:7.4-fpm
RUN docker-php-ext-install mysqli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment