以docker部署wordpress

首先用下列指令建立一個名稱為wordpress_db的mysql container.

docker run -d \
  --restart=always \
  --name wordpress_db \
  -e MYSQL_ROOT_PASSWORD=xxxxxxxxx \
  mysql:latest

其中xxxxxxxxx是資料庫root的密碼.

接著建立一個名稱為wordpress_web的wordpress container,並將剛剛建立的wordpress_db連結成mysql.

docker run -d \
  --rworestart=always \
  --name wordpress_web \
  -e VIRTUAL_HOST=slanla.com \
  --link wordpress_db:mysql \
  -p 23456:80 \
  wordpress

其中23456為對外聯繫的port.

在我的網站中,另外使用apache2 proxypass的功能轉接至wordpress container, 其apache2設定如下:

#---------------------------------------------------------------- 
# http://www.slanla.com
#
<VirtualHost *:80>
  ServerName slanla.com
  ServerAlias www.slanla.com

  SSLEngine off
  Redirect permanent / https://slanla.com/
</VirtualHost>


#---------------------------------------------------------------- 
# http://www.slanla.com
#
<VirtualHost *:443>
  ServerName slanla.com
  ServerAlias www.slanla.com

  SetEnv force-proxy-request-1.0 1
  SetEnv proxy-nokeepalive 1

  SSLProxyEngine on
  SSLProxyVerify none 
  SSLProxyCheckPeerCN off
  SSLProxyCheckPeerName off
  SSLProxyCheckPeerExpire off


  ProxyPreserveHost On

  ProxyPass / http://10.10.10.10:23456/
  ProxyPassReverse / http://10.10.10.10:23456/

  RequestHeader set X-Forwarded-Proto "https"
  RequestHeader set X-Forwarded-Port "443"

  SSLEngine On
  SSLProtocol all -SSLv2 -SSLv3 -TLSv1
  SSLCipherSuite EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256::EECDH:EDH+aRSA:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS
  SSLHonorCipherOrder     on
  SSLCompression          off
  SSLCertificateFile        cert.pem
  SSLCertificateKeyFile     privkey.pem
  SSLCertificateChainFile   fullchain.pem
</VirtualHost>

發佈留言