1.3 KiB
1.3 KiB
LNMP
docker pull nginx:alpine
docker pull php:7-fpm-alpine
docker pull postgres:alpine
docker run --rm -d -p 80:80 --name nginx nginx:alpine
配置
全局
touch ~/docker/docker-compose.yml
touch ~/docker/nginx.conf
version: "3"
services:
Nginx:
image: nginx:alpine
ports:
- 80:80
volumes:
- ./web:/usr/share/nginx/html:ro
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
PHP:
image: undefined01/php:7-fpm-alpine
volumes:
- ./web:/var/www/html:rw
Database:
image: postgres:alpine
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "rootroot"
volumes:
- ./data:/var/lib/postgresql/data:rw
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass PHP:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
include fastcgi_params;
}
}
运行
#启动
docker-compose up -d
#查看
docker container ls