在 .env
檔的 APP_CODE_PATH_HOST
參數修改為存放所有專案的根目錄路徑。
1
| APP_CODE_PATH_HOST=~/Projects
|
修改 docker-compose.yml
檔的 nginx
設定:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| nginx: build: context: ./nginx args: - PHP_UPSTREAM_CONTAINER=${NGINX_PHP_UPSTREAM_CONTAINER} - PHP_UPSTREAM_PORT=${NGINX_PHP_UPSTREAM_PORT} - CHANGE_SOURCE=${CHANGE_SOURCE} - http_proxy - https_proxy - no_proxy volumes: - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG} - ${NGINX_HOST_LOG_PATH}:/var/log/nginx - ${NGINX_SITES_PATH}:/etc/nginx/sites-available - ${NGINX_SSL_PATH}:/etc/nginx/ssl ports: - "${NGINX_HOST_HTTP_PORT}:80" - "81:81" - "${NGINX_HOST_HTTPS_PORT}:443" depends_on: - php-fpm networks: - frontend - backend
|
在 nginx/sites
複製一個 laravel.conf.example
範本設定檔為 laravel.conf
,並修改為以下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| server {
listen 81; listen [::]:81;
# For https # listen 443 ssl; # listen [::]:443 ssl ipv6only=on; # ssl_certificate /etc/nginx/ssl/default.crt; # ssl_certificate_key /etc/nginx/ssl/default.key;
server_name localhost; root /var/www/laravel/public; index index.php index.html index.htm;
location / { try_files $uri $uri/ /index.php$is_args$args; }
location ~ \.php$ { try_files $uri /index.php =404; fastcgi_pass php-upstream; fastcgi_index index.php; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fixes timeouts fastcgi_read_timeout 600; include fastcgi_params; }
location ~ /\.ht { deny all; }
location /.well-known/acme-challenge/ { root /var/www/letsencrypt/; log_not_found off; }
error_log /var/log/nginx/laravel_error.log; access_log /var/log/nginx/laravel_access.log; }
|
啟動 Nginx 服務。