自訂 Apache 伺服器的遷移計畫
您應查看建立遷移作業後產生的遷移計畫檔案。請先自訂檔案再執行遷移作業。系統會使用遷移計畫的詳細資料,從來源中擷取工作負載容器構件。
本文件說明遷移作業的內容,以及執行遷移作業及產生部署構件前,您可能會考慮的客製化類型。
事前準備
本文假設您已建立遷移作業,並擁有遷移計畫檔案。
編輯遷移計畫
複製及分析檔案系統後,您可以在指定輸出路徑 ANALYSIS_OUTPUT_PATH/config.yaml
中建立的新目錄中找到遷移計畫。
視需要編輯遷移計畫並儲存變更。
遷移計畫結構
Apache2 工作負載的遷移計畫具有下列結構,您可以自訂這項結構,詳情請參閱下文。
apacheServer:
# Apache configuration for directories on the system
# Content is the configuration as understood by apache
directories:
- Content: |-
Options FollowSymLinks
AllowOverride None
Require all denied
Path: /
- Content: |-
AllowOverride None
Require all granted
Path: /usr/share
- Content: |-
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
Path: /var/www/
- Content: "#\tOptions Indexes FollowSymLinks\n#\tAllowOverride None\n#\tRequire
all granted"
Path: /srv/
- Content: |-
# AllowOverride None
# Require all denied
Path: /
# Environment variables used by apache
envVars:
- Value: www-data
Var: APACHE_RUN_USER
- Value: www-data
Var: APACHE_RUN_GROUP
- Value: /var/run/apache2$SUFFIX/apache2.pid
Var: APACHE_PID_FILE
- Value: /var/run/apache2$SUFFIX
Var: APACHE_RUN_DIR
- Value: /var/lock/apache2$SUFFIX
Var: APACHE_LOCK_DIR
- Value: /var/log/apache2$SUFFIX
Var: APACHE_LOG_DIR
- Value: C
Var: LANG
# The port the service will listen on
listen:
- "80"
- "443"
# Apache modules to be loaded and installed
loadModules:
- Module: access_compat_module
- Module: alias_module
- Module: auth_basic_module
- Module: authn_core_module
- Module: authn_file_module
- Module: authz_core_module
- Module: authz_host_module
- Module: authz_user_module
- Module: autoindex_module
- Module: deflate_module
- Module: dir_module
- Module: env_module
- Module: filter_module
- Module: mime_module
- Module: mpm_prefork_module
- Module: negotiation_module
- Module: php7_module
- Module: proxy_module
- Module: proxy_fcgi_module
- Module: reqtimeout_module
- Module: rewrite_module
- Module: setenvif_module
- Module: socache_shmcb_module
- Module: ssl_module
- Module: status_module
# The sites to be extracted
virtualHosts:
- address: '*:80'
documentRoot: /var/www/html
# should the site be enabled in extracted VM
includeInContainerImage: true
originalConfig: |-
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
serverName: server-0
- address: '*:443'
# The location of the site content (will be copied to the same location the extracted container)
documentRoot: /var/www/html
includeInContainerImage: false
originalConfig: |-
ServerAdmin admin@example.com
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /etc/ssl/certs/c2d-temporary-self-signed-cert.pem
SSLCertificateKeyFile /etc/ssl/private/c2d-temporary-self-signed-cert.key
<Directory /var/www/html>
Options -Indexes
AllowOverride FileInfo
</Directory>
serverName: server-1
php:
# list of php modules to be installed in the extracted container (add/remove entries to change what will be installed)
modules:
- calendar
- ctype
- curl
- exif
- ffi
- fileinfo
- filter
- gd
- gettext
- iconv
- json
- mysqli
- pcntl
- pdo
- pdo_mysql
- posix
- shmop
- sockets
- sysvmsg
- sysvsem
- sysvshm
- tokenizer
- xsl
設定目錄的安全性政策
在 directories
部分,您可以套用特定設定,在特定目錄中強制執行安全性政策。如要填入及編輯這個計畫的部分,請使用 Directory
指示語言的語法。
載入及安裝模組
您可以在 loadModules
部分指定要載入及安裝的模組。Migrate to Containers 會掃描 LoadModule
指令的原始設定,自動偵測所需的模組。
支援的模組
access_compat_module
alias_module
auth_basic_module
authn_core_module
authn_file_module
authz_core_module
authz_host_module
authz_user_module
autoindex_module
deflate_module
dir_module
env_module
expires_module
filter_module
mime_module
mpm_prefork_module
negotiation_module
php7_module
proxy_fcgi_module
proxy_module
remoteip_module
reqtimeout_module
rewrite_module
setenvif_module
socache_shmcb_module
ssl_module
status_module
指定及設定虛擬主機
在 virtualHosts
部分中,Migrate to Containers 會複製 <VirtualHost>
和 </VirtualHost>
區塊中所包圍的所有指示。
在 address
欄位中,網站的 IP 位址已替換為 *
。
在 originalConfig
下方,DocumentRoot
欄位會指定 Apache 提供要求檔案的路徑。對於 DocumentRoot
中指定的每個路徑,Migrate to Containers 會執行以下操作:
- 它會將每個路徑壓縮為個別的 tar 檔案。
- 它會複製成果中的 tar 檔案以供解壓縮。
- 它會使用 Dockerfile 中的
ADD --chown
選項,變更 Docker 映像檔中使用者的權限。
查看 PHP 擴充功能
Migrate to Containers 會自動偵測 VM 中安裝的 PHP 模組,並將這些模組納入遷移計畫的 php
部分。請查看這個部分,視需要新增或移除模組。
後續步驟
- 瞭解如何執行遷移作業。