Docker安裝Drupal 11 及 Php8.3環境
Yaml這樣寫
# Drupal 11 with MySQL and PHP 8.3
#
# Access via "http://localhost:8080"
# (or "http://$(docker-machine ip):8080" if using docker-machine)
#
# During initial Drupal setup,
# Database type: MySQL
# Database name: drupal
# Database username: root
# Database password: example
# ADVANCED OPTIONS; Database host: mysql
version: '3.1'
services:
drupal:
image: drupal:11-apache
ports:
- 8080:80
environment:
PHP_VERSION: "8.3"
volumes:
- /var/www/html/modules
- /var/www/html/profiles
- /var/www/html/themes
- /var/www/html/sites
restart: always
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: drupal
restart: always
Nginx conf
server {
server_name www.yoursite.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
後續維護
首先要學會用composer及drush來更新及管理程式
安裝 7zip,composer 會用得到
docker exec -it dp-drupal-1 apt update
docker exec -it dp-drupal-1 apt install unzip
裝好後把drush更新到最新版
docker exec -it dp-drupal-1 composer require drush/drush
然後更主程式
docker exec -it dp-drupal-1 composer update
更新及整理資料庫
docker exec -it dp-drupal-1 drush updatedb
docker exec -it dp-drupal-1 drush cr