使用Fig配置WordPress

使用Fig能够很轻松的将Wordpress部署到独立的环境中。首先,你须要安装Fig,而后下载WordPress到当前目录:php

$ curl https://wordpress.org/latest.tar.gz | tar -xvzf -mysql

这会建立一个目录叫wordpress,你能够修改为你想要的名字。进入wordpress目录,建立一个Dockerfile文件,内容为:web

FROM orchardup/php5sql

ADD  . /code数据库

该指令会建立一个镜像包含PHP和WordPess环境。curl

下一步,建立fig.yml,用来启动web服务和数据库。wordpress

fig.yml的内容为:ui

web:
build: .
command: php -S 0.0.0.0:8000 -t /code
ports:
– “8000:8000″
links:
– db
volumes:
– .:/code
db:
image: orchardup/mysql
environment:
MYSQL_DATABASE: wordpressurl

要想让服务启动起来,还须要配置wp-config.php这个文件,主要修改数据库的配置将db host修改为db容器的名字。spa

内容为:
<?php
define(‘DB_NAME’, ‘wordpress’);
define(‘DB_USER’, ‘root’);
define(‘DB_PASSWORD’, ”);
define(‘DB_HOST’, “db:3306″);
define(‘DB_CHARSET’, ‘utf8′);
define(‘DB_COLLATE’, ”);

define(‘AUTH_KEY’, ‘put your unique phrase here’);
define(‘SECURE_AUTH_KEY’, ‘put your unique phrase here’);
define(‘LOGGED_IN_KEY’, ‘put your unique phrase here’);
define(‘NONCE_KEY’, ‘put your unique phrase here’);
define(‘AUTH_SALT’, ‘put your unique phrase here’);
define(‘SECURE_AUTH_SALT’, ‘put your unique phrase here’);
define(‘LOGGED_IN_SALT’, ‘put your unique phrase here’);
define(‘NONCE_SALT’, ‘put your unique phrase here’);

$table_prefix = ‘wp_';
define(‘WPLANG’, ”);
define(‘WP_DEBUG’, false);

if ( !defined(‘ABSPATH’) )
define(‘ABSPATH’, dirname(__FILE__) . ‘/’);

require_once(ABSPATH . ‘wp-settings.php’);

而后,运行fig up,直到它正常运行。

最后,你就能够从8000端口进行访问了。

相关文章
相关标签/搜索