Created
August 11, 2020 14:16
-
-
Save weinung-chiu/ce8cb0101548cc5a412068c475e598cd to your computer and use it in GitHub Desktop.
docker_vol2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.8' | |
services: | |
nginx: | |
# 直接拿 nginx official image 來使用 | |
image: library/nginx:1.19-alpine | |
container_name: "charlie_nginx" | |
ports: | |
- 80:80 | |
volumes: | |
- "./nginx.conf:/etc/nginx/conf.d/default.conf" | |
- "./app:/var/www/html" | |
php: | |
# PHP 常常要設定執行環境或其他 extensions ,另外 build image 使用 | |
image: "charlie_php" | |
build: ./php | |
container_name: "charlie_php" | |
ports: | |
- 9000:9000 | |
volumes: | |
- "./app:/var/www/html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 直接用 official image,可以省下很多工 | |
FROM php:7.4.9-fpm-alpine | |
COPY php.ini $PHP_INI_DIR/conf.d/ | |
# 安裝 php extensions 的神器,請務必一試! | |
# https://github.com/mlocati/docker-php-extension-installer | |
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/ | |
RUN install-php-extensions redis mysqli xdebug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//這裡放你的 php 程式,我習慣在建立環境時用 phpinfo() 來確認相關的 extensions 是不是正確安裝 | |
echo "<h1>Charlie C</h1>"; | |
phpinfo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name localhost; | |
root /var/www/html; | |
index index.php; | |
#把 script 轉給 php container 處理 | |
location ~ \.php(/|$) { | |
fastcgi_pass php:9000; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_buffer_size 128k; | |
fastcgi_buffers 4 256k; | |
fastcgi_busy_buffers_size 256k; | |
include fastcgi_params; | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /var/www/html; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
date.timezone = "Asia/Taipei" | |
display_errors = 1 | |
error_reporting = E_ALL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment