This guide will explain how to create a WordPress environment using KUSANAGI Runs on Docker (KUSANAGI RoD).
Overview
KUSANAGI RoD runs the Ultrafast WordPress Virtual Machine KUSANAGI on a Docker Machine.
KUSANAGI RoD offers the same high speed WordPress execution environment as KUSANAGI, but since it is in beta, the following restrictions apply.
- ・Operating environment
You can use Nginx, PHP 7, PHP 5 and MariaDB.
We will expand to Apache2(httpd) and HHVM at a later time. - ・KUSANAGI commands
You cannot use KUSANAGI commands.
The “kusanagi provision” and “bcache/fcache” commands are performed by editing “docker-compose.yml” - ・SSL
You cannot use Let’s Encrypt’s SSL service.
We will add SSL support at a later time.
Installation
You need Docker, Docker Machine, and Docker Compose to use KUSANAGI RoD.
Installation instructions are as follows.
Docker
Choose the Docker installation for your OS.
Docker Machine
Install Docker Machine from the following:
Docker Compose
Install Docker Compose from the following:
On Windows, installing Docker Toolbox will install Docker Compose as well.
Create a Docker Machine
You can control Docker using your Docker Machine on the local VirtualBox or a cloud platform (such as Microsoft Azure, AWS EC2, etc.)
On VirtualBox
View Get started with Docker Machine and a local VM and create a Docker Machine on VirtualBox. In the following example, we created the Docker Machine “kusanagi-machine”.
# docker-machine create --driver virtualbox --virtualbox-memory=8192 --virtualbox-cpu-count=2 kusanagi-machine
Use the following command to confirm the details of your Docker Machine.
# docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
kusanagi-machine * virtualbox Running tcp://192.168.99.100:2376 v1.11.1
# docker-machine env kusanagi-machine
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/root/.docker/machine/machines/kusanagi-machine"
export DOCKER_MACHINE_NAME="kusanagi-machine"
# Run this command to configure your shell:
On Azure
View Use Docker Machine with the Azure driver and create a Docker Machine on Microsoft Azure. In the following example, we created the Docker Machine “kusanagi-machine”. We set our region as Japan East, and the VM size to Standard_D1.
# docker-machine create -d azure --azure-ssh-user rod \
--azure-subscription-id <Your AZURE_SUBSCRIPTION_ID> \
--azure-location "Japan East" \
--azure-size "Standard_D1" \
--azure-open-port 80 \
kusanagi-azure
Occasionally you will be asked to verify your account, so access the webpage shown and enter the code.
(kusanagi-azure) Microsoft Azure: To sign in, use a web browser to open the page https://aka.ms/devicelogin. Enter the code XXXXXXXXX to authenticate.
Use the following command to confirm the details of your Docker Machine.
# docker-machine ls kusanagi-azure
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
kusanagi-azure - azure Running tcp://XXX.XXX.XXX.XXX:2376 v1.11.1
# docker-machine env kusanagi-azure
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://XXX.XXX.XXX.XXX:2376"
export DOCKER_CERT_PATH="/root/.docker/machine/machines/kusanagi-azure"
export DOCKER_MACHINE_NAME="kusanagi-azure"
# Run this command to configure your shell:
# eval $(docker-machine env kusanagi-azure)
Create KUSANAGI RoD with Docker Compose
Next we will create KUSANAGI RoD by using Docker Compose.
- (1) Download kusanagi-docker from GitHub.
# git clone https://github.com/prime-strategy/kusanagi-docker.git
# cd kusanagi-docker
# ls -A
.git LICENSE README.md
- (2) Like the README states, create “docker-compose.yml”. In the following example we created it using nginx-1.10.0-1 and php-7.0.6.
-
# cat docker-compose.yml version: '2' services: kusanagi-data: container_name: kusanagi-data image: busybox restart: always stdin_open: true tty: true volumes: - /var/lib/mysql - /etc/nginx/conf.d - /etc/httpd/conf.d - /etc/kusanagi.d - /home/kusanagi command: /bin/sh kusanagi-nginx: container_name: kusanagi-nginx image: primestrategy/kusanagi-nginx:1.10.0-1 environment: PROFILE: kusanagi FQDN: kusanagi.example.jp WPLANG: ja BCACHE: "off" FCACHE: "off" volumes_from: - kusanagi-data links: - kusanagi-php7:php - kusanagi-mariadb:mysql ports: - "80:80" - "443:443" kusanagi-mariadb: container_name: kusanagi-mariadb image: mariadb:10.0.24 environment: MYSQL_ROOT_PASSWORD: my-secret-pw MYSQL_USER: user MYSQL_PASSWORD: password MYSQL_DATABASE: wordpress volumes_from: - kusanagi-data kusanagi-php7: container_name: kusanagi-php7 image: primestrategy/kusanagi-php7:7.0.6-1 links: - kusanagi-mariadb:mysql volumes_from: - kusanagi-data
- (3) Change your settings
Edit “docker-compose.yml” to change the environment variables.- kusanagi-nginx
explanation PROFILE Profile name created with kusanagi provision FQDN Host name identified in kusanagi provision WPLANG Language selected in kusanagi provision (en, ja) BCACHE Turn bcache on or off FCACHE Turn fcache on or off - kusanagi-mariadb
explanation MYSQL_ROOT_PASSWORD MySQL root user password MYSQL_USER WordPress user name MYSQL_PASSWORD WordPress password MYSQL_DATABASE WordPress database name - (4) Configure the Docker environment
Name your Docker Machine and perform the settings needed in order to use Docker Compose. -
# eval $(docker-machine env kusanagi-azure)
- (5) Use docker-compose.yml to boot Docker using your Docker Machine.
-
# docker-compose -p kusanagi-azure up # docker-compose -p kusanagi-azure ps Name Command State Ports ---------------------------------------------------------------------------------------------------- kusanagi-data /bin/sh Up kusanagi-mariadb /docker-entrypoint.sh mysqld Up 3306/tcp kusanagi-nginx /docker-entrypoint.sh /usr ... Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp kusanagi-php7 php-fpm Up 9000/tcp
WordPress Settings
Go to the host you identified in “docker-compose.yml” and you should be able to install WordPress. Use the following settings:
explanation | |
---|---|
Database Name | Same as MYSQL_DATABASE. Above example is wordpress |
Username | Same as MYSQL_USER. Above example is user |
Password | Same as MYSQL_PASSWORD. Above example is password |
Database Host | MySQL host name identified during kusanagi-nginx setup. Above example is mysql |
Table Prefix | Optional. Default is wp_ |