Merge pull request #81 from cytopia/release-0.11

Release 0.11
This commit is contained in:
cytopia 2017-06-25 14:47:26 +02:00 committed by GitHub
commit fbb169c37c
49 changed files with 3541 additions and 1052 deletions

View File

@ -10,8 +10,8 @@ error_reporting(-1);
putenv('RES_OPTIONS=retrans:1 retry:1 timeout:1 attempts:1');
$DEVILBOX_VERSION = 'v0.10';
$DEVILBOX_DATE = '2017-05-26';
$DEVILBOX_VERSION = 'v0.11';
$DEVILBOX_DATE = '2017-06-25';
$DEVILBOX_API_PAGE = 'devilbox-api/status.json';
//

View File

@ -410,18 +410,26 @@ $HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL);
<th>composer</th>
<td><?php if (($version = loadClass('Php')->getComposerVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
</tr>
<tr>
<th>drupal-console</th>
<td><?php if (($version = loadClass('Php')->getDrushConsoleVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
</tr>
<tr>
<th>drush</th>
<td><?php if (($version = loadClass('Php')->getDrushVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
</tr>
<tr>
<th>drush-console</th>
<td><?php if (($version = loadClass('Php')->getDrushConsoleVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
</tr>
<tr>
<th>git</th>
<td><?php if (($version = loadClass('Php')->getGitVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
</tr>
<tr>
<th>Laravell installer</th>
<td><?php if (($version = loadClass('Php')->getLaravelVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
</tr>
<tr>
<th>mysqldump-secure</th>
<td><?php if (($version = loadClass('Php')->getMdsVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
</tr>
<tr>
<th>node</th>
<td><?php if (($version = loadClass('Php')->getNodeVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
@ -430,6 +438,18 @@ $HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL);
<th>npm</th>
<td><?php if (($version = loadClass('Php')->getNpmVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
</tr>
<tr>
<th>Phalcon devtools</th>
<td><?php if (($version = loadClass('Php')->getPhalconVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
</tr>
<tr>
<th>Symfony installer</th>
<td><?php if (($version = loadClass('Php')->getSymfonyVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
</tr>
<tr>
<th>Wordpress cli</th>
<td><?php if (($version = loadClass('Php')->getWpcliVersion()) === false) {echo '<span class="text-danger">not installed</span>';}else{echo $version;}; ?></td>
</tr>
</tbody>
</table>

View File

@ -52,8 +52,8 @@ class Php extends BaseClass implements BaseInterface
}
public function getDrushConsoleVersion()
{
$output = loadClass('Helper')->exec('drush-console --version', $output);
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
$output = loadClass('Helper')->exec('drupal --version | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"', $output);
return loadClass('Helper')->egrep('/[0-9.]+[-rc0-9.]*/', $output);
}
public function getNodeVersion()
{
@ -65,6 +65,32 @@ class Php extends BaseClass implements BaseInterface
$output = loadClass('Helper')->exec('npm --version', $output);
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
}
public function getLaravelVersion()
{
$output = loadClass('Helper')->exec('laravel --version', $output);
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
}
public function getMdsVersion()
{
$output = loadClass('Helper')->exec('mysqldump-secure --version', $output);
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
}
public function getPhalconVersion()
{
$output = loadClass('Helper')->exec('phalcon --version', $output);
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
}
public function getSymfonyVersion()
{
$output = loadClass('Helper')->exec('symfony --version', $output);
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
}
public function getWpcliVersion()
{
$output = loadClass('Helper')->exec('wp --version', $output);
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
}
/*********************************************************************************

8
.gitignore vendored
View File

@ -20,6 +20,7 @@
/.env
/log/[a-z0-9-]*
/data/
/backups/
# Ignore custom MySQL configs
/cfg/mysql-5.5/*.cnf
@ -39,12 +40,6 @@
/cfg/php-fpm-7.1/*.ini
/cfg/hhvm-latest/*.ini
# gh-pages
docs/Gemfile
docs/Gemfile.lock
docs/_site/
docs/view-page.sh
######################################
# GENERIC
@ -104,6 +99,7 @@ $RECYCLE.BIN/
*.swp
*.swo
*.swn
*.swm
*~
###### TextMate ######

View File

@ -340,8 +340,8 @@ devilbox_start() {
done
printf "\n"
# Wait another 30 sec for databases to come up
wait_for 30 1
# Wait another 60 sec for databases to come up
wait_for 60 1
echo
}
@ -436,7 +436,7 @@ devilbox_test_url() {
_pattern="${2}"
_number="${3}"
_count="$( curl -q "${_url}" 2>/dev/null | grep -c "${_pattern}" || true )"
_count="$( curl -q --retry 100 --retry-max-time 0 "${_url}" 2>/dev/null | grep -c "${_pattern}" || true )"
if [ "${_count}" != "${_number}" ]; then
echo "[ERR]: Found ${_count}/${_number} of '${_pattern}'"

View File

@ -172,12 +172,15 @@ matrix:
###
before_install:
# Get newer docker version
- max=20; i=0; while [ $i -lt $max ]; do if sudo apt-get update; then break; else i=$((i+1)); fi done
- max=20; i=0; while [ $i -lt $max ]; do if sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-engine; then break; else i=$((i+1)); fi done
- max=100; i=0; while [ $i -lt $max ]; do if sudo apt-get update; then break; else i=$((i+1)); fi done
- max=100; i=0; while [ $i -lt $max ]; do if sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce; then break; else i=$((i+1)); fi done
# Get newer docker-compose version
- curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > docker-compose
- curl -L --retry 100 --retry-max-time 0 https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv -f docker-compose /usr/local/bin
# List versions
- docker version
- docker-compose version
###

339
README.md
View File

@ -14,9 +14,9 @@
[![Build Status](https://travis-ci.org/cytopia/devilbox.svg?branch=master)](https://travis-ci.org/cytopia/devilbox) ![Tag](https://img.shields.io/github/tag/cytopia/devilbox.svg) [![type](https://img.shields.io/badge/type-Docker-orange.svg)](https://www.docker.com/) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
The devilbox is a modern and highly customizable alternative for *[XAMPP](https://www.apachefriends.org)* with a few additional feature on top. It is based on `docker-compose` with presets for all kinds of versions for webservers, database servers, php and more.
The devilbox is a modern and highly customisable **LAMP** and **MEAN** stack replacement based purely on docker and docker-compose running on all major platforms. It supports an unlimited number of projects for which vhosts and DNS records are created automatically. Email catch-all and popular development tools will be at your service as well.
Configuration is not necessary, as everything is pre-setup with mass virtual hosting and auto-dns.
Configuration is not necessary, as everything is pre-setup with mass virtual hosting and also offers Auto-DNS.
**Supported operating systems**
@ -25,12 +25,12 @@ Configuration is not necessary, as everything is pre-setup with mass virtual hos
<sub>It might run on FreeBSD, but I don't know the status of docker-compose there.</sub>
---
## Usage
### Quick start
#### Quick start
You are up and running in three simple steps:
@ -45,125 +45,292 @@ $ vim .env
$ docker-compose up
```
### Selective start
#### Selective start
The above will start all containers, you can however also just start the containers you actually need. This is achieved by simply specifying them in the docker-compose command. Here are a few examples to get you started.
The above will start all containers, you can however also just start the containers you actually need. This is achieved by simply specifying them in the docker-compose command.
```shell
$ docker-compose up httpd php mysql redis
```
![Devilbox](docs/img/devilbox-dash-01.png)
#### Run different versions
```shell
$ docker-compose up httpd php mysql pgsql redis memcd
```
![Devilbox](docs/img/devilbox-dash-02.png)
Every single attachable container comes with many different versions. In order to select the desired version for a container, simply edit the `.env` file and uncomment the version of choice.
```shell
$ docker-compose up httpd php pgsql memcd
```
![Devilbox](docs/img/devilbox-dash-03.png)
<table>
<thead>
<tr>
<th>Apache</th>
<th>Nginx</th>
<th>PHP</th>
<th>MySQL</th>
<th>MariaDB</th>
<th>PgSQL</th>
<th>Redis</th>
<th>Memcached</th>
<th>MongoDB</th>
</tr>
</thead>
<tbody>
<tr>
<td><a target="_blank" title="Apache 2.2" href="https://github.com/cytopia/docker-apache-2.2">2.2</a></td>
<td><a target="_blank" title="Nginx stable" href="https://github.com/cytopia/docker-nginx-stable">stable</a></td>
<td><a target="_blank" title="PHP 5.4" href="https://github.com/cytopia/docker-php-fpm-5.4">5.4</a></td>
<td><a target="_blank" title="MySQL 5.5" href="https://github.com/cytopia/docker-mysql-5.5">5.5</a></td>
<td><a target="_blank" title="MariaDB 5.5" href="https://github.com/cytopia/docker-mariadb-5.5">5.5</a></td>
<td><a target="_blank" title="PgSQL 9.1" href="https://github.com/docker-library/postgres">9.1</a></td>
<td><a target="_blank" title="Redis 2.8" href="https://github.com/docker-library/redis">2.8</a></td>
<td><a target="_blank" title="Memcached 1.4.21" href="https://github.com/docker-library/memcached">1.4.21</a></td>
<td><a target="_blank" title="MongoDB 2.8" href="https://github.com/docker-library/mongo">2.8</a></td>
</tr>
<tr>
<td><a target="_blank" title="Apache 2.4" href="https://github.com/cytopia/docker-apache-2.4">2.4</a></td>
<td><a target="_blank" title="Nginx mainline" href="https://github.com/cytopia/docker-nginx-mainline">mainline</a></td>
<td><a target="_blank" title="PHP 5.5" href="https://github.com/cytopia/docker-php-fpm-5.5">5.5</a></td>
<td><a target="_blank" title="MySQL 5.6" href="https://github.com/cytopia/docker-mysql-5.6">5.6</a></td>
<td><a target="_blank" title="MariaDB 10.0" href="https://github.com/cytopia/docker-mariadb-10.0">10.0</a></td>
<td><a target="_blank" title="PgSQL 9.2" href="https://github.com/docker-library/postgres">9.2</a></td>
<td><a target="_blank" title="Redis 3.0" href="https://github.com/docker-library/redis">3.0</a></td>
<td><a target="_blank" title="Memcached 1.4.22" href="https://github.com/docker-library/memcached">1.4.22</a></td>
<td><a target="_blank" title="MongoDB 3.0" href="https://github.com/docker-library/mongo">3.0</a></td>
</tr>
<tr>
<td></td>
<td></td>
<td><a target="_blank" title="PHP 5.6" href="https://github.com/cytopia/docker-php-fpm-5.6">5.6</a></td>
<td><a target="_blank" title="MySQL 5.7" href="https://github.com/cytopia/docker-mysql-5.7">5.7</a></td>
<td><a target="_blank" title="MariaDB 10.1" href="https://github.com/cytopia/docker-mariadb-10.1">10.1</a></td>
<td><a target="_blank" title="PgSQL 9.3" href="https://github.com/docker-library/postgres">9.3</a></td>
<td><a target="_blank" title="Redis 3.2" href="https://github.com/docker-library/redis">3.2</a></td>
<td><a target="_blank" title="Memcached 1.4.23" href="https://github.com/docker-library/memcached">1.4.23</a></td>
<td><a target="_blank" title="MongoDB 3.2" href="https://github.com/docker-library/mongo">3.2</a></td>
</tr>
<tr>
<td></td>
<td></td>
<td><a target="_blank" title="PHP 7.0" href="https://github.com/cytopia/docker-php-fpm-7.0">7.0</a></td>
<td><a target="_blank" title="MySQL 8.0" href="https://github.com/cytopia/docker-mysql-8.0">8.0</a></td>
<td><a target="_blank" title="MariaDB 10.2" href="https://github.com/cytopia/docker-mariadb-10.2">10.2</a></td>
<td><a target="_blank" title="PgSQL 9.4" href="https://github.com/docker-library/postgres">9.4</a></td>
<td></td>
<td>...</td>
<td><a target="_blank" title="MongoDB 3.4" href="https://github.com/docker-library/mongo">3.4</a></td>
</tr>
<tr>
<td></td>
<td></td>
<td><a target="_blank" title="PHP 7.1" href="https://github.com/cytopia/docker-php-fpm-7.1">7.1</a></td>
<td></td>
<td><a target="_blank" title="MariaDB 10.3" href="https://github.com/cytopia/docker-mariadb-10.3">10.3</a></td>
<td><a target="_blank" title="PgSQL 9.5" href="https://github.com/docker-library/postgres">9.5</a></td>
<td></td>
<td><a target="_blank" title="Memcached 1.4.36" href="https://github.com/docker-library/memcached">1.4.36</a></td>
<td><a target="_blank" title="MongoDB 3.5" href="https://github.com/docker-library/mongo">3.5</a></td>
</tr>
<tr>
<td></td>
<td></td>
<td><a target="_blank" title="HHVM" href="https://github.com/cytopia/docker-hhvm-latest">HHVM</a></td>
<td></td>
<td></td>
<td><a target="_blank" title="PgSQL 9.6" href="https://github.com/docker-library/postgres">9.6</a></td>
<td></td>
<td><a target="_blank" title="Memcached latest" href="https://github.com/docker-library/memcached">latest</a></td>
<td></td>
</tr>
</tbody>
</table>
### Run different versions
#### Enter the container
Every single attachable container comes with many different versions (see **[runtime-matrix](#run-time-matrix)** below). In order to select the desired version for a container, simply edit the `.env` file and uncomment the version of choice.
The following example shows how to set Memcached to version `1.4.28`:
```shell
$ vim .env
...
#MEMCD_SERVER=1.4.21
#MEMCD_SERVER=1.4.22
#MEMCD_SERVER=1.4.23
#MEMCD_SERVER=1.4.24
#MEMCD_SERVER=1.4.25
#MEMCD_SERVER=1.4.26
#MEMCD_SERVER=1.4.27
MEMCD_SERVER=1.4.28
#MEMCD_SERVER=1.4.29
#MEMCD_SERVER=1.4.30
#MEMCD_SERVER=1.4.31
#MEMCD_SERVER=1.4.32
#MEMCD_SERVER=1.4.33
#MEMCD_SERVER=1.4.34
#MEMCD_SERVER=1.4.35
#MEMCD_SERVER=1.4.36
#MEMCD_SERVER=latest
```
### Enter the container
You can also work directly inside the php container if you need to run tools such as `drush`, `drupal-console`, `composer`, `node` etc. Simply use the prepared scripts in the base directory to enter (`PS1` will be populated with current chosen php version):
You can also work directly inside the php container. Simply use the bundled scripts `bash.sh` or `root_bash.sh`. The `PS1` will automatically be populated with current chosen php version.
```shell
# Enter as user devilbox (normal operation / development)
$ ./bash.sh
host> ./bash.sh
devilbox@php-7.0.19 in /shared/httpd $
```
```shell
# Enter as root user (do root stuff)
$ ./root_bash.sh
host> ./root_bash.sh
root@php-7.0.19 in /shared/httpd $
```
Your projects can be found in `/shared/httpd` (This is also the place you will land once entered). DNS records are automatically available inside the php container. Also every other service will be available on `127.0.0.1` inside the php container (tricky socat port-forwarding).
Your projects can be found in `/shared/httpd`. DNS records are automatically available inside the php container. Also every other service will be available on `127.0.0.1` inside the php container (tricky socat port-forwarding).
## Feature overview
The devilbox has everything setup for you. The only thing you will have to install is `docker` and `docker-compose`. Virtual hosts and DNS entries will be created automatically, just by adding new project folders.
#### Features
* **Mass virtual host**
* **Custom domains** (`*.loc`, `*.local`, `*.dev`, ...)
* **Auto-DNS** (Internal Bind server running)
* **Email catch-all** (Internal postfix with catch-all)
* **Log files** (available on host computer)
* **Config overwrites** (`my.cnf`, `nginx.conf`, `httpd.conf` or `php.ini`)
* **Tools** (git, composer, node, npm, drush, drupal-console, ...)
* **Self-validation** (projects and configured options are validated and marked in the intranet)
* **Xdebug**
**Batteries included:**
#### Batteries
* [phpMyAdmin](https://www.phpmyadmin.net)
* [Adminer](https://www.adminer.org)
* [OpcacheGUI](https://github.com/PeeHaa/OpCacheGUI)
* Mail viewer
#### Tools
| tool | binary |
|----------------|---------|
| [composer](https://getcomposer.org) | `composer` |
| [drupal-console](https://drupalconsole.com) | `drupal` |
| [drush](http://www.drush.org) | `drush` |
| [git](https://git-scm.com) | `git` |
| [laravel installer](https://github.com/laravel/installer) | `laravel` |
| [mysqldump-secure](https://mysqldump-secure.org) | `mysqldump-secure` |
| [node](https://nodejs.org) | `node` |
| [npm](https://www.npmjs.com) | `npm` |
| [phalcon-devtools](https://github.com/phalcon/phalcon-devtools) | `phalcon` |
| [symfony installer](https://github.com/symfony/symfony-installer) | `symfony` |
| [wp-cli](https://wp-cli.org) | `wp` |
Require additional tools? Have a look at [Hacking](docs/Hacking.md) for information about how to add your own tools or open up an issue with a new tool request.
#### PHP Modules
The devilbox is a development stack, so it is made sure that a lot of PHP modules are available out of the box in order to work with many different frameworks.
*apc, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, intl, json, ldap, libxml, magickwand, mbstring, mcrypt, memcache, memcached, mhash, mongodb, msgpack, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib*
## Documentation
### Video Tutorials
#### Video Tutorials
To get you started quickly, lean back and watch the following videos on Youtube.
[![Devilbox setup and workflow](docs/img/devilbox_01-setup-and-workflow.png "devilbox - setup and workflow")](https://www.youtube.com/watch?v=reyZMyt2Zzo)
[![Devilbox email catch-all](docs/img/devilbox_02-email-catch-all.png "devilbox - email catch-all")](https://www.youtube.com/watch?v=e-U-C5WhxGY)
### Documentation
#### Documentation explained
For setup, usage and examples see detailed **[Documentation](docs/README.md)**.
The devilbox documentation consists of the following main sections.
| Documentaion | Description |
|----------------------------------|-------------|
| [Overview](docs/README.md) | General overview |
| [Quickstart](docs/Quickstart.md) | Everything needed to get you started in no time |
| [Install](docs/Install.md) | Installation information for different operating systems |
| [Update](docs/Update.md) | Update strategies |
| [Configure](docs/Configure.md) | How to configure the devilbox and its services |
| [Run](docs/Run.md) | Explanation of different required docker-compose run commands |
| [Usage](docs/Usage.md) | How to use the devilbox in detail |
| [OS](docs/OS.md) | Operating system specific information |
| [Backups](docs/Backups.md) | How to backup and restore various databases |
| [Examples](docs/Examples.md) | How to setup different frameworks: drupal, Yii, Symfony, Phalcon, Wordpress... |
| [Technical](docs/Technical.md) | Technical background information |
| [Hacking](docs/Hacking.md) | Hack the devilbox and integrate custom stuff |
| [FAQ](docs/FAQ.md) | Frequently asked questions |
#### Documentation
1. **[Overview](docs/README.md)**
1. [Main idea](docs/README.md#1-main-idea)
2. [Features](docs/README.md#2-features)
3. [Supported Host OS](docs/README.md#3-supported-host-os)
4. [Requirements](docs/README.md#4-requirements)
5. [Docker documentation](docs/README.md#5-docker-documentation)
6. [Devilbox documentation](docs/README.md#6-devilbox-documentation)
7. [Video Tutorials](docs/README.md#7-video-tutorials)
8. [Available PHP Modules](docs/README.md#8-available-php-modules)
9. [Supported Frameworks and CMS](docs/README.md#9-supported-frameworks-and-cms)
2. **[Quickstart](docs/Quickstart.md)**
1. [Installation](docs/Quickstart.md#1-installation)
2. [Update](docs/Quickstart.md#2-update)
3. [Configuration](docs/Quickstart.md#3-configuration)
4. [Run](docs/Quickstart.md#4-run)
5. [Project setup](docs/Quickstart.md#5-project-setup)
6. [Enter the PHP Docker container](docs/Quickstart.md#6-enter-the-php-docker-container)
3. **[Install](docs/Install.md)**
1. [Install Docker](docs/Install.md#1-install-docker)
1. [Linux](docs/Install.md#1-1-linux)
2. [Windows](docs/Install.md#1-2-windows)
3. [OSX](docs/Install.md#1-3-osx)
2. [Install Devilbox](#2-install-devilbox)
4. **[Update](docs/Update.md)**
1. [TL;DR](docs/Update.md#1-tl-dr)
2. [Git tag vs master branch](docs/Update.md#2-git-tag-vs-master-branch)
3. [Compare .env file](docs/Update.md#3-compare-env-file)
4. [Pull new Docker container (Important!)](docs/Update.md#4-pull-new-docker-container-important-)
5. [Remove anonymous volumes](docs/Update.md#5-remove-anonymous-volumes)
5. **[Configure](docs/Configure.md)**
1. [Overview](docs/Configure.md#1-overview)
2. [Devilbox general settings](docs/Configure.md#2-devilbox-general-settings)
3. [Project settings](docs/Configure.md#3-project-settings)
4. [Container settings](docs/Configure.md#4-container-settings)
5. [Intranet settings](docs/Configure.md#5-intranet-settings)
6. [Host computer](docs/Configure.md#6-host-computer)
6. **[Run](docs/Run.md)**
1. [Start the devilbox](docs/Run.md#1-start-the-devilbox)
2. [Stop the devilbox](docs/Run.md#2-stop-the-devilbox)
3. [Attach/Detach during run-time](docs/Run.md#3-attach-detach-during-run-time)
4. [Docker logs](docs/Run.md#4-docker-logs)
7. **[Usage](docs/Usage.md)**
1. [Mounted directories](docs/Usage.md#1-mounted-directories)
2. [Work on the Docker host](docs/Usage.md#2-work-on-the-docker-host)
3. [Work inside the PHP container](docs/Usage.md#3-work-inside-the-php-container)
4. [Managing Projects explained](docs/Usage.md#4-managing-projects-explained)
5. [Creating new Projects](docs/Usage.md#5-creating-new-projetcs)
6. [Switching container versions](docs/Usage.md#6-switching-container-versions)
7. [Emails](docs/Usage.md#7-emails)
8. [Log files](docs/Usage.md#8-log-files)
9. [Intranet](docs/Usage.md#9-intranet)
8. **[OS](docs/OS.md)**
1. [Linux](docs/OS.md#1-linux)
2. [Windows](docs/OS.md#2-windows)
3. [OSX](docs/OS.md#3-osx)
9. **[Backups](docs/Backups.md)**
1. [Info](docs/Backups.md#1-info)
2. [MySQL](docs/Backups.md#2-mysql)
1. [MySQL Database Backup](docs/Backups.md#2-1-mysql-database-backup)
2. [MySQL Database Restore](docs/Backups.md#2-2-mysql-database-restore)
3. [PostgreSQL](docs/Backups.md#3-postgresql)
1. [PostgreSQL Database Backup](docs/Backups.md#3-1-postgresql-database-backup)
2. [PostgreSQL Database Restore](docs/Backups.md#3-1-postgresql-database-restore)
4. [MongoDB](docs/Backups.md#4-mongodb)
1. [MongoDB Database Backup](docs/Backups.md#4-1-mongodb-database-backup)
2. [MongoDB Database Restore](docs/Backups.md#4-1-mongodb-database-restore)
10. **[Examples](docs/Examples.md)**
1. [Introduction](docs/Examples.md#1-introduction)
2. [Setup CakePHP](docs/Examples.md#2-setup-cakephp)
3. [Setup Drupal](docs/Examples.md#3-setup-drupal)
4. [Setup Phalcon](docs/Examples.md#4-setup-phalcon)
5. [Setup Symfony](docs/Examples.md#5-setup-symfony)
6. [Setup Wordpress](docs/Examples.md#6-setup-wordpress)
7. [Setup Yii](docs/Examples.md#7-setup-yii)
8. [Setup Zend](docs/Examples.md#8-setup-zend)
11. **[Technical](docs/Technical.md)**
1. [Networking](docs/Technical.md#1-networking)
2. [Ports and forwarding](docs/Technical.md#2-ports-and-forwarding)
3. [Works the same on Host and PHP Container](docs/Technical.md#3-works-the-same-on-host-and-php-container)
12. **[Hacking](docs/Hacking.md)**
1. [Rebuilding bundled Docker container](docs/Hacking.md#1-rebuilding-bundled-docker-container)
2. [Customizing the bundled Docker container](docs/Hacking.md#2-customizing-the-bundled-docker-container)
3. [Adding your own Docker container](docs/Hacking.md#3-adding-your-own-docker-container)
13. **[FAQ](docs/FAQ.md)**
| Documentaion | Description |
|---------------------------------------|-------------|
| [Overview](docs/README.md) | General overview |
| [Configuration](docs/Configuration.md) | How to configure the devilbox |
| [Usage](docs/Usage.md) | How to use the devilbox |
| [Updating](docs/Updating.md) | How to update |
| [Info](docs/Info.md) | Technical information |
| [PHP Projects](docs/PHP_Projects.md) | How to manage projects |
| [Emails](docs/Emails.md) | How email catching works |
| [Logs](docs/Logs.md) | How to view log files |
| [Intranet](docs/Intranet.md) | The built-in intranet |
| [FAQ](docs/FAQ.md) | Frequently asked questions |
## Run-time Matrix
Select your prefered version. (By editing the **`.env`** file)
The main idea of the devilbox is to selectively run and combine any version you require for your currently desired development stack. Services are grouped into different stacks, currently into **Base**, **SQL** and **NoSQL**. However there are many more to come. If you find yourself in need of a stack or service that is not yet inluded, just open up an issue or pull request.
No need to install and configure different versions locally. Simply choose your required LAMP/LEMP stack versions during startup and it is up and running instantly.
In order to make sure every combination works with each other, the devilbox integrates extensive CI tests for the Docker container itself and their combinations. The following tables show the available stacks including git repositories and travis-ci checks.
#### 1/3 Base stack (required)
<sub>**Note:** Entries without links or without build-status are planned, but not yet available. See [ROADMAP](https://github.com/cytopia/devilbox/issues/23) for tasks and upcoming features.</sub>
#### Base stack (required)
| DNS | Webserver | PHP |
|-----|-----------|-----|
@ -174,9 +341,7 @@ No need to install and configure different versions locally. Simply choose your
| | | [![Build Status](https://travis-ci.org/cytopia/docker-php-fpm-7.1.svg?branch=master)](https://travis-ci.org/cytopia/docker-php-fpm-7.1) [PHP 7.1](https://github.com/cytopia/docker-php-fpm-7.1) |
| | | [![Build Status](https://travis-ci.org/cytopia/docker-hhvm-latest.svg?branch=master)](https://travis-ci.org/cytopia/docker-hhvm-latest) [HHVM latest](https://github.com/cytopia/docker-hhvm-latest)
<sub>**Note:** Entries without links or without build-status are planned, but not yet available. See [ROADMAP](https://github.com/cytopia/devilbox/issues/23) for tasks and upcoming features.</sub>
#### 2/3 SQL stack (optional)
#### SQL stack (optional)
| MySQL | PostgreSQL | MS SQL |
|-------|------------|--------|
@ -190,9 +355,7 @@ No need to install and configure different versions locally. Simply choose your
| [![Build Status](https://travis-ci.org/cytopia/docker-mariadb-10.2.svg?branch=master)](https://travis-ci.org/cytopia/docker-mariadb-10.2) [MariaDB 10.2](https://github.com/cytopia/docker-mariadb-10.2) | | |
| [![Build Status](https://travis-ci.org/cytopia/docker-mariadb-10.3.svg?branch=master)](https://travis-ci.org/cytopia/docker-mariadb-10.3) [MariaDB 10.3](https://github.com/cytopia/docker-mariadb-10.3) | | |
<sub>**Note:** Entries without links or without build-status are planned, but not yet available. See [ROADMAP](https://github.com/cytopia/devilbox/issues/23) for tasks and upcoming features.</sub>
#### 3/3 NoSQL stack (optional)
#### NoSQL stack (optional)
| Cassandra | CouchDB | Memcached | MongoDB | Redis |
|-----------|---------|-----------|---------|-------|
@ -202,10 +365,8 @@ No need to install and configure different versions locally. Simply choose your
| | | | [![build Status](https://travis-ci.org/docker-library/mongo.svg?branch=master)](https://travis-ci.org/docker-library/mongo) [3.4](https://github.com/docker-library/mongo) | |
| | | | [![build Status](https://travis-ci.org/docker-library/mongo.svg?branch=master)](https://travis-ci.org/docker-library/mongo) [3.5](https://github.com/docker-library/mongo) | |
<sub>**Note:** Entries without links or without build-status are planned, but not yet available. See [ROADMAP](https://github.com/cytopia/devilbox/issues/23) for tasks and upcoming features.</sub>
<!--
#### Message stack (optional)
**Optional search stack**
| Apache Solr | Elasticsearch |
@ -221,14 +382,6 @@ No need to install and configure different versions locally. Simply choose your
-->
<!--
## Documentation
* Configuration
* Xdebug
-->
## Intranet overview
The devilbox comes with a pre-configured intranet on `http://localhost`. It will not only show you, your chosen configuration, but also validate the status of your configuration, such as *Do DNS records exists (on host and container)*, *are directories properly set-up*. Additionally it provides external tools to let you interact with databases and emails.
@ -244,7 +397,7 @@ The devilbox comes with a pre-configured intranet on `http://localhost`. It will
## Screenshots
### Homepage with host / docker information
#### Homepage with host / docker information
The homepage shows you the status of your current configured setup.
@ -256,8 +409,7 @@ The homepage shows you the status of your current configured setup.
![Intranet Home](docs/img/01_intranet_home.png "Intranet Home")
### Virtual Host overview
#### Virtual Host overview
This overview shows you all available virtual hosts and if they need additional configuration (on the host)
@ -268,14 +420,13 @@ Virtual Hosts are considered valid if the following requirements are met (on the
![Intranet vHost](docs/img/02_intranet_vhosts.png "Intranet Home")
### Database overview
#### Database overview
Shows you all the databases that are loaded
![Intranet DB](docs/img/03_intranet_databases.png "Intranet Home")
### Email overview
#### Email overview
Shows you all the emails that have been sent. No email will actually be sent outside, but they are all catched by one account and presented here.

View File

@ -0,0 +1,24 @@
; Use PHP 5.6 or PHP 7 mode for HHVM
; PHP 5.6 Mode
hhvm.php7.all = 0
; PHP 7 Mode (default)
;hhvm.php7.all = 1
[PHP]
; Memory
memory_limit = 4096M
; Timeouts
max_execution_time = 180
max_input_time = 180
; Uploads
post_max_size = 1990M
upload_max_filesize = 1990M
; Vars
max_input_vars = 8000
; Error reporting
error_reporting = E_ALL
display_errors = On
track_errors = On

View File

@ -0,0 +1,5 @@
[mysqld]
;key_buffer_size=16M
[mysqldump]
;quick

View File

@ -0,0 +1,5 @@
[mysqld]
;key_buffer_size=16M
[mysqldump]
;quick

View File

@ -0,0 +1,5 @@
[mysqld]
;key_buffer_size=16M
[mysqldump]
;quick

View File

@ -0,0 +1,5 @@
[mysqld]
;key_buffer_size=16M
[mysqldump]
;quick

View File

@ -1,5 +0,0 @@
# User-defined MySQL configuration
Add as many `*.cnf` files here as you wish.
Files not ending with `*.cnf` will not be picked up during startup.

View File

@ -0,0 +1,5 @@
[mysqld]
;key_buffer_size=16M
[mysqldump]
;quick

View File

@ -1,3 +0,0 @@
[mysqld]
slow_query_log = 1
log_queries_not_using_indexes = 1

View File

@ -0,0 +1,5 @@
[mysqld]
;key_buffer_size=16M
[mysqldump]
;quick

View File

@ -0,0 +1,5 @@
[mysqld]
;key_buffer_size=16M
[mysqldump]
;quick

View File

@ -0,0 +1,5 @@
[mysqld]
;key_buffer_size=16M
[mysqldump]
;quick

View File

@ -0,0 +1,18 @@
[PHP]
; Memory
memory_limit = 4096M
; Timeouts
max_execution_time = 180
max_input_time = 180
; Uploads
post_max_size = 1990M
upload_max_filesize = 1990M
; Vars
max_input_vars = 8000
; Error reporting
error_reporting = E_ALL
display_errors = On
track_errors = On

View File

@ -0,0 +1,18 @@
[PHP]
; Memory
memory_limit = 4096M
; Timeouts
max_execution_time = 180
max_input_time = 180
; Uploads
post_max_size = 1990M
upload_max_filesize = 1990M
; Vars
max_input_vars = 8000
; Error reporting
error_reporting = E_ALL
display_errors = On
track_errors = On

View File

@ -0,0 +1,18 @@
[PHP]
; Memory
memory_limit = 4096M
; Timeouts
max_execution_time = 180
max_input_time = 180
; Uploads
post_max_size = 1990M
upload_max_filesize = 1990M
; Vars
max_input_vars = 8000
; Error reporting
error_reporting = E_ALL
display_errors = On
track_errors = On

View File

@ -0,0 +1,18 @@
[PHP]
; Memory
memory_limit = 4096M
; Timeouts
max_execution_time = 180
max_input_time = 180
; Uploads
post_max_size = 1990M
upload_max_filesize = 1990M
; Vars
max_input_vars = 8000
; Error reporting
error_reporting = E_ALL
display_errors = On
track_errors = On

View File

@ -36,8 +36,8 @@ services:
restart: always
ports:
# [local-machine:]local-port:docker-port
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_BIND}:53"
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_BIND}/udp:53/udp"
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_BIND:-1053}:53"
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_BIND:-1053}:53/udp"
environment:
##
@ -65,7 +65,7 @@ services:
# ----------------------------------------
php:
#image: cytopia/${PHP_SERVER:-php-fpm-7.0}:latest
image: cytopia/${PHP_SERVER:-php-fpm-7.0}:0.10
image: cytopia/${PHP_SERVER:-php-fpm-7.0}:0.11
restart: always
# Manually build via `docker-compose build`
@ -114,6 +114,13 @@ services:
##
- FORWARD_PORTS_TO_LOCALHOST=3306:mysql:3306,5432:pgsql:5432,6379:redis:6379,11211:memcd:11211,27017:mongo:27017
##
## MySQL Backups
##
- MYSQL_BACKUP_USER=root
- MYSQL_BACKUP_PASS=${MYSQL_ROOT_PASSWORD}
- MYSQL_BACKUP_HOST=mysql
##
## Additional variables to announce to intranet/php-container
##
@ -167,6 +174,9 @@ services:
# Mount Mail directory
#- ${DEVILBOX_PATH}/run/mail:/var/mail
# Mount DB Backup directory
- ${DEVILBOX_PATH}/backups:/shared/backups
# Mount devilbox user-defined *.ini files in order
# to overwrite the default PHP configuration
- ${DEVILBOX_PATH}/cfg/${PHP_SERVER}:/etc/php-custom.d:ro
@ -439,8 +449,8 @@ services:
# ---- Format: ----
# HOST-DIRECTORY : DOCKER-DIRECTORY
# Mount MySQL Data directory
- ${HOST_PATH_MONGO_DATADIR}:/data/db
# Mount MongoDB Data directory
- ${HOST_PATH_MONGO_DATADIR}/${MONGO_SERVER}:/data/db
depends_on:
- bind

374
docs/Backups.md Normal file
View File

@ -0,0 +1,374 @@
# Devilbox Documentation
[Overview](README.md) |
[Quickstart](Quickstart.md) |
[Install](Install.md) |
[Update](Update.md) |
[Configure](Configure.md) |
[Run](Run.md) |
[Usage](Usage.md) |
[OS](OS.md) |
Backups |
[Examples](Examples.md) |
[Technical](Technical.md) |
[Hacking](Hacking.md) |
[FAQ](FAQ.md)
---
## Backups
1. [Info](#1-info)
2. [MySQL](#2-mysql)
1. [MySQL Database Backup](#2-1-mysql-database-backup)
1. [mysqldump-secure](#2-1-1-mysqldump-secure)
2. [mysqldump](#2-1-2-mysqldump)
3. [phpMyAdmin](#2-1-3-phpmyadmin)
4. [Adminer](#2-1-4-adminer)
2. [MySQL Database Restore](#2-2-mysql-database-restore)
1. [mysql](#2-2-1-mysql)
2. [phpMyAdmin](#2-2-2-phpmyadmin)
3. [Adminer](#2-2-3-adminer)
3. [PostgreSQL](#3-postgresql)
1. [PostgreSQL Database Backup](#3-1-postgresql-database-backup)
1. [pg_dump](#3-1-1-pg_dump)
2. [Adminer](#3-1-2-adminer)
2. [PostgreSQL Database Restore](#3-1-postgresql-database-restore)
1. [psql](#3-2-1-psql)
2. [Adminer](#3-2-2-adminer)
4. [MongoDB](#4-mongodb)
1. [MongoDB Database Backup](#4-1-mongodb-database-backup)
1. [mongodump](#4-1-1-mongodump)
2. [MongoDB Database Restore](#4-1-mongodb-database-restore)
1. [mongorestore](#4-2-1-mongorestore)
---
## 1. Info
Backup and restore will be necessary when you are going to change MySQL, PostgreSQL or MongoDB versions. Each version has its own data directory and different versions do not pick up the databases from another version.
**Example**
```
./data/mysql/mysql-5.5
./data/mysql/mysql-5.7
./data/mysql/mariadb-10.1
./data/pgsql/9.5
./data/pgsql/9.6
./data/mongo/3.2
./data/mongo/3.4
```
This is necessary as later MySQL, PostgreSQL and MongoDB versions will upgrade the databases making it unusable for older versions.
So before you change to a new database version you will have to make a backup and restore the backup in the new version.
If you use the devilbox bundled tools, you will find all backups in the main directory under `./backups/`.
## 2. MySQL
#### 2.1 MySQL Database Backup
There are many different options to backup your MySQL database including some for the command line and some for using the Web interface. The recommended and fastest method is to use mysqldump-secure, as it will also add info files (`*.info`) to each database recording checksums, dump date, dump options and from which version the backup come from.
##### 2.1.1 mysqldump-secure
**[mysqldump-secure](https://mysqldump-secure.org)** is bundled, setup and ready to use in every PHP/HHVM container. You can run it without any arguments and it will dump each available database as a separated compressed file. Backups will be located in `./backups/mysql/` on the Docker host or in `/shared/backups/mysql/` inside the Docker container.
```shell
# Enter the Container
host> ./bash.sh
# Start the backup
devilbox@php-7.1.6 in /shared/httpd $ mysqldump-secure
[INFO] (OPT): Logging enabled
[INFO] (OPT): MySQL SSL connection disabled
[INFO] (OPT): Compression enabled
[INFO] (OPT): Encryption disabled
[INFO] (OPT): Deletion disabled
[INFO] (OPT): Nagios log disabled
[INFO] (OPT): Info files enabled
[INFO] (SQL): 1/3 Skipping: information_schema (DB is ignored)
[INFO] (SQL): 2/3 Dumping: mysql (0.66 MB) 1 sec (0.13 MB)
[INFO] (SQL): 3/3 Skipping: performance_schema (DB is ignored)
[OK] Finished successfully
# List backups inside the container
devilbox@php-7.1.6 in /shared/httpd $ ls -l /shared/backups/mysql/
-rw-r--r-- 1 devilbox 136751 Jun 17 13:31 2017-06-17_13-31__mysql.sql.gz
-rw-r--r-- 1 devilbox 2269 Jun 17 13:31 2017-06-17_13-31__mysql.sql.gz.info
# Quit the docker container
devilbox@php-7.1.6 in /shared/httpd $ exit
# List backups on your hostsystem (from devilbox root directory)
host> ls -l backups/mysql/
-rw-r--r-- 1 cytopia 136751 Jun 17 13:31 2017-06-17_13-31__mysql.sql.gz
-rw-r--r-- 1 cytopia 2269 Jun 17 13:31 2017-06-17_13-31__mysql.sql.gz.info
```
The `*.info` file will hold many useful information in case you need to debug any problems occured during backups.
```shell
$ cat ./backups/mysql/2017-06-17_13-31__mysql.sql.gz.info
```
```ini
; mysqldump-secure backup record
; Do not alter this file!
; Creation of this file can be turned off via config file.
; ============================================================
; = Local system information
; ============================================================
[mysqldump-secure]
version = /usr/local/bin/mysqldump-secure (0.16.3)
vdate = 2016-08-18
config = /etc/mysqldump-secure.conf
[system]
uname = Linux 4.4.0-79-generic
hostname =
user = devilbox
group = devilbox
[tools]
mysqldump = /usr/bin/mysqldump (10.14 Distrib 5.5.52-MariaDB) [for Linux (x86_64)]
mysql = /usr/bin/mysql (15.1 Distrib 5.5.52-MariaDB) [for Linux (x86_64) using readline 5.1]
compressor = /usr/bin/gzip (gzip 1.5)
encryptor = Not used
; ============================================================
; = Database / File information
; ============================================================
[database]
db_name = mysql
db_size = 687326 Bytes (0.66 MB)
tbl_cnt = 30
[file]
file_path = /shared/backups/mysql
file_name = 2017-06-17_13-31__mysql.sql.gz
file_size = 136751 Bytes (0.13 MB)
file_chmod = 0644
file_owner = devilbox
file_group = devilbox
file_mtime = 1497699116 (2017-06-17 13:31:56 CEST [+0200])
file_md5 = 8d1a6c38f81c691bc4b490e7024a4f72
file_sha = 11fb85282ea866dfc69d29dc02a0418bebfea30e7e566c3c588a50987aceac2f
; ============================================================
; = Dump procedure information
; ============================================================
[mysqldump]
encrypted = 0
compressed = 1
arguments = --opt --default-character-set=utf8 --events --triggers --routines --hex-blob --complete-insert --extended-insert --compress --lock-tables --skip-quick
duration = 1 sec
[compression]
compressor = gzip
arguments = -9 --stdout
[encryption]
encryptor =
algorithm =
pubkey =
; ============================================================
; = Server information
; ============================================================
[connection]
protocol = mysql via TCP/IP
secured = No SSL
arguments = --defaults-file=/etc/mysqldump-secure.cnf
[server]
hostname = 001b3750b549
port = 3306
replica = master
version = MariaDB 10.1.23-MariaDB MariaDB Server
```
You can alternatively also execute it directly from your host computer. For that to work, you must be inside the devilbox root directory.
```shell
$ docker-compose exec --user devilbox php mysqldump-secure
```
To find out more about the configuration and options of mysqldump-secure, visit its project page under: [https://mysqldump-secure.org](https://mysqldump-secure.org).
##### 2.1.2 mysqldump
**[mysqldump](https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html)** is bundled with each PHP/HHVM container and ready to use. To backup a database named `my_db_name` follow the below listed example:
```shell
# Enter the Container
host> ./bash.sh
# Start the backup
devilbox@php-7.1.6 in /shared/httpd $ mysqldump -h mysql -u root -p my_db_name > /shared/backups/mysql/my_db_name.sql
```
To find out more about the configuration and options of mysqldump, visit its project page under: [https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html](https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html).
##### 2.1.3 phpMyAdmin
If you do not like to use the command line for backups, you can use **[phpMyAdmin](https://www.phpmyadmin.net)**. It comes bundled with the devilbox intranet. View [Usage](Usage.md) to read more about the devilbox intranet.
To find out more about the usage of phpMyAdmin, visit its project page under: [https://www.phpmyadmin.net](https://www.phpmyadmin.net).
##### 2.1.4 Adminer
If you do not like to use the command line for backups, you can use **[Adminer](https://www.adminer.org)**. It comes bundled with the devilbox intranet. View [Usage](Usage.md) to read more about the devilbox intranet.
To find out more about the usage of Adminer, visit its project page under: [https://www.adminer.org](https://www.adminer.org).
#### 2.2 MySQL Database Restore
##### 2.2.1 mysql
In order to restore or import mysql databases on the command line, you need to use `mysql`. Here are a few examples for different file types:
###### 2.2.1.1 `*.sql` files
```shell
# Enter the Container
host> ./bash.sh
# Start the import
devilbox@php-7.1.6 in /shared/httpd $ mysql -h mysql -u root -p my_db_name < /shared/backups/mysql/my_db_name.sql
```
###### 2.2.1.2 `*.sql.gz` files
```shell
# Enter the Container
host> ./bash.sh
# Start the import
devilbox@php-7.1.6 in /shared/httpd $ zcat /shared/backups/mysql/my_db_name.sql.gz | mysql -h mysql -u root -p my_db_name
```
###### 2.2.1.3 `*.sql.tar.gz` files
```shell
# Enter the Container
host> ./bash.sh
# Start the import
devilbox@php-7.1.6 in /shared/httpd $ tar xzOf /shared/backups/mysql/my_db_name.sql.tar.gz | mysql -h mysql -u root -p my_db_name
```
##### 2.2.2 phpMyAdmin
**[phpMyAdmin](https://www.phpmyadmin.net)** supports importing of many different formats out-of-the-box. Simply select the compressed or uncompressed file and press `Go` in the Web interface.
##### 2.2.3 Adminer
**[Adminer](https://www.adminer.org)** supports importing of plain (`*.sql`) or gzipped compressed (`*.sql.gz`) files out-of-the-box. Simply select the compressed or uncompressed file and press `Execute` in the Web interface.
## 3. PostgreSQL
#### 3.1 PostgreSQL Database Backup
##### 3.1.1 pg_dump
**[pg_dump](https://www.postgresql.org/docs/current/static/backup-dump.html)** is bundled with each PHP/HHVM container and ready to use. To backup a database named `my_db_name` follow the below listed example:
```shell
# Enter the Container
host> ./bash.sh
# Start the import
devilbox@php-7.1.6 in /shared/httpd $ pg_dump -h pgsql -U postgres -W my_db_name > /shared/backups/pgsql/my_db_name.sql
```
To find out more about the configuration and options of pg_dump, visit its project page under: [https://www.postgresql.org/docs/current/static/backup-dump.html](https://www.postgresql.org/docs/current/static/backup-dump.html#BACKUP-DUMP).
##### 3.1.2 Adminer
If you do not like to use the command line for backups, you can use **[Adminer](https://www.adminer.org)**. It comes bundled with the devilbox intranet. View [Usage](Usage.md) to read more about the devilbox intranet.
To find out more about the usage of Adminer, visit its project page under: [https://www.adminer.org](https://www.adminer.org).
#### 3.2 PostgreSQL Database Restore
##### 3.2.1 psql
In order to restore or import PostgreSQL databases on the command line, you need to use **[psql](https://www.postgresql.org/docs/current/static/backup-dump.html#BACKUP-DUMP-RESTORE)**. Here are a few examples for different file types:
###### 3.2.1.1 `*.sql` files
```shell
# Enter the Container
host> ./bash.sh
# Start the import
devilbox@php-7.1.6 in /shared/httpd $ psql -h pgsql -U postgres -W my_db_name < /shared/backups/pgsql/my_db_name.sql
```
###### 3.2.1.2 `*.sql.gz` files
```shell
# Enter the Container
host> ./bash.sh
# Start the import
devilbox@php-7.1.6 in /shared/httpd $ zcat /shared/backups/pgsql/my_db_name.sql.gz | psql -h pgsql -U postgres -W my_db_name
```
###### 3.2.1.3 `*.sql.tar.gz` files
```shell
# Enter the Container
host> ./bash.sh
# Start the import
devilbox@php-7.1.6 in /shared/httpd $ tar xzOf /shared/backups/pgsql/my_db_name.sql.tar.gz | psql -h pgsql -U postgres -W my_db_name
```
##### 3.2.2 Adminer
**[Adminer](https://www.adminer.org)** supports importing of plain (`*.sql`) or gzipped compressed (`*.sql.gz`) files out-of-the-box. Simply select the compressed or uncompressed file and press `Execute` in the Web interface.
## 4. MongoDB
#### 4.1 MongoDB Database Backup
##### 4.1.1 mongodump
**[mongodump](https://docs.mongodb.com/manual/reference/program/mongodump/)** is bundled with each PHP/HHVM container and ready to use. To backup all MongoDB databases follow the below listed example:
```shell
# Enter the Container
host> ./bash.sh
# Start the dump into /shared/backups/mongo
devilbox@php-7.1.6 in /shared/httpd $ mongodump --out /shared/backups/mongo
```
To find out more about the configuration and options of mongodump, visit its project page under: [https://docs.mongodb.com/manual/reference/program/mongodump/](https://docs.mongodb.com/manual/reference/program/mongodump/).
#### 4.2 MongoDB Database Restore
##### 4.2.1 mongorestore
**[mongorestore](https://docs.mongodb.com/manual/reference/program/mongorestore/)** is bundled with each PHP/HHVM container and ready to use. To restore all MongoDB databases follow the below listed example:
```shell
# Enter the Container
host> ./bash.sh
# Start the restore/import from /shared/backups/mongo
devilbox@php-7.1.6 in /shared/httpd $ mongorestore /shared/backups/mongo
```
To find out more about the configuration and options of mongorestore, visit its project page under: [https://docs.mongodb.com/manual/reference/program/mongorestore/](https://docs.mongodb.com/manual/reference/program/mongorestore/).

View File

@ -1 +0,0 @@
devilbox.org

View File

@ -1,114 +0,0 @@
# Devilbox Documentation
[Home](https://github.com/cytopia/devilbox) |
[Overview](README.md) |
Configuration |
[Usage](Usage.md) |
[Updating](Updating.md) |
[Info](Info.md) |
[PHP Projects](PHP_Projects.md) |
[Emails](Emails.md) |
[Logs](Logs.md) |
[Intranet](Intranet.md) |
[FAQ](FAQ.md)
----
## Configuration
### 1. The `.env` file
All docker-compose configuration is done inside the `.env` file which simply defines key-value variables parsed to `docker-compose.yml`.
First thing to do after cloning this repository is creating this file from the `env-example`.
```shell
$ cp env-example .env
```
The file itself is well commented and should explain itself. In case anything is unclear leave an issue at GitHub.
> [What is the `.env` file?](https://docs.docker.com/compose/env-file/)
There are a few sections you should be aware off to better understand how it all works.
#### 1.1 Selecting service versions
Each service has a `<SERVICE_NAME>_SERVER` variable with a corresponding version. All existing versions are present in the file and commented out.
It is important to leave at least one version uncomment, otherwise the start-up will lead to errors. Use the following variable to control which version will be loaded:
* **`PHP_SERVER`**
* **`HTTPD_SERVER`**
* **`MYSQL_SERVER`**
* **`PGSQL_SERVER`**
* **`REDIS_SERVER`**
* **`MEMCD_SERVER`**
#### 1.2 Data directories
There are a few pre-configured data directories to make storage persistent across container restarts:
* *`HOST_PATH_HTTPD_DATADIR`*
* *`HOST_PATH_MYSQL_DATADIR`*
* *`HOST_PATH_PGSQL_DATADIR`*
The values by default point to relative directories inside the devilbox repository. You can however also point them to different locations (relative or absolute)
MySQL and PgSQL data directories will also append their version as a subfolder to the data directories in order to prevent database file corruptions due to different versions and possible incompatabilities between them.
If you have a MySQL database on your host computer with the same version that your docker container is using, you can also interchangeably use the data dir with you host MySQL version and vice-versa.
### 2. The `cfg/` directory
Inside the devilbox root directory you will find a foder called `cfg/`. This will contain subdirectories in the form of `<SERVICE>-<VERSION>`.
Those folders will be mounted into the appropriate location into the respective docker container in order to overwrite service configuration.
Currently only MySQL/MariaDB and PHP/HHVM overrides are supported.
The folder structure looks like this:
```
cfg/
hhvm-latest/
mariadb-10.0/
mariadb-10.1/
mariadb-10.2/
mariadb-10.3/
mariadb-5.5/
mysql-5.5/
mysql-5.6/
mysql-5.7/
mysql-8.0/
php-fpm-5.4/
php-fpm-5.5/
php-fpm-5.6/
php-fpm-7.0/
php-fpm-7.1/
```
Each of the folders will contain an example file in the following format:
```
devilbox-custom.<ext>-example
```
Only files which have the correct file extensions will be read, all others such as `*.<ext>-example` will be ignored.
#### 2.1 Adding PHP options
---
### Hints
**A. Can I not just comment out the service in the `.env` file?**
No, don't do this. This will lead to unexpected behaviour (different versions will be loaded).
The `.env` file allows you to configure the devilbox, but not to start services selectively. At least one version per service must be defined.
**B. I don't want to start all container. How would I do this?**
Head over to the **[Usage](Usage.md)** section to get an in-depth explanation about how to start services selectively.

725
docs/Configure.md Normal file
View File

@ -0,0 +1,725 @@
# Devilbox Documentation
[Overview](README.md) |
[Quickstart](Quickstart.md) |
[Install](Install.md) |
[Update](Update.md) |
Configure |
[Run](Run.md) |
[Usage](Usage.md) |
[OS](OS.md) |
[Backups](Backups.md) |
[Examples](Examples.md) |
[Technical](Technical.md) |
[Hacking](Hacking.md) |
[FAQ](FAQ.md)
---
## Configure
1. [Overview](#1-overview)
1. [The devilbox `.env` file](#1-1-the-devilbox-env-file)
2. [The devilbox `cfg/` directory](#1-2-the-devilbox-cfg-directory)
3. [The operating system `hosts` file](#1-3-the-operating-system-hosts-file)
4. [The operating system `resolv.conf` file](#1-4-the-operating-system-resolv-conf-file)
2. [Devilbox general settings](#2-devilbox-general-settings)
1. [Verbosity](#2-1-verbosity)
2. [Devilbox base path](#2-2-devilbox-base-path)
3. [Host computer listening address](#2-3-host-computer-listening-address)
3. [Project settings](#3-project-settings)
1. [Project domain](#3-1-project-domain)
2. [Project path](#3-2-project-path)
4. [Container settings](#4-container-settings)
1. [General](#4-1-general)
1. [Timezone](#4-1-1-timezone)
2. [User id](#4-1-1-user-id)
3. [Group id](#4-1-2-group-id)
2. [PHP / HHVM](#4-2-php-hhvm)
1. [Select PHP version](#4-2-1-select-php-version)
2. [Xdebug](#4-2-2-xdebug)
3. [php.ini](#4-2-3-php-ini)
4. [HHVM](#4-2-4-hhvm)
3. [Apache / Nginx](#4-3-apache-nginx)
1. [Select Httpd version](#4-3-1-select-httpd-version)
2. [Host port](#4-3-2-host-port)
4. [MySQL](#4-4-mysql)
1. [Select MySQL version](#4-4-1-select-mysql-version)
2. [Root password](#4-4-2-root-password)
3. [General Log](#4-4-3-general-log)
4. [Host port](#4-4-4-host-port)
5. [Data path](#4-4-5-data-path)
6. [my.cnf](#4-4-6-my-cnf)
5. [PostgreSQL](#4-5-postgresql)
1. [Select PostgreSQL version](#4-5-1-select-postgresql-version)
2. [Root user](#4-5-2-root-user)
3. [Root password](#4-5-3-root-password)
4. [Host port](#4-5-4-host-port)
5. [Data path](#4-5-5-data-path)
6. [Redis](#4-6-redis)
1. [Select Redis version](#4-6-1-select-redis-version)
2. [Host port](#4-6-2-host-port)
7. [Memcached](#4-7-memcached)
1. [Select Memcached version](#4-7-1-select-memcached-version)
2. [Host port](#4-7-2-host-port)
8. [MongoDB](#4-8-mongodb)
1. [Select MongoDB version](#4-8-1-select-mongodb-version)
2. [Host port](#4-8-2-host-port)
3. [Data path](#4-8-3-data-path)
9. [Bind](#4-9-bind)
1. [Upstream resolver](#4-9-1-upstream-resolver)
2. [Host port](#4-9-2-host-port)
5. [Intranet settings](#5-intranet-settings)
1. [DNS check timeout](#5-1-dns-check-timeout)
6. [Host computer](#6-host-computer)
1. [/etc/hosts](#6-1-etc-hosts)
2. [Auto-DNS](#6-2-auto-dns)
---
## 1. Overview
There are only four things you can configure on your host computer.
#### 1.1 The devilbox `.env` file
All docker-compose configuration is done inside the `.env` file which simply defines key-value variables parsed to `docker-compose.yml`.
First thing to do after cloning this repository is creating this file from the `env-example`:
```shell
$ cp env-example .env
```
When you update the devilbox git directory, you should always check if `env-example` introduces new configuration options. You can do that by comparing the `env-example` file with your current `.env` file.
```shell
$ vimdiff env-example .env
```
You can get more information here:
> [What is the `.env` file?](https://docs.docker.com/compose/env-file/)
#### 1.2 The devilbox `cfg/` directory
Inside the devilbox root directory you will find a foder called `cfg/`. This will contain subdirectories in the form of `<SERVICE>-<VERSION>`. Those folders will be mounted into the appropriate location into the respective docker container in order to overwrite service configuration.
Currently only MySQL/MariaDB and PHP/HHVM overrides are supported.
The folder structure looks like this:
```
cfg/
hhvm-latest/
mariadb-10.0/
mariadb-10.1/
mariadb-10.2/
mariadb-10.3/
mariadb-5.5/
mysql-5.5/
mysql-5.6/
mysql-5.7/
mysql-8.0/
php-fpm-5.4/
php-fpm-5.5/
php-fpm-5.6/
php-fpm-7.0/
php-fpm-7.1/
php-fpm-7.2/
```
Each of the folders will contain an example file in the following format:
```
devilbox-custom.<ext>-example
```
Only files which have the correct file extensions will be read, all others such as `*.<ext>-example` will be ignored.
* Valid PHP config extension: `.ini`
* Valid MySQL config extension: `.cnf`
#### 1.3 The operating system `hosts` file
On Linux and OSX your hosts file is located at `/etc/hosts` on Windows it will be at `C:\Windows\System32\drivers\etc`. Use this file to setup custom DNS entries if you are not using Auto-DNS.
Read up on it below at `/etc/hosts` or `Auto-DNS` section.
#### 1.4 The operating system `resolv.conf` file
This file is used to add the devilbox DNS server for Auto-DNS.
Read up on it below at `/etc/hosts` or `Auto-DNS` section.
## 2. Devilbox general settings
#### 2.1 Verbosity
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| DEBUG_COMPOSE_ENTRYPOINT | `0` | Set it to `1` or `0` |
If set to `1`, it will show all executed commands during docker startup.
#### 2.2 Devilbox base path
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| DEVILBOX_PATH | `.` | Relative or absolute path allowed |
This is the base path that will be prepended to all mount paths specified in `.env`.
You will usually not need to change this value..
#### 2.3 Host computer listening address
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| LOCAL_LISTEN_ADDRESS | `127.0.0.1:` | Address for every service to listen on the Docker host.<br/>Pay attention to the **`:`** after the IP address |
This determines the Host address your webserver and all other daemons should listen on.
In case it is not `127.0.0.1` (because you are using a VirtualBox Docker setup) change it to the IP address of the VirtualBox host. Otherwise you will not need to change this value.
1. When you remove it completely, it will listen on all interfaces.
2. When you use specific address, you must add a **`:`** at the end.
You can for example change it to `0.0.0.0:` or make it empty in order to listen on all interfaces. This enables it for other people inside your network to access the devilbox. Or you can even install the devilbox on a different computer and access it remotely.
## 3. Project settings
#### 3.1 Project domain
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| TLD_SUFFIX | `loc` | Domain suffix for all your project. Can also be a subdomain such `work.loc` |
Each project will be served by `http://<project-folder>.<TLD_SUFFIX>`. If you want to change the default `loc` domain suffix to something else such as local, adjust this variable. Here are a few examples:
| Project Folder | TLD_SUFFIX | URL |
|----------------|------------|-----|
| my-cake | loc | http://my-cake.loc |
| my-cake | local | http://my-cake.local |
| my-cake | dev | http://my-cake.dev |
| my-cake | work.loc | http://my-cake.work.loc |
| test | foo | http://test.foo |
| project1 | bar | http://project1.bar |
The above examples should make it clear enough.
#### 3.2 Project path
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HOST_PATH_HTTPD_DATADIR | `./data/www` | Can be absolute or relative path. A relative path starts inside the devilbox git directory. |
This is the file system path on your host computer which will hold the Project Folders.
## 4. Container settings
#### 4.1 General
##### 4.1.1 Timezone
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| TIMEZONE | `Europe/Berlin`| Set timezone of the Docker container |
Use this variable to control the timezone of the container.
**Note:** This currently only works on the devilbox self-provided container:
* DNS
* MySQL/MariaDB
* PHP/HHVM
* Apache/Nginx
The official container do not support this setting.
##### 4.1.1 User id
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| NEW_UID | `1000`| Change the Docker containers user id (uid) |
This setting is used to change the user id of the PHP/HHVM container to the one you specify. As you will work insisde the PHP/HHVM container, you will have to set it to the same user id of your Host computers user id. It will make sure that files created inside the container have the same access permissions as outside the container.
To find out your user id, type the following on your Host system:
```shell
$ id
```
**Note:** If your Host computers user id and the containers user id do not match, files will have different access rights inside and outside which might result in permission errors like `access denied`. So make sure to set this value.
**Note:** Files created by the webserver such as uploads, tmp and cache files are still created by the webservers user id and you will probably have to `chmod` them. This issues will be addressed shortly and you will also be able to change the uid/gid of the webserver in the next devilbox release.
##### 4.1.2 Group id
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| NEW_GID | `1000`| Change the Docker containers group id (gid) |
This setting is used to change the group id of the PHP/HHVM container to the one you specify. As you will work insisde the PHP/HHVM container, you will have to set it to the same group id of your Host computers group id. It will make sure that files created inside the container have the same access permissions as outside the container.
To find out your group id, type the following on your Host system:
```shell
$ id
```
**Note:** If your Host computers group id and the containers group id do not match, files will have different access rights inside and outside which might result in permission errors like `access denied`. So make sure to set this value.
**Note:** Files created by the webserver such as uploads, tmp and cache files are still created by the webservers group id and you will probably have to `chmod` them. This issues will be addressed shortly and you will also be able to change the uid/gid of the webserver in the next devilbox release.
#### 4.2 PHP / HHVM
##### 4.2.1 Select PHP version
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| PHP_SERVER | `php-fpm-7.0`| Change the PHP Docker container |
1. Open the `.env` file in your favorite editor
2. Find the `PHP_SERVER=` block
You can choose between different PHP versions and HHVM.
**Important:** Keep in mind that if you have a custom php.ini config at `./cfg/php-*/`, it is only effective for one version. Custom php configurations are separted per version.
##### 4.2.2 Xdebug
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| PHP_XDEBUG_ENABLE | `1` | Enable Xdebug for PHP |
| PHP_XDEBUG_REMOTE_PORT | `9000` | PHP Xdebugs remote port - where your editor/IDE is receiving Xdebug data |
| PHP_XDEBUG_REMOTE_HOST | `192.168.0.215` | PHP Xdebugs remote IP address - where your editor/IDE is listening for Xdebug connections (Make sure to change this to the IP of your Docker Host |
Xdebug is turned on by default and also using the official Xdebug default port. The only thing you will have to adjust is the Xdebug remote host address so that your editor/IDE can actually receive Xdebug data.
##### 4.2.3 php.ini
`php.ini` settings can be configured for each PHP/HHVM version separately. Container-based configuration is done inside the `./cfg/` directory.
```shell
$ ls -l ./cfg/ | grep -E 'php|hhvm'
drwxrwxr-x 2 cytopia 4096 Jun 21 08:47 hhvm-latest/
drwxrwxr-x 2 cytopia 4096 Jun 21 08:43 php-fpm-5.4/
drwxrwxr-x 2 cytopia 4096 Jun 21 08:43 php-fpm-5.5/
drwxrwxr-x 2 cytopia 4096 Jun 21 08:43 php-fpm-5.6/
drwxrwxr-x 2 cytopia 4096 Jun 21 08:44 php-fpm-7.0/
drwxrwxr-x 2 cytopia 4096 Jun 21 08:44 php-fpm-7.1/
drwxrwxr-x 2 cytopia 4096 Jun 21 08:44 php-fpm-7.2/
```
Each of the above folders will hold an example configuration file named `devilbox-custom.ini-example` which shows some example settings but will **not have** any effect yet. Only files ending by **`.ini`** will be sourced and applied, so you must copy it (or create a new file) to something that ends by `*.ini`.
In order to edit settings for PHP 5.6, go into that folder, copy the example file and adjust ist:
```shell
# Copy to file ending by *.ini
$ cd cfg/php-fpm-5.6
$ cp devilbox-custom.ini-example devilbox-custom.ini
# Edit settings
$ vi devilbox-custom.ini
```
Change will take effect after restarting the devilbox.
##### 4.2.4 HHVM
HHVM can just be configured as all other PHP versions. However it has a special option to change between **PHP-5.6** mode and **PHP-7** mode. This example is addressed in `cfg/hhvm-latest/devilbox.ini-example`.
```shell
$ cat cfg/hhvm-latest/devilbox.ini-example
```
```ini
; Use PHP 5.6 or PHP 7 mode for HHVM
; PHP 5.6 Mode
;hhvm.php7.all = 0
; PHP 7 Mode (default)
;hhvm.php7.all = 1
```
By default, HHVM is using **PHP-7** mode, you can change this setting to **PHP-5.6** by enabling `hhvm.php7.all = 0`.
**Note:** You must then also copy the file to something that ends by `*.ini`.
#### 4.3 Apache / Nginx
##### 4.3.1 Select Httpd version
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HTTPD_SERVER | `nginx-stable`| Change the Httpd Docker container |
1. Open the `.env` file in your favorite editor
2. Find the `HTTPD_SERVER=` block
You can choose between Apache and Nginx in different version. All of them are configured to work the same, there is nothing to worry about when changing them.
##### 4.3.2 Host port
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HOST_PORT_HTTPD | `80`| Host computer listening port for the webserver (Apache or Nginx) |
By default the webserver will listen on port 80 (on your Host computer). You can change this to any other port (in case port 80 is already taken).
If you also want to change the listening address (default: 127.0.0.1) to something else, see above or search this document for `LOCAL_LISTEN_ADDRESS`.
#### 4.4 MySQL
##### 4.4.1 Select MySQL version
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| MYSQL_SERVER | `mariadb-10.1`| Change the MySQL Docker container |
1. Open the `.env` file in your favorite editor
2. Find the `MYSQL_SERVER=` block
**Important:** Each version has a different data directory. This is a security precautions. Imagine you startup MySQL 5.5 for the first time. New databases will be created. Now you startup MySQL 8. All existing databases would be upgraded to work flawlessly with MySQL 8, however this is not downwards compatible. So by startup up MySQL 5.5 again, it would say the database is corrupt.
##### 4.4.2 Root password
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| MYSQL_ROOT_PASSWORD | `` | Root user password for MySQL |
If you start a MySQL container for the first time, it will setup MySQL itself with the specified password. If you do change the root password to something else, make sure to also set it accordingly in `.env`, otherwise the devilbox will not be able to connect to MySQL and will not be able to display information inside the bundled intranet.
##### 4.4.3 General Log
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| MYSQL_GENERAL_LOG | `1` | Turn on or off MySQL general query log |
https://dev.mysql.com/doc/refman/5.7/en/query-log.html:
> The general query log is a general record of what mysqld is doing. The server writes information to this log when clients connect or disconnect, and it logs each SQL statement received from clients. The general query log can be very useful when you suspect an error in a client and want to know exactly what the client sent to mysqld.
This logging behavior is turned on by default in order to provide all information during development. Set it to `0` to turn it off.
##### 4.4.4 Host port
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HOST_PORT_MYSQL | `3306`| Host computer listening port for the MySQL server (MySQL or MariaDB) |
By default the MySQL server will listen on port 3306 (on your Host computer). You can change this to any other port (in case port 3306 is already taken).
If you also want to change the listening address (default: 127.0.0.1) to something else, see above or search this document for `LOCAL_LISTEN_ADDRESS`.
##### 4.4.5 Data path
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HOST_PATH_MYSQL_DATADIR | `./data/mysql` | Can be absolute or relative path. A relative path starts inside the devilbox git directory. |
This is the file system path on your host computer which will hold the MySQL data.
**Note:** A sub directory will be created inside this path for each MySQL version. This separation is there to make sure that higher versions do not upgrade the database irrevocably. (e.g.: MySQL 8.0 can read data from MySQL 5.5, but not the other way round).
The automatic folder structure will look something like this:
```shell
$ ls -l ./data/mysql/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 mariadb-10.0/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 mariadb-10.1/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 mariadb-10.2/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 mariadb-10.3/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 mysql-5.5/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 mysql-5.6/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 mysql-5.7/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 mysql-8.0/
```
##### 4.4.6 my.cnf
`my.cnf` settings can be configured for each MySQL/MariaDB version separately. Container-based configuration is done inside the `./cfg/` directory.
```shell
$ ls -l ./cfg/ | grep -E 'mysql|maria'
drwxrwxr-x 2 cytopia 4096 Jun 1 08:44 mariadb-10.0/
drwxrwxr-x 2 cytopia 4096 Jun 1 08:44 mariadb-10.1/
drwxrwxr-x 2 cytopia 4096 Jun 1 08:44 mariadb-10.2/
drwxrwxr-x 2 cytopia 4096 Jun 1 08:44 mariadb-10.3/
drwxrwxr-x 2 cytopia 4096 Jun 13 13:18 mysql-5.5/
drwxrwxr-x 2 cytopia 4096 Jun 1 08:44 mysql-5.6/
drwxrwxr-x 2 cytopia 4096 Jun 1 08:44 mysql-5.7/
drwxrwxr-x 2 cytopia 4096 Jun 1 08:44 mysql-8.0/
```
Each of the above folders will hold an example configuration file named `devilbox-custom.cnf-example` which shows some example settings but will **not have** any effect yet. Only files ending by **`.cnf`** will be sourced and applied, so you must copy it (or create a new file) to something that ends by `*.cnf`.
In order to edit settings for MySQL 5.5, go into that folder, copy the example file and adjust ist:
```shell
# Copy to file ending by *.ini
$ cd cfg/mysql-5.5
$ cp devilbox-custom.cnf-example devilbox-custom.cnf
# Edit settings
$ vi devilbox-custom.cnf
```
Change will take effect after restarting the devilbox.
#### 4.5 PostgreSQL
##### 4.5.1 Select PostgreSQL version
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| PGSQL_SERVER | `9.6` | Change the PostgreSQL Docker container |
1. Open the `.env` file in your favorite editor
2. Find the `PGSQL_SERVER=` block
**Important:** Each version has a different data directory. This is a security precautions. Imagine you startup PostgreSQL 9.1 for the first time. New databases will be created. Now you startup PostgreSQL 9.6. All existing databases would be upgraded to work flawlessly with PostgreSQL 9.6, however this is not downwards compatible. So by startup up PostgreSQL 9.1 again, it would say the database is corrupt.
##### 4.5.2 Root user
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| PGSQL_ROOT_USER | `postgres` | Root username for PostgreSQL |
If you start a PostgreSQL container for the first time, it will setup PostgreSQL itself with a specified username and password. If you do change the root username or password to something else, make sure to also set it accordingly in `.env`, otherwise the devilbox will not be able to connect to PostgreSQL and will not be able to display information inside the bundled intranet.
See also: Root password
##### 4.5.3 Root password
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| PGSQL_ROOT_PASSWORD | `` | Root user password for PostgreSQL |
If you start a PostgreSQL container for the first time, it will setup PostgreSQL itself with a specified username and password. If you do change the root username or password to something else, make sure to also set it accordingly in `.env`, otherwise the devilbox will not be able to connect to PostgreSQL and will not be able to display information inside the bundled intranet.
See also: Root user
##### 4.5.4 Host port
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HOST_PORT_PGSQL | `5432`| Host computer listening port for the PostgreSQL server |
By default the PostgreSQL server will listen on port 5432 (on your Host computer). You can change this to any other port (in case port 5432 is already taken).
If you also want to change the listening address (default: 127.0.0.1) to something else, see above or search this document for `LOCAL_LISTEN_ADDRESS`.
##### 4.5.5 Data path
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HOST_PATH_PGSQL_DATADIR | `./data/pgsql` | Can be absolute or relative path. A relative path starts inside the devilbox git directory. |
This is the file system path on your host computer which will hold the PostgreSQL data.
**Note:** A sub directory will be created inside this path for each PostgreSQL version. This separation is there to make sure that higher versions do not upgrade the database irrevocably. (e.g.: PostgreSQL 9.6 can read data from PostgreSQL 9.1, but maybe not the other way round).
The automatic folder structure will look something like this:
```shell
$ ls -l ./data/pgsql/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 9.1/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 9.2/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 9.3/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 9.4/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 9.5/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 9.6/
```
#### 4.6 Redis
##### 4.6.1 Select Redis version
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| REDIS_SERVER | `3.2` | Change the Redis Docker container |
1. Open the `.env` file in your favorite editor
2. Find the `REDIS_SERVER=` block
There is nothing to pay attention to here.
##### 4.6.2 Host port
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HOST_PORT_REDIS | `6379`| Host computer listening port for the Redis server |
By default the Redis server will listen on port 6379 (on your Host computer). You can change this to any other port (in case port 6379 is already taken).
If you also want to change the listening address (default: 127.0.0.1) to something else, see above or search this document for `LOCAL_LISTEN_ADDRESS`.
#### 4.7 Memcached
##### 4.7.1 Select Memcached version
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| MEMCD_SERVER | `1.4.21` | Change the Memcached Docker container |
1. Open the `.env` file in your favorite editor
2. Find the `MEMCD_SERVER=` block
There is nothing to pay attention to here.
##### 4.7.2 Host port
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HOST_PORT_MEMCD | `11211`| Host computer listening port for the Memcached server |
By default the Memcached server will listen on port 11211 (on your Host computer). You can change this to any other port (in case port 11211 is already taken).
If you also want to change the listening address (default: 127.0.0.1) to something else, see above or search this document for `LOCAL_LISTEN_ADDRESS`.
#### 4.8 MongoDB
##### 4.8.1 Select MongoDB version
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| MONGO_SERVER | `3.4` | Change the MongoDB Docker container |
1. Open the `.env` file in your favorite editor
2. Find the `MONGO_SERVER=` block
**Important:** Each version has a different data directory. This is a security precautions. Imagine you startup MongoDB 2.8 for the first time. New databases will be created. Now you startup MongoDB 3.5. All existing databases would be upgraded to work flawlessly with MongoDB 3.5, however this is not downwards compatible. So by startup up MongoDB 2.8 again, it would say the database is corrupt.
##### 4.8.2 Host port
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HOST_PORT_MONGO | `27017`| Host computer listening port for the MongoDB server |
By default the Memcached server will listen on port 27017 (on your Host computer). You can change this to any other port (in case port 27017 is already taken).
If you also want to change the listening address (default: 127.0.0.1) to something else, see above or search this document for `LOCAL_LISTEN_ADDRESS`.
##### 4.8.3 Data path
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HOST_PATH_MONGO_DATADIR | `./data/mongo` | Can be absolute or relative path. A relative path starts inside the devilbox git directory. |
This is the file system path on your host computer which will hold the MongoDB data.
**Note:** A sub directory will be created inside this path for each MongoDB version. This separation is there to make sure that higher versions do not upgrade the database irrevocably. (e.g.: MongoDB 3.5 can read data from MongoDB 2.8, but maybe not the other way round).
The automatic folder structure will look something like this:
```shell
$ ls -l ./data/mongo/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 2.8/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 3.0/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 3.2/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 3.4/
drwxrwxr-x 6 48 48 4096 Jun 21 08:47 3.5/
```
#### 4.9 Bind
##### 4.9.1 Upstream resolver
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| BIND_DNS_RESOLVER | `8.8.8.8,8.8.4.4` | Comma separated list of IP addresses of DNS servers. By default using Google's DNS server as they are pretty fast. |
The devilbox is using its own DNS server internally (your host computer can also use it for Auto-DNS) in order to resolve custom project domains defined by `TLD_SUFFIX`. To also be able to reach the internet from within the Container there must be some kind of upstream DNS server to ask for queries.
If you don't trust the Google DNS server, then set it to something else. If you already have a DNS server inside your LAN and also want your custom DNS (if any) to be available inside the containers, set the value to its IP address.
##### 4.9.2 Host port
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| HOST_PORT_BIND | `1053`| Host computer listening port for the Bind DNS server |
By default the Bind DNS server will listen on port 1053 (on your Host computer). You can change this to any other port (in case port 1053 is already taken)
If you also want to change the listening address (default: 127.0.0.1) to something else, see above or search this document for `LOCAL_LISTEN_ADDRESS`.
## 5. Intranet settings
#### 5.1 DNS check timeout
| `.env` file variable name | Default | Note |
|---------------------------|---------|------|
| DNS_CHECK_TIMEOUT | `1` | DNS timeout in seconds for unresolvable Domains |
`TLD_SUFFIX` domains are checked if they are set in the host computer /etc/hosts or available via attached DNS server. Timeout is done on vhosts.php (intranet) via ajax calls. In order to keep performance, set this to a low value. DNS checks might not succeed in time on slow machines. If DNS is valid, but timeout is expired, set this to a higher value.
`DNS_CHECK_TIMEOUT` value is how many seconds to time out.
## 6. Host computer
#### 6.1 /etc/hosts
In the `/etc/hosts` file you will have to configure your project DNS.
Each project is available in your browser via `http://<project-folder>.<TLD_SUFFIX>`. However your Host computer is not aware of this DNS name by default. In order to tell it to what IP address the domain should be resolved, you will need to make one entry per project in the `/etc/hosts` file on your host computer.
These entries typically look like this:
```shell
$ cat /etc/hosts
127.0.0.1 localhost
```
If you have set `TLD_SUFFIX` to `loc` and your project folder is named `my-project`, you will need to add the following entry:
```
127.0.0.1 my-project.loc
```
As you can see, the following general structure for all project applies:
```
<LOCAL_LISTEN_ADDRESS> <project-folder>.<TLD_SUFFIX>
```
See **Project settings** for more detail.
**Note:** On Windows the file can be found under: `C:\Windows\System32\drivers\etc`
If you do not want to create this entry everytime for a new project, skip to the next section to see how to setup Auto-DNS.
#### 6.2 Auto-DNS
The devilbox provides its own DNS nameserver that automatically configures itself based on the values of `TLD_SUFFIX`. That means each `<project-folder>.<TLD_SUFFIX>` domain will always point to `127.0.0.1`.
You can make advantage of that by adding this DNS nameserver to your host computers DNS config in `/etc/resolv.conf`. Then everytime you make a request (in your Browser for example) to a devilbox project domain, the bundled DNS name server will successfully answer the request and direct you to the project. This will remove the need to make custom `/etc/hosts` entries for each project.
**What is required for this to work?**
First of all, you need to make sure that nothing on your host computer is listening on port 53.
```shell
$ netstat -tulpen | grep ':53'
```
If there is already something listening on that port, you will need to stop whatever is listening in port 53 (TCP and UDP).
If nothing is listening anymore on port 53, edit your `/etc/resolv.conf` and add the following line above all other `nameserver` entries:
```
nameserver 127.0.0.1
```
**Note:** Keep all other `nameserver` entries intact. The devilbox DNS nameserver will only work once the devilbox is running. If you remove all others and don't run the devilbox, you won't be able to resolve any DNS names anymore.
Afterwards `/etc/resolv.conf` will look similar to this:
```
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
nameserver 192.168.0.10
search local
```
**Note:** This section needs to be improved with more detail. If anything is unclear for now, drop an issue at Github.

View File

@ -1,23 +0,0 @@
# Devilbox Documentation
[Home](https://github.com/cytopia/devilbox) |
[Overview](README.md) |
[Configuration](Configuration.md) |
[Usage](Usage.md) |
[Updating](Updating.md) |
[Info](Info.md) |
[PHP Projects](PHP_Projects.md) |
Emails |
[Logs](Logs.md) |
[Intranet](Intranet.md) |
[FAQ](FAQ.md)
----
## Emails
You can send emails from within your PHP projects without having to worry to accidentally sending them out.
All emails to whatever recipients are kept inside by a catch-all functionality from within the `php` container (using postfix).
In order to view the sent emails, use the bundled devilbox intranet and go to the Emails menu. For more information about this see the **[Intranet](Intranet.md)** section.

391
docs/Examples.md Normal file
View File

@ -0,0 +1,391 @@
# Devilbox Documentation
[Overview](README.md) |
[Quickstart](Quickstart.md) |
[Install](Install.md) |
[Update](Update.md) |
[Configure](Configure.md) |
[Run](Run.md) |
[Usage](Usage.md) |
[OS](OS.md) |
[Backups](Backups.md) |
Examples |
[Technical](Technical.md) |
[Hacking](Hacking.md) |
[FAQ](FAQ.md)
---
## Examples
1. [Introduction](#1-introduction)
2. [Setup CakePHP](#2-setup-cakephp)
3. [Setup Drupal](#3-setup-drupal)
4. [Setup Phalcon](#4-setup-phalcon)
5. [Setup Symfony](#5-setup-symfony)
6. [Setup Wordpress](#6-setup-wordpress)
7. [Setup Yii](#7-setup-yii)
8. [Setup Zend](#8-setup-zend)
---
## 1. Introduction
The devilbox provides popular tools for setting up and managing major frameworks or content management systems. The following bundled tools are available:
| Binary | Tool name | Framework/CMS |
|------------|-------------------|--------------------|
| `composer` | [composer](https://getcomposer.org) | CakePHPi, Symfony, Yii, Zend and others |
| `drush` | [drush](http://www.drush.org/) | Drupal |
| `drupal` | [drupal-consol](https://drupalconsole.com) | Drupal |
| `git` | [git](https://git-scm.com) | Everything available on github and other git servers |
| `laravel` | [laravel installer](https://github.com/laravel/installer) | Laravel |
| `phalcon` | [phalcon devtools](https://github.com/phalcon/phalcon-devtools) | Phalcon |
| `symfony` | [symfony installer](https://github.com/symfony/symfony-installer) | Symfony |
| `wp` | [wp-cli](https://wp-cli.org/) | Wordpress |
## 2. Setup CakePHP
The following configuration will be used:
| Project name | VirtualHost directory | Database | TLD_SUFFIX | Url |
|--------------|-----------------------|------------|------------|-----|
| my-cake | /shared/httpd/my-cake | my_cake | local | http://my-cake.local |
It will be ready in eight simple steps:
1. Enter the PHP container
2. Create a new VirtualHost directory
3. Install CakePHP via `composer`
4. Symlink webroot directory
5. Add MySQL database
6. Configure datbase connection
7. Setup DNS record
8. Visit http://my-cake.local in your browser
```shell
# 1. Enter the PHP container
host> ./bash.sh
# 2. Create a new VirtualHost directory
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-cake
# 3. Install CakePHP via composer
devilbox@php-7.0.20 in /shared/httpd $ cd my-cake
devilbox@php-7.0.20 in /shared/httpd $ composer create-project --prefer-dist cakephp/app cakephp
# 4. Symlink webroot directory
devilbox@php-7.0.20 in /shared/httpd $ ln -s cakephp/webroot/ htdocs
# 5. Add MySQL datbase
devilbox@php-7.0.20 in /shared/httpd $ mysql -u root -h 127.0.0.1 -p -e 'CREATE DATABASE my_cake;'
# 6. Configure datbase connection
devilbox@php-7.0.20 in /shared/httpd $ vi cakephp/config/app.php
```
```php
<?php
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => '127.0.0.1',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'non_standard_port_number',
'username' => 'root',
'password' => 'secret',
'database' => 'my_cake',
'encoding' => 'utf8',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
```
**7. DNS record**
If you do not have auto-DNS configured, you will need to add the following line to your Host computer's `/etc/hosts`:
```shell
127.0.0.1 my-cake.local
```
**8. Open your browser**
All set now, you can visit http://my-cake.local in your browser.
If you want to dig deeper into installing CakePHP, visit their documentation [https://book.cakephp.org/3.0/en/installation.html](https://book.cakephp.org/3.0/en/installation.html).
## 3. Setup Drupal
The following configuration will be used:
| Project name | VirtualHost directory | Database | TLD_SUFFIX | Url |
|--------------|-----------------------|------------|------------|-----|
| my-drupal | /shared/httpd/my-drupal | my_drupal| local | http://my-drupal.local |
It will be ready in six simple steps:
1. Enter the PHP container
2. Create a new VirtualHost directory
3. Install Drupal via `drush`
4. Symlink Drupal directory
5. Setup DNS record
6. Visit http://my-drupal.local in your browser and follow instructions
```shell
# 1. Enter the PHP container
host> ./bash.sh
# 2. Create a new VirtualHost directory
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-drupal
# 3. Install Drupal via drush
devilbox@php-7.0.20 in /shared/httpd $ cd my-drupal
devilbox@php-7.0.20 in /shared/httpd $ drush dl drupal
# 4. Symlink Drupal directory
devilbox@php-7.0.20 in /shared/httpd $ ln -s drupal-8.3.3 htdocs
```
**5. DNS record**
If you do not have auto-DNS configured, you will need to add the following line to your Host computer's `/etc/hosts`:
```shell
127.0.0.1 my-drupal.local
```
**6. Open your browser**
Open your browser at http://my-drupal.local and follow the Drupal installation steps.
**Note:** For MySQL host choose `127.0.0.1`.
## 4. Setup Phalcon
The following configuration will be used:
| Project name | VirtualHost directory | Database | TLD_SUFFIX | Url |
|--------------|-----------------------|------------|------------|-----|
| my-phalcon | /shared/httpd/my-phalcon | - | local | http://my-phalcon.local |
It will be ready in six simple steps:
1. Enter the PHP container
2. Create a new VirtualHost directory
3. Install Phalcon via `phalcon`
4. Symlink public directory
5. Setup DNS record
6. Visit http://my-phalcon.local in your browser
```shell
# 1. Enter the PHP container
host> ./bash.sh
# 2. Create a new VirtualHost directory
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-phalcon
# 3. Install Phalcon via phalcon
devilbox@php-7.0.20 in /shared/httpd $ cd my-phalcon
devilbox@php-7.0.20 in /shared/httpd $ phalcon project phalconphp
# 4. Symlink public directory
devilbox@php-7.0.20 in /shared/httpd $ ln -s phalconphp/public htdocs
```
**5. DNS record**
If you do not have auto-DNS configured, you will need to add the following line to your Host computer's `/etc/hosts`:
```shell
127.0.0.1 my-phalcon.local
```
**7. Open your browser**
Open your browser at http://my-phalcon.local
## 5. Setup Symfony
The following configuration will be used:
| Project name | VirtualHost directory | Database | TLD_SUFFIX | Url |
|--------------|-----------------------|------------|------------|-----|
| my-symfony | /shared/httpd/my-symfony | - | local | http://my-symfony.local |
It will be ready in six simple steps:
1. Enter the PHP container
2. Create a new VirtualHost directory
3. Install Symfony via `symfony`
4. Symlink web directory
5. Enable Symfony prod (app.php)
6. Setup DNS record
7. Visit http://my-symfony.local in your browser
```shell
# 1. Enter the PHP container
host> ./bash.sh
# 2. Create a new VirtualHost directory
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-symfony
# 3. Install Symfony via symfony
devilbox@php-7.0.20 in /shared/httpd $ cd my-symfony
devilbox@php-7.0.20 in /shared/httpd $ symfony new symfony
# 4. Symlink web directory
devilbox@php-7.0.20 in /shared/httpd $ ln -s symfony/web htdocs
# 5. Enable Symfony production (app.php)
devilbox@php-7.0.20 in /shared/httpd $ cd symfony/web
devilbox@php-7.0.20 in /shared/httpd $ ln -s app.php index.php
```
**6. DNS record**
If you do not have auto-DNS configured, you will need to add the following line to your Host computer's `/etc/hosts`:
```shell
127.0.0.1 my-symfony.local
```
**7. Open your browser**
Open your browser at http://my-symfony.local
## 6. Setup Wordpress
The following configuration will be used:
| Project name | VirtualHost directory | Database | TLD_SUFFIX | Url |
|--------------|-----------------------|------------|------------|-----|
| my-wp | /shared/httpd/my-wp | my_wp | local | http://my-wp.local |
It will be ready in six simple steps:
1. Enter the PHP container
2. Create a new VirtualHost directory
3. Download Wordpress via `git`
4. Symlink wordpress git directory
5. Setup DNS record
6. Visit http://my-wp.local in your browser
```shell
# 1. Enter the PHP container
host> ./bash.sh
# 2. Create a new VirtualHost directory
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-wp
# 3. Download Wordpress via git
devilbox@php-7.0.20 in /shared/httpd $ cd my-wp
devilbox@php-7.0.20 in /shared/httpd $ git clone https://github.com/WordPress/WordPress wordpress.git
# 4. Symlink wordpress git directory
devilbox@php-7.0.20 in /shared/httpd $ ln -s wordpress.git htdocs
```
**5. DNS record**
If you do not have auto-DNS configured, you will need to add the following line to your Host computer's `/etc/hosts`:
```shell
127.0.0.1 my-wp.local
```
**6. Open your browser**
Open your browser at http://my-wp.local
## 7. Setup Yii
The following configuration will be used:
| Project name | VirtualHost directory | Database | TLD_SUFFIX | Url |
|--------------|-----------------------|------------|------------|-----|
| my-yii | /shared/httpd/my-yii | - | local | http://my-yii.local |
It will be ready in six simple steps:
1. Enter the PHP container
2. Create a new VirtualHost directory
3. Install Yii2 via `composer`
4. Symlink web directory
5. Setup DNS record
6. Visit http://my-yii.local in your browser
```shell
# 1. Enter the PHP container
host> ./bash.sh
# 2. Create a new VirtualHost directory
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-yii
# 3. Install Yii2 via composer
devilbox@php-7.0.20 in /shared/httpd $ cd my-yii
devilbox@php-7.0.20 in /shared/httpd $ composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic yii2-dev
# 4. Symlink web directory
devilbox@php-7.0.20 in /shared/httpd $ ln -s yii2-dev/web htdocs
```
**5. DNS record**
If you do not have auto-DNS configured, you will need to add the following line to your Host computer's `/etc/hosts`:
```shell
127.0.0.1 my-yii.local
```
**6. Open your browser**
Open your browser at http://my-yii.local
## 8. Setup Zend
The following configuration will be used:
| Project name | VirtualHost directory | Database | TLD_SUFFIX | Url |
|--------------|-----------------------|------------|------------|-----|
| my-zend | /shared/httpd/my-zend | - | local | http://my-zend.local |
It will be ready in six simple steps:
1. Enter the PHP container
2. Create a new VirtualHost directory
3. Install Zendframework via `composer`
4. Symlink public directory
5. Setup DNS record
6. Visit http://my-zend.local in your browser
```shell
# 1. Enter the PHP container
host> ./bash.sh
# 2. Create a new VirtualHost directory
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-zend
# 3. Install Zendframework via composer
devilbox@php-7.0.20 in /shared/httpd $ cd my-zend
devilbox@php-7.0.20 in /shared/httpd $ composer create-project --prefer-dist zendframework/skeleton-application zend
# 4. Symlink public directory
devilbox@php-7.0.20 in /shared/httpd $ ln -s zend/public htdocs
```
**5. DNS record**
If you do not have auto-DNS configured, you will need to add the following line to your Host computer's `/etc/hosts`:
```shell
127.0.0.1 my-zend.local
```
**7. Open your browser**
Open your browser at http://my-zend.local

View File

@ -1,28 +1,26 @@
# Devilbox Documentation
[Home](https://github.com/cytopia/devilbox) |
[Overview](README.md) |
[Configuration](Configuration.md) |
[Quickstart](Quickstart.md) |
[Install](Install.md) |
[Update](Update.md) |
[Configure](Configure.md) |
[Run](Run.md) |
[Usage](Usage.md) |
[Updating](Updating.md) |
[Info](Info.md) |
[PHP Projects](PHP_Projects.md) |
[Emails](Emails.md) |
[Logs](Logs.md) |
[Intranet](Intranet.md) |
[OS](OS.md) |
[Backups](Backups.md) |
[Examples](Examples.md) |
[Technical](Technical.md) |
[Hacking](Hacking.md) |
FAQ
----
---
## FAQ
**Are there any differences between Linux, Windows and OSX?**
**How do I backup my MySQL database?**
1. Use phpMyAdmin
2. Use Adminer
3. use `mysqldump` from your host computer
4. use `mysqldump` from within the php container
Yes, have a look at **[OS](OS.md)** to read up about the differences.
**Why are mounted MySQL data directories separated by version?**
@ -32,6 +30,54 @@ This is just a pre-caution. Imagine they would link to the same datadir. You sta
See: *Why are mounted MySQL data directories separated by version?*
**Why are mounted MongoDB data directories separated by version?**
See: *Why are mounted MySQL data directories separated by version?*
**Why do the user/group permissions of log/ or cfg/ directories show 1000?**
Uid and Gid are set to 1000 by default. You can alter them to match the uid/gid of your current user. Open the `.env` file and change the sections `NEW_UID` and `NEW_GID`. When you start up the devilbox, the php-container will use these values for its user.
**Can I change the MySQL root password?**
Yes, you can change the password of the MySQL root user. If you do so, you must also set the new password in your `.env` file. See [Configure](Configure.md) for how to change the values.
**Can I not just comment out the service in the `.env` file?**
No, don't do this. This will lead to unexpected behaviour (different versions will be loaded).
The `.env` file allows you to configure the devilbox, but not to start services selectively.
**Are there any required services that must/will always be started?**
Yes. `http` and `php` will automatically always be started (due to dependencies inside `docker-compose.yml`) if you specify them or not.
**What PHP Modules are available?**
The devilbox is a development stack, so it is made sure that a lot of PHP modules are available out of the box in order to work with many different frameworks.
*apc, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, intl, json, ldap, libxml, magickwand, mbstring, mcrypt, memcache, memcached, mhash, mongodb, msgpack, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib*
There will however be slight differences between the versions and especially with HHVM. To see the exact bundled modules for each version visit the corresponding docker repositories on Github:
[PHP 5.4](https://github.com/cytopia/docker-php-fpm-5.4) |
[PHP 5.5](https://github.com/cytopia/docker-php-fpm-5.5) |
[PHP 5.6](https://github.com/cytopia/docker-php-fpm-5.6) |
[PHP 7.0](https://github.com/cytopia/docker-php-fpm-7.0) |
[PHP 7.1](https://github.com/cytopia/docker-php-fpm-7.1) |
[HHVM](https://github.com/cytopia/docker-hhvm-latest)
**Can I add other PHP Modules?**
Yes, if there are any PHP modules you require that are not yet available in the PHP Docker container, you can install it during run-time, or create your own container. See [Hacking](Hacking.md) for more informatino.
**Can I change php.ini?**
Yes, php.ini directives can be changes on a per PHP version base. Go to `./cfg/` inside devilbox git diretory. There you will find configuration directories for each php version. Just put a \*.ini file there and restart the devilbox.
**Can I change my.cnf?**
Yes, my.cnf directives can be changes on a per MySQL version base. Go to `./cfg/` inside devilbox git diretory. There you will find configuration directories for each MySQL version. Just put a \*.cnf file there and restart the devilbox.
**Can I switch HHVM between PHP 5.6 and PHP 7 mode?**
Yes, this can be done by adding a \*.ini file to `./cfg/hhvm-latest/` with the following content: `hhvm.php7.all = 0` to disable PHP 7. The default is to use PHP 7 mode.

156
docs/Hacking.md Normal file
View File

@ -0,0 +1,156 @@
# Devilbox Documentation
[Overview](README.md) |
[Quickstart](Quickstart.md) |
[Install](Install.md) |
[Update](Update.md) |
[Configure](Configure.md) |
[Run](Run.md) |
[Usage](Usage.md) |
[OS](OS.md) |
[Backups](Backups.md) |
[Examples](Examples.md) |
[Technical](Technical.md) |
Hacking |
[FAQ](FAQ.md)
---
## Hacking
1. [Rebuilding bundled Docker container](#1-rebuilding-bundled-docker-container)
1. [Why rebuild yourself?](#1-1-why-rebuild-yourself-)
2. [How to rebuild yourself?](#1-2-how-to-rebuild-yourself-)
3. [How to use the rebuild container?](#1-3-how-to-use-the-rebuild-container-)
2. [Customizing the bundled Docker container](#2-customizing-the-bundled-docker-container)
3. [Adding your own Docker container](#3-adding-your-own-docker-container)
1. [What information will you need?](#3-1-what-information-will-you-need-)
2. [How to add your service?](#3-2-how-to-add-your-service-)
3. [How to start your service?](#3-3-how-to-start-your-service-)
---
## 1. Rebuilding bundled Docker container
The devilbox Docker container are rebuild frequently and pushed to [dockerhub](https://hub.docker.com/r/cytopia/). However there might be cases in which you want to rebuild right away in order to use a new minor version of a tool inside the container.
#### 1.1 Why rebuild yourself?
Imagine for example you are using the [PHP 7.1](https://github.com/cytopia/docker-php-fpm-7.1) container which currently is available with the version 7.1.6. You found that PHP 7.1.7 has just been released, but the container wasn't yet updated to that version. If you can't wait and need that version now, you can just update the container to that version yourself.
#### 1.2 How to rebuild yourself?
Rebuilding yourself has been made pretty easy. The devilbox docker container repositories come with two scripts for automatic rebuilding. `build/docker-build.sh` and `build/docker-rebuild.sh`.
1. *Clone* or *fork and clone* the desired docker repository to your computer
2. Run `build/docker-build.sh` (cached build) or `build/docker-rebuild.sh` (uncached build)
Either of the two above scripts will rebuild the desired docker container with the latest available versions. The rebuild docker container will then be available locally by the tag `latest`
#### 1.3 How to use the rebuild container?
##### 1.3.1 Tagged devilbox repository
If your devilbox git repository is checked out on a `git tag`, then also the docker container are bound to specific docker tags. It will look like this in `docker-compose.yml`:
```yml
php:
image: cytopia/${PHP_SERVER:-php-fpm-7.0}:0.10
```
Your newly rebuild `latest` docker container will not yet be available for the next run. You still need to change the `docker-compose.yml` and set the container to `latest`:
```yml
php:
image: cytopia/${PHP_SERVER:-php-fpm-7.0}:latest
```
##### 1.3.2 devilbox repository on master branch
If your devilbox git repository is checkout out on the `master` branch, then all docker container are always bound to the `latest` docker tag inside `docker-compose.yml` and you do not need to change anything. Just rebuilding the container is enough to be picked up for the next start.
## 2. Customizing the bundled Docker container
Customizing a Docker container is almost as simple as rebuilding it.
1. Fork the desired docker repository
2. Clone your forked docker repository locally
3. Edit `Dockerfile` with your customization
4. Run `build/docker-build.sh` (cached build) or `build/docker-rebuild.sh` (uncached build)
5. Read the rebuild section above to apply necessary steps
## 3. Adding your own Docker container
You can add your custom docker container including its configuration to `docker-compose.yml`.
#### 3.1 What information will you need?
1. A name that you can use to refer to in the docker-compose command
2. The Docker image name
3. The Docker image version or `latest`
4. An unused IP address from the devilbox network
#### 3.2 How to add your service?
##### 3.2.1 General example
1. Open `docker-compose.yml`
2. Paste the following snippet with your replaced values just below the `services:` line (with one level of indentation)
```yml
...
services:
# Your custom Docker container here:
<name>:
image: <image-name>:<image-version>
networks:
app_net:
ipv4_address: <unused-ip-address>
# For ease of use always automatically start these:
depends_on:
- bind
- php
- httpd
# End of custom Docker container
...
```
##### 3.2.2 Specific example
Lets make a real example for adding [Cockroach DB](https://hub.docker.com/r/cockroachdb/cockroach/)
1. Name: `cockroach`
2. Image: `cockroachdb/cockroach`
3. Version: `latest`
4. IP: `172.16.238.200`
Now add the information to `docker-compose.yml` just below the `services:` line:
```yml
...
services:
# Your custom Docker container here:
cockroach:
image: cockroachdb/cockroach:latest
networks:
app_net:
ipv4_address: 172.16.238.200
# For ease of use always automatically start these:
depends_on:
- bind
- php
- httpd
# End of custom Docker container
...
```
#### 3.3 How to start your service?
```shell
# The following will bring up your service including all the
# dependent services (bind, php and httpd)
$ docker-compose up <name>
```

View File

@ -1,73 +0,0 @@
# Devilbox Documentation
[Home](https://github.com/cytopia/devilbox) |
[Overview](README.md) |
[Configuration](Configuration.md) |
[Usage](Usage.md) |
[Updating](Updating.md) |
Info |
[PHP Projects](PHP_Projects.md) |
[Emails](Emails.md) |
[Logs](Logs.md) |
[Intranet](Intranet.md) |
[FAQ](FAQ.md)
----
## Info
### Available containers
It is best to use the hostnames and not to rely on the ip addresses as they might change. In most cases however you can even use `127.0.0.1` or `localhost` (See background section below).
> E.g.: When you want to setup a MySQL database connection use `mysql` or `127.0.0.1` as the hostname.
| Container | Container name | Hostname | IP Address |
|-----------------|-----------------|-----------|----------------|
| DNS | bind | bind | 172.16.238.100 |
| PHP / HHVM | php | php | 172.16.238.10 |
| Apache / Nginx | http | http | 172.16.238.11 |
| MySQL / MariaDB | mysql | mysql | 172.16.238.12 |
| PostgreSQL | pgsql | pgsql | 172.16.238.13 |
| Redis | redis | redis | 172.16.238.14 |
| Memcached | memcd | memcd | 172.16.238.15 |
| MongoDB | mongo | mongo | 172.16.238.16 |
### Background
#### Background - PHP Container
The `php` container is the center of all container. Everything happens in there.
This is also the reason it does some more magic than actually required.
**Remote ports and remote sockets are made available to the `php` container.**
The PHP container is using [socat](https://linux.die.net/man/1/socat) to
1. forward the remote mysql port `3306` (on the mysql container) to its own `127.0.0.1:3306`
2. forward the remote pgsql port `5432` (on the pgsql container) to its own `127.0.0.1:5432`
3. forward the remote redis port `6379` (on the redis container) to its own `127.0.0.1:6379`
4. forward the remote memcached port `11211` (on the memcd container) to its own `127.0.0.1:11211`
5. forward the remote mongodb port `27017` (on the mongo container) to its own `127.0.0.1:27017`
#### Background - Docker Host
The docker host (your computer) does exactly the same as the `php` container.
1. container mysql port `3306` is exposed to the host on port `127.0.0.1:3306`
2. container pgsql port `5432` is exposed to the host on port `127.0.0.1:5432`
3. container redis port `6379` is exposed to the host on port `127.0.0.1:6379`
3. container memcd port `11211` is exposed to the host on port `127.0.0.1:11211`
3. container mongo port `27017` is exposed to the host on port `127.0.0.1:27017`
Also the database sockets from the container are mounted into the host.
#### Background - Benefit of the above
With the PHP container and the docker host (your computer) behaving the same it is possible to write your php applications like this:
```php
<?php
mysql_connect('127.0.0.1', 'user', 'pass');
```
This setup can then either be served by the docker or by your host computer (if you shutdown docker and start your local lamp stack)

83
docs/Install.md Normal file
View File

@ -0,0 +1,83 @@
# Devilbox Documentation
[Overview](README.md) |
[Quickstart](Quickstart.md) |
Install |
[Update](Update.md) |
[Configure](Configure.md) |
[Run](Run.md) |
[Usage](Usage.md) |
[OS](OS.md) |
[Backups](Backups.md) |
[Examples](Examples.md) |
[Technical](Technical.md) |
[Hacking](Hacking.md) |
[FAQ](FAQ.md)
---
## Install
1. [Install Docker](#1-install-docker)
1. [Linux](#1-1-linux)
2. [Windows](#1-2-windows)
3. [OSX](#1-3-osx)
2. [Install Devilbox](#2-install-devilbox)
1. [Latest git tag](#2-1-latest-git-tag)
2. [Current master branch](#2-2-current-master-branch)
---
## 1. Install Docker
Only requirement for the devilbox is to have docker and docker-compose installed, everything else is bundled and provided within the Docker container.
#### 1.1 Linux
Refer to the official [Docker for Linux documentation](https://docs.docker.com/engine/installation/#supported-platforms) for how to install Docker on your distribution.
#### 1.2 Windows
Refer to the official [Docker for Windows documentation](https://docs.docker.com/docker-for-windows/install/) for how to install Docker.
**Note:** You should install the [Native Windows Docker](https://docs.docker.com/docker-for-windows/install/) and not the [Docker Toolbox](https://docs.docker.com/toolbox/overview/).
#### 1.3 OSX
Refer to the official [Docker for Mac documentation](https://docs.docker.com/docker-for-mac/install/) for how to install Docker.
**Note:** You should install the [Native Mac Docker](https://docs.docker.com/docker-for-mac/install/) and not the [Docker Toolbox](https://docs.docker.com/toolbox/overview/).
## 2. Install Devilbox
Just clone the devilbox repository and copy the configuration file.
```shell
$ git clone https://github.com/cytopia/devilbox
$ cd devilbox
$ cp env-example .env
```
You are all set now and can continue with [configuring the devilbox](Configure.md).
#### 2.1 Latest git tag
If you always want a stable development environment, you should stay on the latest git tag. However devilbox git tags are tied to specific Docker container tags. That means you will only get new Docker versions once you switch to the next devilbox git tag.
To check out the latest git tag, issue the following command:
```shell
$ git checkout "$(git describe --abbrev=0 --tags)"
```
When updating git tags, you do not need to explicitly pull new Docker images, as this will be done automatically once starting up the devilbox. The only thing you will have to do is to compare your current configuration file `.env` with possible new options in `env-example`. Refer to [Update](Update.md) For more information about how to update the devilbox properly.
#### 2.2 Current master branch
The devilbox master branch will always reflect the latest changes. However, no commits are pushed directly to master and everything merged into this branch has to go through various tests to make sure the master branch stays as stable as it can get.
The master branch ties each Docker container to their `latest` Docker tags. That means you can regularily `docker-compose pull` in order to obtain updated Docker container.
**Note:** Always do `git pull origin master` and `docker-compose pull` together. Do not just do one of them.
For the installation routine, there is nothing else to do here. After cloning you are automatically on the master branch. There are however a few things to pay attention to when updating the master branch. Refer to [Update](Update.md) For more information about how to update the devilbox properly.

View File

@ -1,18 +0,0 @@
# Devilbox Documentation
[Home](https://github.com/cytopia/devilbox) |
[Overview](README.md) |
[Configuration](Configuration.md) |
[Usage](Usage.md) |
[Updating](Updating.md) |
[Info](Info.md) |
[PHP Projects](PHP_Projects.md) |
[Emails](Emails.md) |
[Logs](Logs.md) |
Intranet |
[FAQ](FAQ.md)
----
## Intranet

View File

@ -1,58 +0,0 @@
# Devilbox Documentation
[Home](https://github.com/cytopia/devilbox) |
[Overview](README.md) |
[Configuration](Configuration.md) |
[Usage](Usage.md) |
[Updating](Updating.md) |
[Info](Info.md) |
[PHP Projects](PHP_Projects.md) |
[Emails](Emails.md) |
Logs |
[Intranet](Intranet.md) |
[FAQ](FAQ.md)
----
## Logs
Log information is available in two forms.
1. Mounted log directories
2. Docker logs
### Mounted log directories
Inside the devilbox directory you will find a folder `log/`.
This itself will contain subdirectories in the form `<service>-<version>` which will then hold all available log files.
**Example:**
```
devilbox/
log/
apache-2.2/
access_log
error_log
localhost-access.log
localhost-error.log
other-error.log
mariadb-10.3/
error.log
query.log
slow.log
php-fpm-7.0/
php-fpm.err
www-access.log
www-error.log
```
### Docker logs
All output that is produced to stdout or stderr by the started service will be available in `docker logs`. In order to view them constantly in a terminal session use:
```shell
docker-compose logs -f
```
Docker logs are currently only being used to display the initial startup including the chosen settings. All other logging is written to file and mounted to the docker host.

53
docs/OS.md Normal file
View File

@ -0,0 +1,53 @@
# Devilbox Documentation
[Overview](README.md) |
[Quickstart](Quickstart.md) |
[Install](Install.md) |
[Update](Update.md) |
[Configure](Configure.md) |
[Run](Run.md) |
[Usage](Usage.md) |
OS |
[Backups](Backups.md) |
[Examples](Examples.md) |
[Technical](Technical.md) |
[Hacking](Hacking.md) |
[FAQ](FAQ.md)
---
## Operating System differences
1. [Linux](#1-linux)
2. [Windows](#2-windows)
1. [/etc/hosts](#2-1-etc-hosts-)
1. [/etc/resolv.conf](#2-2-etc-resolv-conf-)
3. [OSX](#3-osx)
---
## 1. Linux
Documentation is written from a Linux point of view, so there will be no differences.
## 2. Windows
On Windows you will have to edit different files on the Docker host than on Linux or OSX.
#### 2.1 `/etc/hosts`
To set custom DNS entries on windows you will have to edit `C:\WINDOWS\system32\drivers\etc` instead.
#### 2.2 `/etc/resolv.conf`
In order to add a custom DNS resolver in Windows, you will have to use the GUI tools of your network interfaces.
Check out this blog entry for how to adjust it:
http://www.pc-freak.net/blog/configure-equivalent-linux-etcresolvconf-search-domaincom-ms-windows-dns-suffixes/
## 3. OSX
OSX behaves the same as Linux and will not have any differences from the documentation.

View File

@ -1,120 +0,0 @@
# Devilbox Documentation
[Home](https://github.com/cytopia/devilbox) |
[Overview](README.md) |
[Configuration](Configuration.md) |
[Usage](Usage.md) |
[Updating](Updating.md) |
[Info](Info.md) |
PHP Projects |
[Emails](Emails.md) |
[Logs](Logs.md) |
[Intranet](Intranet.md) |
[FAQ](FAQ.md)
----
## PHP Projects
### TL;DR
1. Create folder `${HOST_PATH_HTTPD_DATADIR}/my-project/htdocs`
2. Set `${TLD_SUFFIX}` in the `.env` file (example: `loc`)
2. Expand docker host `/etc/hosts` with `127.0.0.1 my-project.loc` or attach included DNS server to your host and stop worrying about DNS
3. Browse `http://my-project.loc`
### Adding projects
As an example, we are going to add two projects.
**Prerequisites (dir)**
For this case let's assume your www root folder points to `~/www`. This means your projects will reside on your host computer in your home directory under www.
In order to achive this set `HOST_PATH_HTTPD_DATADIR=~/www` in the `.env` file (If this file does not yet exist, copy `env-example` to `.env`).
`.env`:
```
...
HOST_PATH_HTTPD_DATADIR=~/www
...
```
**Prerequisites (domain suffix)**
Let's also assume that you have chosen `*.loc` as you projects `TLD_SUFFIX` Domain
In order to achive this set `TLD_SUFFIX=loc` in the `.env` file (If this file does not yet exist, copy `env-example` to `.env`).
`.env`:
```
...
TLD_SUFFIX=loc
...
```
**Desired Projects**
| Project name | Document Root | URL |
|--------------|---------------|-----|
| devilbox | ~/www/devilbox/htdocs | http://devilbox.loc |
| foo.bar | ~/www/foo.bar/htdocs | http://foo.bar.loc |
`htdocs` can either be a folder or a symlink to a folder.
**Project: devilbox**
Setup projects folder and an `index.php` (on your host computer)
```shell
$ mkdir -p ~/www/devilbox/htdocs
$ vim ~/devilbox/htdocs/index.php
```
```php
<?php
echo 'hello world';
?>
```
Adjust your local (host computer) `/etc/hosts` and point `devilbox.loc` to your localhost address `127.0.0.1`
```shell
$ sudo vim /etc/hosts
```
```shell
127.0.0.1 devilbox.loc
```
**Project: foo.bar**
Setup projects folder and use existing github project to serve.
```shell
$ mkdir -p ~/www/foo.bar
$ cd ~/www/foo.bar
# Use an existing github project as your document root
$ git clone https://github.com/<user>/<some-project>
# Symlink the project to htdocs
$ ln -s <some-project> htdocs
$ ls -l
drwxr-xr-x 4 cytopia 1286676289 136 Oct 30 14:24 <some-project>/
lrwxr-xr-x 1 cytopia 1286676289 549 Nov 6 15:13 htdocs -> <some-project>/
```
Adjust your local (host computer) `/etc/hosts` and point `foo.bar.loc` to your localhost address `127.0.0.1`
```shell
$ sudo vim /etc/hosts
```
```shell
127.0.0.1 foo.bar.loc
```

200
docs/Quickstart.md Normal file
View File

@ -0,0 +1,200 @@
# Devilbox Documentation
[Overview](README.md) |
Quickstart |
[Install](Install.md) |
[Update](Update.md) |
[Configure](Configure.md) |
[Run](Run.md) |
[Usage](Usage.md) |
[OS](OS.md) |
[Backups](Backups.md) |
[Examples](Examples.md) |
[Technical](Technical.md) |
[Hacking](Hacking.md) |
[FAQ](FAQ.md)
---
## Quickstart
1. [Installation](#1-installation)
2. [Update](#2-update)
1. [Tagged release](#2-1-tagged-release)
2. [Master branch](#2-2-master-branch)
3. [Configuration](#3-configuration)
1. [.env](#3-1-env)
2. [Services](#3-2-services)
4. [Run](#4-run)
1. [Run all](#4-1-run-all)
2. [Run selection](#4-2-run-selection)
5. [Project setup](#5-project-setup)
1. [General setup](#5-1-general-setup)
2. [Specific Frameworks](#5-2-specific-frameworks)
6. [Enter the PHP Docker container](#6-enter-the-php-docker-container)
---
## 1. Installation
Installing the devilbox is as easy as this:
```shell
$ git clone https://github.com/cytopia/devilbox
$ cd devilbox/
$ cp env-example .env
```
To find out in more detail for different operating systems have a look at **[Install](Install.md)**.
## 2. Update
You will have the choice to stay on stable git tags or on the latest master branch. Both options have slightly different update procedures. View the quick instructions below and for more information have a look at **[Update](Update.md)**
#### 2.1 Tagged release
```shell
$ docker-compose stop
$ docker-compose rm
$ git fetch --all
$ git checkout "$(git describe --abbrev=0 --tags)"
```
#### 2.2 Master branch
```shell
$ docker-compose stop
$ docker-compose rm
$ git fetch --all
$ git pull origin master
$ ./update-docker.sh
```
## 3. Configuration
The devilbox will work out-of-the box after the above installation routine has been done. However there are lots of options to configure. Read up on it on **[Configure](Configure.md)**. A brief overview is shown below.
#### 3.1 .env
Edit all general settings inside the .env file (file paths, what version to run, debug, timezeon, etc). The `.env` file is well documented and self-explanatory.
```shell
$ vim .env
```
#### 3.2 Services
Additionally to configure the devilbox in general, you can also configure each service separately by adding/altering service specific configuration files.
**Example:** Configure PHP 5.6
```shell
$ cd cfg/
$ echo "max_execution_time = 180" > php-fpm-5.6/config.ini
```
**Example:** Configure MySQL 5.5
```shell
$ cd cfg/
$ echo "[mysqld]\nslow_query_log = 1" > mysql-5.5/config.cnf
```
## 4. Run
Starting up the devilbox is done via docker-compose commands. You will have the choice to start-up everything or just a selection of the services you need. To get more more information about this view **[Run](Run.md)**.
#### 4.1 Run all
```shell
$ docker-compose up -d
```
#### 4.2 Run selection
```shell
$ docker-compose up -d httpd php mysql redis
```
## 5. Project setup
The heart of the devilbox is the easy configuration of an unlimitted numbder of projects. Most stuff configures itself automatically in the background, but a few things are still left up to you. The following will give you a kick-start for setting up a few projects. To find out in more detail view **[Usage](Usage.md)**.
#### 5.1 General setup
**Assumption:**
1. HOST_PATH_TO_HTTPD_DATADIR=**./data/www**
2. TLD_SUFFIX=**local**
3. Three Projects: project1, project2 and wordpress
**Folder setup on your Host system:**
| VirtualHost directory | DocumentRoot directory | URL |
|-----------------------|-----------------------------|------------------------|
| <code>./data/www/<b>project1</b></code> | <code>./data/www/project1/<b>htdocs</b></code> | `http://project1.local` |
| <code>./data/www/<b>project2</b></code> | <code>./data/www/project2/<b>htdocs</b></code> | `http://project2.local` |
| <code>./data/www/<b>wordpress</b></code>| <code>./data/www/wordpress/<b>htdocs</b></code> | `http://wordpress.local` |
Each VirtualHost will serve files from the **htdocs/** folder.
**DNS setup on your Host system:**
| Project folder | `/etc/hosts` entry |
|----------------|----------------------------|
| project1 | `127.0.0.1 project1.local` |
| project2 | `127.0.0.1 project2.local` |
| wordpress | `127.0.0.1 wordpress.local`|
Some frameworks have a nested www directory and require you to use a symlink instead of explicitly setting a **htdocs/** folder. See the CakePHP folder setup below:
```shell
$ ls -l
drwxrwxr-x 2 cytopia 4096 Jun 14 08:29 cakephp
lrwxrwxrwx 1 cytopia 11 Jun 14 08:29 htdocs -> cakephp/app/webroot/
```
#### 5.2 Specific Frameworks
One example of the above mentioned nested directory structure is CakePHP. Its actual www dats is serveed from:
```shell
<project>/cake/app/webroot
```
instead of
```shell
<project>/htdocs
```
You can easily achieve this by symlinking this folder to `htdocs`:
```shell
$ ls -l <project>/
drwxrwxr-x 2 cytopia 4096 Jun 14 08:29 cakephp
lrwxrwxrwx 1 cytopia 11 Jun 14 08:29 htdocs -> cakephp/app/webroot/
```
To quickly find setup instructions for your framework of choice head over to **[Examples](Examples.md)**:
> 1. [Introduction](Examples.md#1-introduction)
> 2. [Setup CakePHP](Examples.md#2-setup-cakephp)
> 3. [Setup Drupal](Examples.md#3-setup-drupal)
> 4. [Setup Phalcon](Examples.md#4-setup-phalcon)
> 5. [Setup Symfony](Examples.md#5-setup-symfony)
> 6. [Setup Wordpress](Examples.md#6-setup-wordpress)
> 7. [Setup Yii](Examples.md#7-setup-yii)
> 8. [Setup Zend](Examples.md#8-setup-zend)
## 6. Enter the PHP Docker container
The PHP Docker container is your workhorse which has many tools pre-installed and you can do every task inside instead of doing it on the docker host. Entering the container is done via a shipped script:
```shell
host> ./bash.sh
devilbox@php-7.0.19 in /shared/httpd $
```
See **[Usage](Usage.md)** for a detailed explanation.

View File

@ -1,292 +1,184 @@
# Devilbox
# Devilbox Documentation
| **Overview** | **Installing** | **Updating** | **Configuration** | **Usage** | **Technical** | **FAQ** |
Overview |
[Quickstart](Quickstart.md) |
[Install](Install.md) |
[Update](Update.md) |
[Configure](Configure.md) |
[Run](Run.md) |
[Usage](Usage.md) |
[OS](OS.md) |
[Backups](Backups.md) |
[Examples](Examples.md) |
[Technical](Technical.md) |
[Hacking](Hacking.md) |
[FAQ](FAQ.md)
---
## Overview
### Dockerized LAMP/MEAN stack
1. [Main idea](#1-main-idea)
2. [Features](#2-features)
3. [Supported Host OS](#3-supported-host-os)
4. [Requirements](#4-requirements)
5. [Docker documentation](#5-docker-documentation)
6. [Devilbox documentation](#6-devilbox-documentation)
7. [Video Tutorials](#7-video-tutorials)
8. [Available PHP Modules](#8-available-php-modules)
9. [Supported Frameworks and CMS](#9-supported-frameworks-and-cms)
<p class="center">The devilbox is a modern and highly customisable LAMP and MEAN stack replacement based purely on docker and docker-compose running on all major platforms. It supports an unlimited number of projects for which vhosts and DNS records are created automatically. Email catch-all and popular development tools will be at your service as well.</p>
---
<img src="img/devilbox-dash.png" alt="Devilbox" style="max-width:100%"/>
## 1. Main idea
The devilbox allows you to have an unlimitted number of projects ready without having to install any external software and without having to configure any virtual hosts. As well as providing a very flexible development stack that you can run offline. (Internet is only required to initially pull docker container).
### Supported Host OS
The only thing you will have to do is to create a new folder on the filesystem and your virtual host is ready to be served with your custom domain.
<p class="center">Don't worry about switching computers. The devilbox will run on all major operating systems.</p>
<div class="center">
<img class="battery" style="height:64px;" title="Linux support" alt="Linux support" src="https://raw.githubusercontent.com/cytopia/icons/master/64x64/linux.png" />
<img class="battery" style="height:64px;" title="OSX support" alt="OSX support" src="https://raw.githubusercontent.com/cytopia/icons/master/64x64/osx.png" />
<img class="battery" style="height:64px;" title="Windows support" alt="Windows support" src="https://raw.githubusercontent.com/cytopia/icons/master/64x64/windows.png" />
</div>
### Install, Configure and Start
<p class="center">Your whole development stack is up and running in a few simple steps.</p>
The default project catch-all domain is `*.dev` (see [Configure](Configure.md) for how to change it). Let's view an example:
```shell
# Get the soures
$ git clone https://github.com/cytopia/devilbox
$ cd devilbox
# Create and customize the config file
$ cp env-example .env
$ vim .env
# Start your daemons
$ docker-compose up
# Inside your main project folder
$ ls -l
drwxr-xr-x 3 cytopia 4096 Jun 10 13:10 my-drupal
drwxr-xr-x 3 cytopia 4096 Jun 10 13:10 my-wordpress
drwxr-xr-x 3 cytopia 4096 Jun 10 13:10 project1
drwxr-xr-x 3 cytopia 4096 Jun 10 13:10 project2
drwxr-xr-x 3 cytopia 4096 Jun 10 13:10 yii-test
```
By having the above folders, the devilbox will automatically be able to serve the following vhosts:
### Run exactly what you need
* http://my-drupal.dev
* http://my-wordpress.dev
* http://project1.dev
* http://project2.dev
* http://yii-test.dev
<p class="center">Choose your required daemons and select a version. Any combination is possible.<br/>This will allow you, to always exactly simulate your production environment locally during development.</p>
<table>
<thead>
<tr>
<th>Apache</th>
<th>Nginx</th>
<th>PHP</th>
<th>MySQL</th>
<th>MariaDB</th>
<th>PgSQL</th>
<th>Redis</th>
<th>Memcached</th>
<th>MongoDB</th>
</tr>
</thead>
<tbody>
<tr>
<td><a target="_blank" title="Apache 2.2" href="https://github.com/cytopia/docker-apache-2.2">2.2</a></td>
<td><a target="_blank" title="Nginx stable" href="https://github.com/cytopia/docker-nginx-stable">stable</a></td>
<td><a target="_blank" title="PHP 5.4" href="https://github.com/cytopia/docker-php-fpm-5.4">5.4</a></td>
<td><a target="_blank" title="MySQL 5.5" href="https://github.com/cytopia/docker-mysql-5.5">5.5</a></td>
<td><a target="_blank" title="MariaDB 5.5" href="https://github.com/cytopia/docker-mariadb-5.5">5.5</a></td>
<td><a target="_blank" title="PgSQL 9.1" href="https://github.com/docker-library/postgres">9.1</a></td>
<td><a target="_blank" title="Redis 2.8" href="https://github.com/docker-library/redis">2.8</a></td>
<td><a target="_blank" title="Memcached 1.4.21" href="https://github.com/docker-library/memcached">1.4.21</a></td>
<td><a target="_blank" title="MongoDB 2.8" href="https://github.com/docker-library/mongo">2.8</a></td>
</tr>
<tr>
<td><a target="_blank" title="Apache 2.4" href="https://github.com/cytopia/docker-apache-2.4">2.4</a></td>
<td><a target="_blank" title="Nginx mainline" href="https://github.com/cytopia/docker-nginx-mainline">mainline</a></td>
<td><a target="_blank" title="PHP 5.5" href="https://github.com/cytopia/docker-php-fpm-5.5">5.5</a></td>
<td><a target="_blank" title="MySQL 5.6" href="https://github.com/cytopia/docker-mysql-5.6">5.6</a></td>
<td><a target="_blank" title="MariaDB 10.0" href="https://github.com/cytopia/docker-mariadb-10.0">10.0</a></td>
<td><a target="_blank" title="PgSQL 9.2" href="https://github.com/docker-library/postgres">9.2</a></td>
<td><a target="_blank" title="Redis 3.0" href="https://github.com/docker-library/redis">3.0</a></td>
<td><a target="_blank" title="Memcached 1.4.22" href="https://github.com/docker-library/memcached">1.4.22</a></td>
<td><a target="_blank" title="MongoDB 3.0" href="https://github.com/docker-library/mongo">3.0</a></td>
</tr>
<tr>
<td></td>
<td></td>
<td><a target="_blank" title="PHP 5.6" href="https://github.com/cytopia/docker-php-fpm-5.6">5.6</a></td>
<td><a target="_blank" title="MySQL 5.7" href="https://github.com/cytopia/docker-mysql-5.7">5.7</a></td>
<td><a target="_blank" title="MariaDB 10.1" href="https://github.com/cytopia/docker-mariadb-10.1">10.1</a></td>
<td><a target="_blank" title="PgSQL 9.3" href="https://github.com/docker-library/postgres">9.3</a></td>
<td><a target="_blank" title="Redis 3.2" href="https://github.com/docker-library/redis">3.2</a></td>
<td><a target="_blank" title="Memcached 1.4.23" href="https://github.com/docker-library/memcached">1.4.23</a></td>
<td><a target="_blank" title="MongoDB 3.2" href="https://github.com/docker-library/mongo">3.2</a></td>
</tr>
<tr>
<td></td>
<td></td>
<td><a target="_blank" title="PHP 7.0" href="https://github.com/cytopia/docker-php-fpm-7.0">7.0</a></td>
<td><a target="_blank" title="MySQL 8.0" href="https://github.com/cytopia/docker-mysql-8.0">8.0</a></td>
<td><a target="_blank" title="MariaDB 10.2" href="https://github.com/cytopia/docker-mariadb-10.2">10.2</a></td>
<td><a target="_blank" title="PgSQL 9.4" href="https://github.com/docker-library/postgres">9.4</a></td>
<td></td>
<td>...</td>
<td><a target="_blank" title="MongoDB 3.4" href="https://github.com/docker-library/mongo">3.4</a></td>
</tr>
<tr>
<td></td>
<td></td>
<td><a target="_blank" title="PHP 7.1" href="https://github.com/cytopia/docker-php-fpm-7.1">7.1</a></td>
<td></td>
<td><a target="_blank" title="MariaDB 10.3" href="https://github.com/cytopia/docker-mariadb-10.3">10.3</a></td>
<td><a target="_blank" title="PgSQL 9.5" href="https://github.com/docker-library/postgres">9.5</a></td>
<td></td>
<td><a target="_blank" title="Memcached 1.4.36" href="https://github.com/docker-library/memcached">1.4.36</a></td>
<td><a target="_blank" title="MongoDB 3.5" href="https://github.com/docker-library/mongo">3.5</a></td>
</tr>
<tr>
<td></td>
<td></td>
<td><a target="_blank" title="HHVM" href="https://github.com/cytopia/docker-hhvm-latest">HHVM</a></td>
<td></td>
<td></td>
<td><a target="_blank" title="PgSQL 9.6" href="https://github.com/docker-library/postgres">9.6</a></td>
<td></td>
<td><a target="_blank" title="Memcached latest" href="https://github.com/docker-library/memcached">latest</a></td>
<td></td>
</tr>
</tbody>
</table>
New folders can be created, deleted and removed during run-time and corresponding virtual hosts will be available instantly without having to restart anything.
### Run only what you need
## 2. Features
<p class="center">You are not forced to load the whole stack everytime. Only bring up what you really need.<br/>It is also possible to add or remove daemons while the stack is already running.</p>
```shell
# Load traditional lamp stack only
$ docker-compose up httpd php mysql
# Add redis to the running stack
$ docker-compose up redis
# Stop MySQL from the current stack
$ docker-compose stop mysql
```
| Feature | Description |
|---------|-------------|
| **Internet** | |
| No always-on | Internet connection is only required during initial setup or update (to pull containers), afterwards you can always work offline. |
| **Projects** | |
| Unlimitted Projects | Add as many Projects as you need. |
| Auto VirtualHosts | New VirtualHosts are added instantly without a restart or reload. Just create a new directory and you are ready to go. |
| Auto DNS | Use the built-in DNS server to stop worrying about `/etc/hosts` setup per project. |
| Email catch-all | All outgoing emails are intercepted and stored locally. Use the intranet to view any sent email. |
| Custom VirtualHost domains | Whatever project domain you desire: `*.dev`, `*.loc`, `*.local` or even subdomains like `*.sub.example` - you can adjust it to your needs. |
| **Run** | |
| Selective start | Run only the Docker container you actually need. |
| Version choice | Use your development stack with whatever version combination needed. |
| Stack choice | Attach SQL or NoSQL container and use Nginx or Apache to simulate your live env. |
| Log files | Log files are available for each chosen version. |
| **Configuration** | |
| HHVM | You can choose between PHP 5.6 and PHP 7 mode for HHVM |
| php.ini | You an overwrite PHP settings for each PHP version. |
| my.cnf | You an overwrite MySQL settings for each MySQL version. |
| **Intranet** | |
| phpMyAdmin | Manage your MySQL databases here. |
| Adminer | Manage your SQL and NoSQL databases here. |
| OpCacheGUI | Visualize the state of opcache usage. |
| EmailGUI | See all sent emails at a glance |
| **Docker Tools**|
| Work inside container | You can completely work inside the PHP container and use all bundled tools in order to keep your host system clean. |
| **Hacking** |
| Add custom container | You can add any other Docker container to `docker-compose.yml` and start using them in your development stack. |
### Introduction Videos
## 3. Supported Host OS
<p class="center">Head over to youtube for a quick introduction and see for yourself how easily new projects can be created.</p>
The devilbox runs on all major operating systems. Below you can quickly check the recommended docker versions and current issues per OS.
<div class="center">
<a target="_blank" href="https://www.youtube.com/watch?v=reyZMyt2Zzo" alt="Devilbox introduction video" title="Devilbox introduction video"><img src="img/devilbox_01-setup-and-workflow.png" /></a>
<a target="_blank" href="https://www.youtube.com/watch?v=e-U-C5WhxGY" alt="Devilbox Email catch-all introduction" title="Devilbox Email catch-all introduction"><img src="img/devilbox_02-email-catch-all.png" /></a>
</div>
| | ![linux][lin-logo] | ![windows][win-logo] | ![osx][osx-logo] |
|-------------|----------------------|---------------------------|----------------------|
| **Docker Version** | normal | [Docker for Windows][d4w] | [Docker dor Mac][d4m]|
| **Current Issues** | [here][lin-issues] | [here][win-issues] | [here][osx-issues] |
[win-logo]: https://raw.githubusercontent.com/cytopia/icons/master/64x64/windows.png
[lin-logo]: https://raw.githubusercontent.com/cytopia/icons/master/64x64/linux.png
[osx-logo]: https://raw.githubusercontent.com/cytopia/icons/master/64x64/osx.png
[d4w]: https://docs.docker.com/docker-for-windows/install/
[d4m]: https://docs.docker.com/docker-for-mac/install/
[dtb]: https://docs.docker.com/toolbox/overview/
[win-issues]: https://github.com/cytopia/devilbox/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20label%3A%22host%3Awindows%22
[lin-issues]: https://github.com/cytopia/devilbox/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20label%3A%22host%3Alinux%22
[osx-issues]: https://github.com/cytopia/devilbox/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20label%3A%22host%3Aosx%22
**How about FreeBSD?**
The devilbox has not been tested on FreeBSD yet. Current milestones include to make it rock-solid on the above listed operating systems. However, if you want it to run on FreeBSD open up an issue on Github and you will receive support making it work on FreeBSD.
### PHP Modules
## 4. Requirements
<div class="center">
<p>The devilbox is a development stack, so it is made sure that a lot of PHP modules are available out of the box in order to work with many different frameworks. There will however be slight differences between the versions and especially with HHVM. To see the exact bundled modules for each version visit the corresponding docker repositories on Github:</p>
<img class="battery" style="height:64px;" title="PHP" alt="PHP" src="img/logos/php.png" />
<img class="battery" style="height:64px;" title="HHVM" alt="HHVM" src="img/logos/hhvm.png" />
<p>
<strong><a target="_blank" title="PHP 5.4" href="https://github.com/cytopia/docker-php-fpm-5.4">PHP 5.4</a></strong> |
<strong><a target="_blank" title="PHP 5.5" href="https://github.com/cytopia/docker-php-fpm-5.5">PHP 5.5</a></strong> |
<strong><a target="_blank" title="PHP 5.6" href="https://github.com/cytopia/docker-php-fpm-5.5">PHP 5.6</a></strong> |
<strong><a target="_blank" title="PHP 7.0" href="https://github.com/cytopia/docker-php-fpm-5.5">PHP 7.0</a></strong> |
<strong><a target="_blank" title="PHP 7.1" href="https://github.com/cytopia/docker-php-fpm-5.5">PHP 7.1</a></strong> |
<strong><a target="_blank" title="HHVM" href="https://github.com/cytopia/docker-hhvm-latest">HHVM</a></strong>
</p>
<p>apc, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, intl, json, ldap, libxml, magickwand, mbstring, mcrypt, memcache, memcached, mhash, mongodb, msgpack, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib</p>
</div>
* **Internet connection** - only required during initial setup for cloning the devilbox repository and pulling the required docker container. Afterwards you can always work offline.
* [Docker Engine 1.12.0+](https://docs.docker.com/compose/compose-file/compose-versioning/#version-21)
* [Docker Compose 1.6.0+](https://docs.docker.com/compose/compose-file/compose-versioning/#version-2)
* On Windows use [Docker for Windows][d4w] (not tested on [Docker Toolbox][dtb])
* On OSX use [Docker for Mac][d4m] (not tested on [Docker Toolbox][dtb])
### Email catch-all
## 5. Docker documentation
<div class="center">
<img class="battery" style="height:64px;" title="Email catch-all" alt="Email catch-all" src="img/logos/email.png"/>
<p>The built-in postfix mailserver is configured to automatically intercept all outgoing emails. This is an important measurement during development to make sure not to accidentally send out real emails. Instead you will be able to see all sent emails in the included intranet mail view. See Intranet section below.</p>
</div>
If you have never worked with docker/docker-compose before, you should check up on their documentation to get you started: [docker docs](https://docs.docker.com/).
### Auto-DNS
## 6. Devilbox documentation
<div class="center">
<img class="battery" style="height:64px;" title="Auto-DNS" alt="Auto-DNS" src="img/logos/dns.png" />
<p>Creating a new project just requires you to create a new folder on the filesystem. As you probalby don't want to bother with editing your /etc/hosts file everytime, the built-in DNS server will automatically provide the correct DNS records for every project.</p>
</div>
| Topic | Description |
|-------------------------|-------------|
| **[Quickstart](Quickstart.md)** | Command overview to get you started quickly |
| **[Install](Install.md)** | How to install docker, docker-compose and the devilbox |
| **[Update](Update.md)** | Update best practise |
| **[Configure](Configure.md)** | How to configure the devilbox, switch versions (PHP, MySQL, PgSQL, ...) and how to set custom options (php.ini, my.cnf, httpd.conf, ...) |
| **[Run](Run.md)** | How to operate the devilbox, start and stop all or only required Docker container. |
| **[Usage](Usage.md)** | How to create projects, Email and DNS usage, tools (`composer`, `npm`, `node`, `drush`, ...), entering the container, Log files, Xdebug, Backups, Intranet, ...|
| **[OS](OS.md)** | Operating System differences between Linux, Windows and OSX. |
| **[Backups](Backups.md)** | How to backup and restore your databases for different versions. |
| **[Examples](Examples.md)** | Some project examples for popular CMS/Frameworks. How to setup Wordpress, Drupal, Yii, ... |
| **[Technical](Technical.md)** | Technical background information |
| **[Hacking](Hacking.md)** | How to extend the devilbox with your own docker container |
| **[FAQ](FAQ.md)** | Questions and Troubleshooting |
### Batteries included
## 7. Video Tutorials
<p class="center">No need to download external tools. Everything is bundled, up-to-date and available inside the containers.</p>
Have a look at youtube to see some the features in action.
<div class="center">
<a target="_blank" title="phpMyAdmin" href="https://www.phpmyadmin.net"><img class="battery" style="height:64px;" src="img/logos/phpmyadmin.png" alt="Devilbox"/></a>
<a target="_blank" title="Adminer" href="https://www.adminer.org"><img class="battery" style="height:64px;" src="img/logos/adminer.png" alt="Devilbox"/></a>
<a target="_blank" title="OpCache GUI" href="https://github.com/amnuts/opcache-gui"><img class="battery" style="height:64px;" src="img/logos/opcachegui.png" alt="Devilbox"/></a>
<br/>
<a target="_blank" title="Composer" href="https://getcomposer.org"><img class="battery" style="height:64px;" src="img/logos/composer.png" alt="Devilbox"/></a>
<a target="_blank" title="Drush" href="https://www.drupal.org/project/drush"><img class="battery" style="height:64px;" src="img/logos/drush.png" alt="Devilbox"/></a>
<a target="_blank" title="Drupal Console" href="https://drupalconsole.com"><img class="battery" style="height:64px;" src="img/logos/drupal-console.png" alt="Devilbox"/></a>
<a target="_blank" title="NodeJS" href="https://nodejs.org"><img class="battery" style="height:64px;" src="img/logos/nodejs.png" alt="Devilbox"/></a>
<a target="_blank" title="WP-CLI" href="https://wp-cli.org"><img class="battery" style="height:64px;" src="img/logos/wp-cli.png" alt="Devilbox"/></a>
<a target="_blank" title="NPM" href="https://www.npmjs.com"><img class="battery" style="height:64px;" src="img/logos/npm.png" alt="Devilbox"/></a>
<a target="_blank" title="Git" href="https://git-scm.com"><img class="battery" style="height:64px;" src="img/logos/git.png" alt="Devilbox"/></a>
</div>
[![Devilbox setup and workflow](img/devilbox_01-setup-and-workflow.png "devilbox - setup and workflow")](https://www.youtube.com/watch?v=reyZMyt2Zzo)
[![Devilbox email catch-all](img/devilbox_02-email-catch-all.png "devilbox - email catch-all")](https://www.youtube.com/watch?v=e-U-C5WhxGY)
### Supported Frameworks and CMS
## 8. Available PHP Modules
<p class="center">There is nothing special about the devilbox, so any framework or CMS that will work with normal LAMP/MEAN stacks will work here as well. However in order to make double sure, a few popular applications have been explicitly tested.</p>
The devilbox is a development stack, so it is made sure that a lot of PHP modules are available out of the box in order to work with many different frameworks.
<div class="center">
<a target="_blank" title="CakePHP" href="https://cakephp.org" ><img alt="CakePHP" class="battery" style="height:64px;" src="img/logos/cake.png" /></a>
<a target="_blank" title="Drupal" href="https://www.drupal.org/" ><img alt="Drupal" class="battery" style="height:64px;" src="img/logos/drupal.png" /></a>
<a target="_blank" title="PhalconPHP" href="https://phalconphp.com" ><img alt="PhalconPHP" class="battery" style="height:64px;" src="img/logos/phalcon.png" /></a>
<a target="_blank" title="Wordpress" href="https://wordpress.org" ><img alt="Wordpress" class="battery" style="height:64px;" src="img/logos/wordpress.png" /></a>
<a target="_blank" title="Yii" href="http://www.yiiframework.com" ><img alt="Yii" class="battery" style="height:64px;" src="img/logos/yii.png" /></a>
</div>
*apc, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, intl, json, ldap, libxml, magickwand, mbstring, mcrypt, memcache, memcached, mhash, mongodb, msgpack, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib*
There will however be slight differences between the versions and especially with HHVM. To see the exact bundled modules for each version visit the corresponding docker repositories on Github:
[PHP 5.4](https://github.com/cytopia/docker-php-fpm-5.4) |
[PHP 5.5](https://github.com/cytopia/docker-php-fpm-5.5) |
[PHP 5.6](https://github.com/cytopia/docker-php-fpm-5.6) |
[PHP 7.0](https://github.com/cytopia/docker-php-fpm-7.0) |
[PHP 7.1](https://github.com/cytopia/docker-php-fpm-7.1) |
[HHVM](https://github.com/cytopia/docker-hhvm-latest)
### Devilbox Intranet
## 9. Supported Frameworks and CMS
<p class="center">Once the devilbox is up and running, you can visit the bundled intranet on <a target="_blank" href="http://localhost">http://localhost</a>.<br/>The intranet is not just a simple dash, it provides many useful tools:</p>
<div class="center">
Container Health | DNS Status | Available vHosts | Emails | Databases | Effective Configuration<br/>
<img alt="" title="" src="img/02_intranet_vhosts.png "/>
<img alt="" title="" src="img/04_intranet_emails.png "/>
</div>
### Security
<p class="center">Be aware that the docker service is running with root privileges on your system (like any other webserver for example). The devilbox is using a mix of official docker images and custom images. All integrated containers are available on <a target="_blank" href="https://github.com/cytopia/devilbox#run-time-matrix">Github</a> and can be reviewed at any time.</p>
### Up-to-dateness
<p class="center">Docker containers are pushed to <a target="_blank" href="https://hub.docker.com/r/cytopia">Docker Hub</a> frequently.<br/>It should be enough for you to pull updated images on a regeular basis.</p>
```shell
$ docker-compose pull
```
<p class="center">However, if a new minor version (PHP for example) has just been released and you want to use it right away, you can simply *git clone* the docker repository and rebuild the container. Each container repository contains a shell script for easy building.</p>
```shell
# Download PHP 7.1 repository
$ git clone https://github.com/cytopia/docker-php-fpm-7.1
# Rebuild the container in order to get the latest minor/patch version
$ cd docker-php-fpm-7.1
$ ./build/docker-rebuild.sh
```
### Integration Tests
<div class="center">
<a target="_blank" href="https://travis-ci.org/cytopia/devilbox"><img src="https://travis-ci.org/cytopia/devilbox.svg?branch=master" /></a>
</div>
<p class="center">In order to make sure everything always runs stable and as expected, the devilbox makes heavy use of integration tests. You can head over to <a target="_blank" href="https://travis-ci.org/cytopia/devilbox">Travis-CI</a> and have a look at stable and nightly builds.</p>
### Contribute
<div class="center">
<p>Contributers are welcome in any way.</p>
<p>First of all, if you like the project, please <a href="https://github.com/cytopia/devilbox">do star it</a>. Starring is an important measurement to see the number of active users and better allows me to organize my time and effort I can put into this project.</p>
<p>You can also get actively involved. <a href="https://github.com/cytopia/devilbox">Do clone the project</a> and start improving whatever you think is useful. There is quite a lot todo and planned. If you like to contribute, view <a href="https://github.com/cytopia/devilbox/blob/master/CONTRIBUTING.md">CONTRIBUTING.md</a> and <a href="https://github.com/cytopia/devilbox/issues/23">ROADMAP</a>.</p>
<p>Major contributors will be credited within the intranet and on the github page.</p>
</div>
### License
<div class="center">
<p>MIT License</p>
<p>Copyright (c) 2016 cytopia</p>
</div>
As far as tested there are no limitations and you can use any Framework or CMS just as you would on your live environment. Below are a few examples of extensively tested Frameworks and CMS:
![CakePHP](img/logos/cake.png)
![Drupal](img/logos/drupal.png)
![Phalcon](img/logos/phalcon.png)
![Wordpress](img/logos/wordpress.png)
![Yii](img/logos/yii.png)
Have a look at [Examples](Examples.md) for how to set them up.

183
docs/Run.md Normal file
View File

@ -0,0 +1,183 @@
# Devilbox Documentation
[Overview](README.md) |
[Quickstart](Quickstart.md) |
[Install](Install.md) |
[Update](Update.md) |
[Configure](Configure.md) |
Run |
[Usage](Usage.md) |
[OS](OS.md) |
[Backups](Backups.md) |
[Examples](Examples.md) |
[Technical](Technical.md) |
[Hacking](Hacking.md) |
[FAQ](FAQ.md)
---
## Run
1. [Start the devilbox](#1-start-the-devilbox)
1. [Foreground Start](#1-1-foreground-start)
2. [Background Start](#1-2-background-start)
3. [Selective Start](#1-3-selective-start)
2. [Stop the devilbox](#2-stop-the-devilbox)
1. [Foreground Stop](#2-1-foreground-stop)
2. [Background Stop](#2-2-background-stop)
3. [Attach/Detach during run-time](#3-attach-detach-during-run-time)
1. [Attach during run-time](#3-1-attach-during-run-time)
2. [Detach during run-time](#3-2-detach-during-run-time)
4. [Docker logs](#4-docker-logs)
1. [All logs](#4-1-all-logs)
1. [Specific logs](#4-2-specific-logs)
1. [Tail logs](#4-3-tail-logs)
---
## 1. Start the devilbox
Starting and stopping containers is done via docker-compose. If you have never worked with it before, have a look at their documentation for an [overview](https://docs.docker.com/compose/reference/overview/), [up](https://docs.docker.com/compose/reference/up/) and [stop](https://docs.docker.com/compose/reference/stop/) commands.
By starting up the devilbox all attached containers will send their stdout and stderr to docker logs (foreground or background), you can increase/decrease the containers startup verbosity by configuring the `.env` file. See [Configure](Configure.md) for how to change that behavior.
#### 1.1 Foreground Start
The normal start will bring up **all** container defined in *docker-compose.yml* and will stay in forground making it possible to stop them via Ctrl+c.
```shell
$ docker-compose up
```
#### 1.2 Background Start
Instead of having the docker-compose run stay in foreground, you can also send it to the background by adding `-d` as an argument. The following will bring up **all** container and send docker-compose to background.
```shell
$ docker-compose up -d
```
#### 1.3 Selective Start
There is no need to always bring up **all** container, if you just need a few at the moment. In order to do so, simply specify the container by name that you actually need.
##### 1.3.1 Starting httpd, php, bind and mysql
```shell
# Foreground
$ docker-compose up httpd php bind mysql
# Background
$ docker-compose up -d httpd php bind mysql
```
**Start Note:** `httpd`, `php` and `bind` are base container that will **always** be started if specified or not. (Defined by `depends_on` in `docker-compose.yml`). So the above could also be achieved by simply specifying `mysql` only.
```shell
# Foreground
$ docker-compose up mysql
# Background
$ docker-compose up -d mysql
```
**Log Note:** When you do not specify httpd, php and bind in foreground start, their docker-logs will not be shown and you will have to explicitly use `docker-compose logs` to view their stdout/stderr output. Refer to the Log section below.
##### 1.3.2 Starting httpd, php, bind, pgsql and redis
```shell
# Foreground
$ docker-compose up httpd php bind pgsql redis
# Background
$ docker-compose up -d httpd php bind pgsql redis
```
**Start Note:** `httpd`, `php` and `bind` are base container that will **always** be started if specified or not. (Defined by `depends_on` in `docker-compose.yml`). So the above could also be achieved by simply specifying `pgsql` and `redis` only.
```shell
# Foreground
$ docker-compose up pgsql redis
# Background
$ docker-compose up -d pgsql redis
```
**Log Note:** When you do not specify httpd, php and bind in foreground start, their docker-logs will not be shown and you will have to explicitly use `docker-compose logs` to view their stdout/stderr output. Refer to the Log section below.
## 2. Stop the devilbox
#### 2.1 Foreground stop
If you started up docker compose in foreground mode (without `-d`), you can hit `ctrl+c` to gracefull stop or **twice** `ctrl+c` to kill the running containers.
**Note:** Automatically started containers that were not specified (such as `http` or `php`) will have to be stopped manually via `docker-compose down` afterwards.
#### 2.2 Background stop
If you started up docker compose in background mode (with `-d`), go back to the devilbox directory (where the `docker-compose.yml` file resides and type `docker-compose down` to gracefully stop or `docker-compose kill` to kill them immediately.
```shell
# Gracefully shutdown everything
$ docker-compose down
# Kill everything immediately
$ docker-compose kill
```
Best pracice would be to start the container in the background (with `-d`) and use `docker compose down` to gracefully stop all of them.
## 3. Attach/Detach during run-time
#### 3.1 Attach during run-time
You can also add/attach containers during runtime if you need them. You might have started httpd, php, bind and mysql and decided that you will also require redis. So go ahead and add redis to the running container stack.
```shell
# Foreground
$ docker-compose up redis
# Background
$ docker-compose up -d redis
```
It is recommended to always use background starts, this way you can intially start your desired stack and re-use the current terminal window to start or stop other services.
#### 3.2 Detach during run-time
You can also stop specific containers during runtime if they are not needed anymore. You might have started httpd, php, bind, mysql and redis and decided that redis was not needed. So go ahead and remove redis from the running container stack.
```shell
$ docker-compose stop redis
```
## 4. Docker Logs
Services started in background mode (`-d`) or those that were started as dependencies (`http` and `php`) will always only log to docker logs and not to stdout/stderr.
#### 4.1 All logs
In order to view logs of all started containers type:
```shell
$ docker-compose logs
```
#### 4.2 Specific logs
In order to view logs of a specific container, name it explicitly:
```shell
$ docker-compose logs redis
```
#### 4.3 Tail logs
There is also a version similar to `tail -f` to keep logs updated all the time.
```shell
$ docker-compose logs -f
```

108
docs/Technical.md Normal file
View File

@ -0,0 +1,108 @@
# Devilbox Documentation
[Overview](README.md) |
[Quickstart](Quickstart.md) |
[Install](Install.md) |
[Update](Update.md) |
[Configure](Configure.md) |
[Run](Run.md) |
[Usage](Usage.md) |
[OS](OS.md) |
[Backups](Backups.md) |
[Examples](Examples.md) |
Technical |
[Hacking](Hacking.md) |
[FAQ](FAQ.md)
---
## Technical
1. [Networking](#1-networking)
2. [Ports and forwarding](#2-ports-and-forwarding)
1. [PHP Container](#2-1-php-container)
2. [Docker Host](#2-2-docker-host)
3. [Works the same on Host and PHP Container](#3-works-the-same-on-host-and-php-container)
---
## 1. Networking
It is best to use the hostnames and not to rely on the ip addresses as they might change. In most cases however you can use `127.0.0.1` for all connections. Read up to find out why.
> E.g.: When you want to setup a MySQL database connection use `mysql` or `127.0.0.1` as the hostname.
| Container | Container name | Hostname | IP Address |
|-----------------|-----------------|-----------|----------------|
| DNS | bind | bind | 172.16.238.100 |
| PHP / HHVM | php | php | 172.16.238.10 |
| Apache / Nginx | http | http | 172.16.238.11 |
| MySQL / MariaDB | mysql | mysql | 172.16.238.12 |
| PostgreSQL | pgsql | pgsql | 172.16.238.13 |
| Redis | redis | redis | 172.16.238.14 |
| Memcached | memcd | memcd | 172.16.238.15 |
| MongoDB | mongo | mongo | 172.16.238.16 |
## 2. Ports and forwarding
#### 2.1 PHP Container
The `php` container is the center of all container. Everything happens in there.
This is also the reason it does some more magic than actually required.
**Remote ports and remote sockets are made available to the `php` container.**
The PHP container is using [socat](https://linux.die.net/man/1/socat) to
1. forward the remote mysql port `3306` (on the mysql container) to its own `127.0.0.1:3306`
2. forward the remote pgsql port `5432` (on the pgsql container) to its own `127.0.0.1:5432`
3. forward the remote redis port `6379` (on the redis container) to its own `127.0.0.1:6379`
4. forward the remote memcached port `11211` (on the memcd container) to its own `127.0.0.1:11211`
5. forward the remote mongodb port `27017` (on the mongo container) to its own `127.0.0.1:27017`
The following container can be reached from within the PHP container via the following methods:
| Container | Hostname | IP Address | IP Address | Port |
|-----------------|-----------|----------------|------------|-------|
| DNS | bind | 172.16.238.100 | - | 53 |
| PHP / HHVM | php | 172.16.238.10 | - | 9000 |
| Apache / Nginx | http | 172.16.238.11 | - | 80 |
| MySQL / MariaDB | mysql | 172.16.238.12 | 127.0.0.1 | 3306 |
| PostgreSQL | pgsql | 172.16.238.13 | 127.0.0.1 | 5432 |
| Redis | redis | 172.16.238.14 | 127.0.0.1 | 6379 |
| Memcached | memcd | 172.16.238.15 | 127.0.0.1 | 11211 |
| MongoDB | mongo | 172.16.238.16 | 127.0.0.1 | 27017 |
#### 2.2 Docker Host
The docker host (your computer) does exactly the same as the `php` container.
1. container mysql port `3306` is exposed to the host on port `127.0.0.1:3306`
2. container pgsql port `5432` is exposed to the host on port `127.0.0.1:5432`
3. container redis port `6379` is exposed to the host on port `127.0.0.1:6379`
3. container memcd port `11211` is exposed to the host on port `127.0.0.1:11211`
3. container mongo port `27017` is exposed to the host on port `127.0.0.1:27017`
The following container can be reached from the Docker host via the following methods:
| Container | IP Address | Port |
|-----------------|------------|-------|
| DNS | 127.0.0.1 | 1053 |
| PHP / HHVM | - | 9000 |
| Apache / Nginx | 127.0.0.1 | 80 |
| MySQL / MariaDB | 127.0.0.1 | 3306 |
| PostgreSQL | 127.0.0.1 | 5432 |
| Redis | 127.0.0.1 | 6379 |
| Memcached | 127.0.0.1 | 11211 |
| MongoDB | 127.0.0.1 | 27017 |
## 3. Works the same on Host and PHP Container
As you might have noticed, the ports and addresses will be exactly the same inside the PHP container and on the docker host (when using `127.0.0.1`) for most container. That way it is possible to write your php application like this:
```php
<?php
mysql_connect('127.0.0.1', 'user', 'pass');
```

166
docs/Update.md Normal file
View File

@ -0,0 +1,166 @@
# Devilbox Documentation
[Overview](README.md) |
[Quickstart](Quickstart.md) |
[Install](Install.md) |
Update |
[Configure](Configure.md) |
[Run](Run.md) |
[Usage](Usage.md) |
[OS](OS.md) |
[Backups](Backups.md) |
[Examples](Examples.md) |
[Technical](Technical.md) |
[Hacking](Hacking.md) |
[FAQ](FAQ.md)
---
## Update
1. [TL;DR](#1-tl-dr)
2. [Git tag vs master branch](#2-git-tag-vs-master-branch)
1. [Git tag](#2-1-git-tag)
2. [Git master branch](#2-2-git-master-branch)
3. [Compare .env file](#3-compare-env-file)
4. [Pull new Docker container (Important!)](#4-pull-new-docker-container-important-)
5. [Remove anonymous volumes](#5-remove-anonymous-volumes)
---
## 1. TL;DR
Shutdown, update and startup.
```shell
# Stop container, remove deprecated volumes and update git
$ docker-compose down
$ docker-compose rm
$ git fetch --all
$ git pull origin master
# Check for changes
$ vimdiff .env env-example
# Pull all available container
$ ./update-docker.sh
# Or just pull currently enabled versions in .env
$ docker-compose pull
# Ready and run
$ docker-compose up
```
Do not forget to read: [Pull new Docker container (Important!)](#4-pull-new-docker-container-important-)
## 2. Git tag vs master branch
#### 2.1 Git tag
Git tags tie each Docker container to a stable Docker tag. This will look like this in the `docker-compose.yml`
```shell
$ grep '^[[:space:]]*image:' docker-compose.yml
image: cytopia/bind:0.9
image: cytopia/${PHP_SERVER:-php-fpm-7.0}:0.9
image: cytopia/${HTTPD_SERVER:-nginx-stable}:0.9
image: cytopia/${MYSQL_SERVER:-mariadb-10.1}:0.9
```
That means within your current git tag, you will not receive any Docker container updates, because the devilbox is bound to specific Docker tagged versions.
When a new devilbox tag is released, the `docker-compose.yml` file will have new Docker tags. There is no manuall action required. If you start up the devilbox for the first time, it will see that the container with those tags are not available locally and automatically start downloading them.
So the update procedure is as follows:
```shell
$ git fetch --all
$ git checkout "$(git describe --abbrev=0 --tags)"
```
**Note:** If you want to pre-download all available versions for later offline-usage, run the `update-docker.sh` script.
```shell
$ ./update-docker.sh
```
#### 2.2 Git master branch
The git master branch ties each Docker container to their `latest` tag. Latest tagged Docker container always reflect the latest changes and can be compared with a master branch of a git repository. This will look like this in the `docker-compose.yml`
```shell
$ grep '^[[:space:]]*image:' docker-compose.yml
image: cytopia/bind:latest
image: cytopia/${PHP_SERVER:-php-fpm-7.0}:latest
image: cytopia/${HTTPD_SERVER:-nginx-stable}:latest
image: cytopia/${MYSQL_SERVER:-mariadb-10.1}:latest
```
When you update the devilbox repository by `git pull origin master`, the Docker tags are still `latest` and you will continue using the current version of Docker container. You must also issue `docker-compose pull` in order to also update your Docker container.
So the update procedure is as follows:
```shell
$ git fetch --all
$ git pull origin master
$ docker-compose pull
```
**Note:** If you want to pre-download all available versions for later offline-usage, run the `update-docker.sh` script.
```shell
$ ./update-docker.sh
```
## 3. Compare .env file
New devilbox releases will most likeley receive new or improved functionality and features and therefore will have an altered `env-example` file. (This is an example configuration file which holds all current configuration options).
The effective configuration for docker-compose is stored in the `.env` file. However, the `.env` file is ignored by git, so that you can do changes without setting the git state dirty.
So when you update (master branch or tag) you will always have to compare your current `.env` settings with the new `env-example` file. If you are familiar with vim, just do the following:
```shell
$ vimdiff .env env-example
```
Make sure to transfer all new options from `env-example` to your current `.env` file.
## 4. Pull new Docker container (Important!)
As described above, for git master branch updates you will always have to pull new Docker container. **However, there is something very important to keep in mind:**
1. You have just updated the master branch and pulled new Docker container
2. You edit the `.env` file to switch to a different PHP version
3. You start up the devilbox. Is your new PHP Docker up to date?
No! You will have to `docker-compose pull` again. Why?
Lets have another look into `docker-compose.yml`:
```yml
image: cytopia/${PHP_SERVER:-php-fpm-7.0}:latest
image: cytopia/${HTTPD_SERVER:-nginx-stable}:latest
image: cytopia/${MYSQL_SERVER:-mariadb-10.1}:latest
```
As you can see, the Docker container names are variablized. If you updated `php-fpm-5.4:latest`, you still have to update `php-fpm-5.5:latest` (and all others) as they were not yet enabled/visible in `docker-compose.yml`.
So instead of pulling everything manually, use the bundled update script to do that for all available Docker container. That will also allow you to work offline, as every available docker image will be download in their latest version.
```shell
$ ./update-docker.sh
```
## 5. Remove anonymous volumes
The devilbox is not yet at a feature-ready stable release and volumes mounts might change from release to release until version 1.0 will be released. This can cause errors during startup. To solve those issues after updating, you should remove all anonymouse volumes with the following command:
```shell
$ docker-compose rm
```

View File

@ -1,68 +0,0 @@
# Devilbox Documentation
[Home](https://github.com/cytopia/devilbox) |
[Overview](README.md) |
[Configuration](Configuration.md) |
[Usage](Usage.md) |
Updating |
[Info](Info.md) |
[PHP Projects](PHP_Projects.md) |
[Emails](Emails.md) |
[Logs](Logs.md) |
[Intranet](Intranet.md) |
[FAQ](FAQ.md)
----
## Updating
### Tags vs Branches
The devilbox git repository offers two types of setups.
1. Git `tags` for stable release
2. The `master` branch with the latest features
### Git tags
Each new devilbox release is tagged in git and bound to tagged docker images.
Updating only involves to check out the latest tag and make sure to stop and remmove your containers prior starting them up again. Latest docker images will be pulled automatically as their docker tag number will also change between releases.
Additionally you will also have compare `env-example` against your current `.env` file and in case of differences apply them.
```shell
# Update source
$ git fetch --all
$ git checkout <tag>
# Stop and remove your container
$ docker-compose stop
$ docker-compose rm
# Check for config file changes
$ vimdiff .env env-example
```
Currently releases are not that frequent, so you might be better of with the `master` branch.
### Git master branch
The `master` branch does not use tagged docker images, but `latest`. So once you git pull you should also pull the latest docker images.
```shell
# Update source
$ git fetch --all
$ git pull origin master
# Stop and remove your container
$ docker-compose stop
$ docker-compose rm
# Pull latest docker images
$ docker-compose pull
# Check for config file changes
$ vimdiff .env env-example
```

View File

@ -1,131 +1,393 @@
# Devilbox Documentation
[Home](https://github.com/cytopia/devilbox) |
[Overview](README.md) |
[Configuration](Configuration.md) |
[Quickstart](Quickstart.md) |
[Install](Install.md) |
[Update](Update.md) |
[Configure](Configure.md) |
[Run](Run.md) |
Usage |
[Updating](Updating.md) |
[Info](Info.md) |
[PHP Projects](PHP_Projects.md) |
[Emails](Emails.md) |
[Logs](Logs.md) |
[Intranet](Intranet.md) |
[OS](OS.md) |
[Backups](Backups.md) |
[Examples](Examples.md) |
[Technical](Technical.md) |
[Hacking](Hacking.md) |
[FAQ](FAQ.md)
----
---
## Usage
This section is about how to start, stop, view and enter (all or a selection of some) containers. If you want to know how to choose the container type version (e.g. which mysql version or which php version) refer to the **[Configuration](Configuration.md)** section.
1. [Mounted directories](#1-mounted-directories)
2. [Work on the Docker host](#2-work-on-the-docker-host)
3. [Work inside the PHP container](#3-work-inside-the-php-container)
1. [As devilbox user](#3-1-as-devilbox-user)
2. [As root user](#3-2-as-root-user)
3. [Available tools](#3-3-available-tools)
4. [Available URLs](#3-4-available-urls)
4. [Managing Projects explained](#4-managing-projects-explained)
1. [How does it work?](#4-1-how-does-it-work-)
2. [Directory structure explained](#4-2-directory-structure-explained)
5. [Creating new Projects](#5-creating-new-projetcs)
1. [From Docker Host](#5-1-from-docker-host)
2. [From inside the PHP container](#5-2-from-inside-the-php-container)
3. [Using symlinks](#5-3-using-symlinks)
4. [Adding DNS records](#5-4-adding-dns-record)
1. [/etc/hosts](#5-4-1-etc-hosts)
2. [Auto-DNS](#5-4-2-auto-dns)
6. [Switching container versions](#6-switching-container-versions)
1. [Httpd versions](#6-1-httpd-versions)
2. [PHP versions](#6-2-php-versions)
2. [SQL versions](#6-3-sql-versions)
3. [NoSQL versions](#6-4-nosql-versions)
7. [Emails](#7-emails)
8. [Log files](#8-log-files)
1. [Mounted logs](#8-1-mounted-logs)
2. [Docker logs](#8-2-docker-logs)
9. [Intranet](#9-intranet)
1. [Overview](#9-1-overview)
2. [vHosts](#9-2-vhosts)
3. [Tools](#9-3-tools)
**Convention:** The terms *container* and *service* are used interchangeably.
---
**Assumption:** All `docker-compose` commands must be executed within the devilbox root directory, where the `docker-compose.yml` file resides.
## 1. Mounted directories
### 1. Start and Stop
Mounted directories are the bridge between the container and your host computer.
All your projects will be available on your host computer as well as inside the Docker container.
#### 1.1 Start all container
That makes it possible to work from the Docker host, by for example editing your files with your favorite editor/IDE and to run any commands, such as `npm`, `composer` or others inside the PHP container with the correct PHP version.
## 2. Work on the Docker host
If you do not need to run any command line tools manually (composer, node, etc), it is sufficient to stay on the host. All you need is a browser and an editor/IDE.
1. Open your browser at http://localhost
2. Open your project inside your editor
3. Start coding
**Note:** If you want to do some command-line PHP tasks and you have PHP installed on your host, make sure it is the same version as your currently started PHP Docker container. If not, just enter the PHP Docker and do the tasks there.
You could however also invoke the Docker's PHP executeable (or any other binary) from your host via:
```shell
$ docker-compose up
# Call a generic command
$ docker-compose exec --user devilbox php <command>
| | | | |
use execute use container the
docker-compose cmd built-in name actual
on the user to command
docker devilbox exec to
container command execute
```
This will bring up **all containers** defined in `docker-compose.yml`.
Here is an example to list the PHP inside the container from the Docker host.
```shell
# Print PHP version
$ docker-compose exec --user devilbox php php -v
```
However, you will probably not need all of the defined services and especially on slow machines you only want to start what you really need. This is possible as well.
#### 1.2 Start selected container
## 3. Work inside the PHP container
In order to only start the services you actually need, you must specify them with the docker-compose command.
If you need to run some command line tasks manually such as `drush`, `composer` or anything similar which is not available on your host computer, you can do that inside the PHP container, which comes with lots of useful pre-install tools.
**Note:** The `http` and `php` container will automatically be started and must not be explicitly specified. (If not specified, their log output will also not go to stderr/stdout, but instead to docker logs)
The situation inside the container is not different from on the Docker host. All services and port bindings are available there as well on `127.0.0.1`. Read up on [Technical](Technical.md) to find out more about the syncronization of both.
**FYI:** You will always find your projects inside the PHP container at `/shared/httpd/`.
#### 3.1 As devilbox user
In the devilbox git directory you will find a bash script called `bash.sh`. Just execute this script and it will take you directly into the PHP docker container at the project root directory.
```shell
# Only start HTTP and PHP
$ docker-compose up http php
# Start HTTP, PHP and Redis
$ docker-compose up redis
# Start HTTP, PHP and MySQL
$ docker-compose up mysql
# Start HTTP, PHP, PostgreSQL and Memcache
$ docker-compose up pgsql memcache
host> ./bash.sh
devilbox@php-7.0.19 in /shared/httpd $
```
I think you get the idea.
#### 1.3 Start in background
As you can see, the PS1 prompt will also show you the current configured PHP version.
You can also run the docker compose command in the background and close your terminal after startup. To do so simply add the `-d` flag:
#### 3.2 As root user
In case you need to perform some tasks that are only possible with root rights (such as installing or updating software), you can also use the `root_bash.sh` script.
```shell
$ docker-compose up -d
host> ./root_bash.sh
root@php-7.0.19 in /shared/httpd $
```
Or in case of selectively starting
**Note:** Performing installations and updates are only temporary for the current session. Any change will be lost at the next start/restart of the devilbox. If you permanently require additional software refer to [Hacking](Hacking.md).
#### 3.3 Available tools
For your convenience a few selected tools have been pre-installed in their current version that you can use for your daily development tasks. Some of them are:
| Binary | Tool name |
|------------|-------------------|
| `composer` | [composer](https://getcomposer.org) |
| `drush` | [drush](http://www.drush.org/) |
| `drupal` | [drupal-consol](https://drupalconsole.com) |
| `git` | [git](https://git-scm.com) |
| `laravel` | [laravel installer](https://github.com/laravel/installer) |
| `mysqldump-secure` | [mysqldump-secure](https://mysqldump-secure.org) |
| `node` | [node](https://nodejs.org) |
| `npm` | [npm](https://www.npmjs.com) |
| `phalcon` | [phalcon devtools](https://github.com/phalcon/phalcon-devtools) |
| `symfony` | [symfony installer](https://github.com/symfony/symfony-installer) |
| `wp` | [wp-cli](https://wp-cli.org/) |
The complete list of tools including their version can be found at the PHP docker containers git repository Readme:
[PHP 5.4](https://github.com/cytopia/docker-php-fpm-5.4) |
[PHP 5.5](https://github.com/cytopia/docker-php-fpm-5.5) |
[PHP 5.6](https://github.com/cytopia/docker-php-fpm-5.6) |
[PHP 7.0](https://github.com/cytopia/docker-php-fpm-7.0) |
[PHP 7.1](https://github.com/cytopia/docker-php-fpm-7.1) |
[HHVM](https://github.com/cytopia/docker-hhvm-latest)
If you permanently require additional software refer to [Hacking](Hacking.md).
If you think additional tools should always be bundled, [create an issue](https://github.com/cytopia/devilbox/issues).
#### 3.4 Available URLs
Your projects will be available by the same URL as they are available from your docker host computer. There is no need to edit the PHP container's `/etc/hosts` file, as it is automatically provide via the DNS container `bind`.
For example, by doing `curl http://project1.dev` from either your host computer or from inside the PHP container will return the same URL.
## 4. Managing Projects explained
[![Devilbox setup and workflow](img/devilbox_01-setup-and-workflow.png "devilbox - setup and workflow")](https://www.youtube.com/watch?v=reyZMyt2Zzo)
#### 4.1 How does it work?
Creating new projects is really simple and just involves a few steps.
1. Create a new **project folder** for your VirtualHost
2. Create a subfolder named **htdocs/** for the DocumentRoot
2. Create a **DNS record** pointing to your VirtualHost (via `/etc/hosts`)
The **project folder** will be the name of your VirtualHost. The **htdocs/** folder holds all files that will be server by the VirtualHost (called DocumentRoot). The **DNS record** will be the domain name that points to the webserver's IP address (127.0.0.1).
#### 4.2 Directory structure explained
Your project folder is determined by the value of `HOST_PATH_TO_HTTPD_DATADIR` which can be set in `.env`. The default is `./data/www`.
| Location | Project directory |
|--------------|-------------------|
| Host system | `HOST_PATH_TO_HTTPD_DATADIR` (default: `./data/www`) |
| PHP Docker | `/shared/httpd` |
| HTTPD Docker | `/shared/httpd` |
**What directory structure is required to serve a new project?**
1. Each folder inside your project directory is an independent VirtualHost.
2. Each VirtualHost folder requires the `htdocs/` folder which is the DocumentRoot.
In order to make the following examples easier let's work with some assumed default values. The first one represents the project base directory and the second one is for the project domains.
1. HOST_PATH_TO_HTTPD_DATADIR=**./data/www**
2. TLD_SUFFIX=**local**
| VirtualHost directory | DocumentRoot directory | URL |
|-----------------------|-----------------------------|------------------------|
| <code>./data/www/<b>project1</b></code> | <code>./data/www/project1/<b>htdocs</b></code> | `http://project1.local` |
| <code>./data/www/<b>project2</b></code> | <code>./data/www/project2/<b>htdocs</b></code> | `http://project2.local` |
| <code>./data/www/<b>wordpress</b></code>| <code>./data/www/wordpress/<b>htdocs</b></code> | `http://wordpress.local` |
The VirtualHost directory make a new VirtualHost available under the specified URL. However the actual files that will be served are always expected to be in a subfolder called `htdocs/`. By having an additional sub-directory for the Document root you are able to store non-www files inside the project folder and even **symlink** you www dir to htdocs.
## 5. Creating new Projetcs
This is a general overview about creating projects. If you want to see some real examples how to setup **Wordpress**, **Drupal**, **CakePHP**, **Yii**, **Symfony** and others, visit the [Example Section](Examples.md).
#### 5.1 From Docker host
The following will create a VirtualHost for `http://project1.local`.
```shell
$ docker-compose up -d mysql
# replace HOST_PATH_TO_HTTPD_DATADIR with the actual project base dir
$ cd HOST_PATH_TO_HTTPD_DATADIR
$ mkdir project1
$ mkdir project1/htdocs
```
#### 1.4 Stop container
<sub>If you want to know how to change the TLD_SUFFIX `local` to something else, refer to [Configure](Configure.md).</sub>
1. If you started up docker compose in foreground mode (without `-d`), you can hit `ctrl+c` to gracefull stop or **twice** `ctrl+c` to kill the running containers.<br/>**Note:** Automatically started containers that were not specified (such as `http` or `php`) will have to be stopped manually via `docker-compose down` afterwards.
2. If you started up docker compose in background mode (with `-d`), go back to the devilbox directory (where the `docker-compose.yml` file resides and type `docker-compose down` to gracefully stop or `docker-compose kill` to kill them immediately.
#### 5.2 From inside the PHP container
Best pracice would be to start the container in the background (with `-d`) and use `docker compose down` to gracefully stop all of them.
If you prefer to work directly inside the PHP Docker container, you can do the same. The following will create a VirtualHost for `http://project1.local`.
### 2. Container Info
#### 2.1 List running container
Inside the devilbox directory enter the following command to get a list of the started/running container:
```shell
$ docker-compose ps
$ cd /shared/httpd
$ mkdir project1
$ mkdir project1/htdocs
```
#### 2.2 Show container stdout/stderr output
<sub>If you want to know how to go into the PHP container, check the section above **2. Work inside the PHP container**.</sub>
Services started in background mode (`-d`) or those that were started as dependencies (`http` and `php`) will always only log to docker logs and not to stdout/stderr. In order to view their output use:
#### 5.3 Using symlinks
Instead of creating a **htdocs/** folder explicitly, you can also make a symlink by the same name. This is required as some frameworks have nested www folders.
Keep the actual versioned wordpress name and symlink it to htdocs.
```shell
$ docker-compose logs
$ ls -l
drwxrwxr-x 2 cytopia 4096 Jun 14 08:29 wordpress-4.8
lrwxrwxrwx 1 cytopia 11 Jun 14 08:29 htdocs -> wordpress-4.8/
```
### 3. Enter
#### 3.1 Enter the php container
The `php` container (which might also have hhvm installed, depending on your version choice) is the container you can use to enter if you want to execute commands with the specified php version.
> **Note:** If you also have php installed locally on your host machine (and it is the php version of your choice), there is no need to enter the php container, just execute all the required commands on your project dir.
To enter the php container, type the following in the devilbox root directory:
```shel
$ ./bash.sh
```
You can alternatively also enter as root:
```
$ ./root_bash.sh
CakePHP serves its files from a nested folder, a symlink is required here.
```shell
$ ls -l
drwxrwxr-x 2 cytopia 4096 Jun 14 08:29 cakephp
lrwxrwxrwx 1 cytopia 11 Jun 14 08:29 htdocs -> cakephp/app/webroot/
```
#### 3.2 Find your project files
#### 5.4 Adding DNS record
The `php` container mounts your project files (the path of `HOST_PATH_TO_WWW_DOCROOTS` as specified in the `.env` file) to `/shared/httpd`.
In order to actually visit the newly created project in your browser, there must be a DNS entry pointing to the webserver's listening IP address. This can either be done automatically by a DNS server or you can do it manually for each project by editing your `/etc/hosts` file every time you create a new project.
So enter the container as described above and once inside the `php` container cd into `/shared/httpd`.
##### 5.4.1 /etc/hosts
----
If you have not setup Auto-DNS, you will need to create your own DNS records for every project. Let's assume your `TLD_SUFFIX` is set to `local`.
### Hints
| Project folder | `/etc/hosts` entry |
|----------------|-------------------------------|
| my-project1 | `127.0.0.1 my-project1.local` |
| drupal-test | `127.0.0.1 drupal-test.local` |
| playground | `127.0.0.1 playground.local` |
**A. How do I know the name of the container I can start?**
##### 5.4.2 Auto-DNS
Refer to the **[Info](Info.md)** section or look it up in the `docker-compose.yml` file.
When using the devilbox built-in DNS server, there is nothing to do. DNS catch-all records for your `TLD_SUFFIX` exist and will always point to `127.0.0.1`. See [Configure](Configure.md) for how to setup Auto-DNS.
**B. Can I not just comment out the service in the `.env` file?**
No, don't do this. This will lead to unexpected behaviour (different versions will be loaded).
The `.env` file allows you to configure the devilbox, but not to start services selectively.
## 6. Switching container versions
**C. Are there any required services that must/will always be started?**
Being able to combine all kinds of different container version is one of the main goals of the devilbox. Changing the versions is kept simple and consistent for all container.
Yes. `http` and `php` will automatically always be started (due to dependencies inside `docker-compose.yml`) if you specify them or not.
1. Open the `.env` file in your favorite editor
2. Find the `*_SERVER=` block for the container to change the version
3. Comment all lines you do not want to activate
4. Uncomment the one line you want to use.
5. Restart the devilbox for the changes to take effect
<sub>Be aware that if multiple lines are uncommented, the last one takes effect.</sub>
For an in-depth explanation about how to configure each service, you should have a look at [Configure](Configure.md).
#### 6.1 Httpd versions
1. Open the `.env` file in your favorite editor
2. Find the `HTTPD_SERVER=` block
You can choose between Apache and Nginx in different version. All of them are configured to work the same, there is nothing to worry about when changing them.
#### 6.2 PHP versions
1. Open the `.env` file in your favorite editor
2. Find the `PHP_SERVER=` block
You can choose between different PHP versions and HHVM.
**Important:** Keep in mind that if you have a custom php.ini config at `./cfg/php-*/`, it is only effective for one version. Custom php configurations are separted per version.
#### 6.3 SQL versions
1. Open the `.env` file in your favorite editor
2. Find the `MYSQL_SERVER=` or `PGSQL_SERVER=` block
**Important:** Each version has a different data directory. This is a security precautions. Imagine you startup MySQL 5.5 for the first time. New databases will be created. Now you startup MySQL 8. All existing databases would be upgraded to work flawlessly with MySQL 8, however this is not downwards compatible. So by startup up MySQL 5.5 again, it would say the database is corrupt.
#### 6.4 NoSQL versions
1. Open the `.env` file in your favorite editor
2. Find the `MONGO_SERVER=`, 'MEMCD_SERVER=` or `REDIS_SERVER=` block
There is nothing to pay attention to here.
## 7. Emails
All your projects can send emails to whatever recipient. You do not have to worry that they will actually being sent. Each PHP container runs a local postfix mailserver that intercepts all outgoing mails and puts them all in the local devilbox user mail account.
In order to view sent emails open up the devilbox intranet http://localhost/mail.php. There you can also test email sending and verify that they really stay locally.
## 8. Log files
#### 8.1 Mounted logs
Log files are available on the Host system and separated per service version. See `./log/` (inside devilbox git directory). The `./log/` folder itself will contain subdirectories in the form `<service>-<version>` which will then hold all available log files.
**Example:**
```
log/
apache-2.2/
access_log
error_log
localhost-access.log
localhost-error.log
other-error.log
apache-2.4/
access_log
error_log
localhost-access.log
localhost-error.log
other-error.log
mariadb-10.3/
error.log
query.log
slow.log
php-fpm-7.0/
php-fpm.err
www-access.log
www-error.log
```
#### 8.2 Docker logs
All output printed to stdout or stderr by the started services will be available in `docker logs`. In order to view them constantly in a terminal session use:
```shell
docker-compose logs -f
```
Docker logs are currently only being used to display the initial startup including the chosen settings. All other logging is written to file and mounted to the docker host.
## 9. Intranet
The devilbox bundled intranet is not required for project management or creation, however it offers a few useful tools.
#### 9.1 Overview
The overview page presents you the current state of the running stack and any errors it might have encountered.
http://localhost
#### 9.2 vHosts
The vHost page shows you all available projects and any configuation errors that need to be resolved. Errors could be: missing `htdocs/` folder and incorrect DNS settings. So make sure to first visit this page if any of your vHost does not work.
http://localhost/vhosts.php
#### 9.3 Tools
The intranet also offers a few common as well as self-made tools. These include:
* phpMyAdmin
* Adminer
* Mail viewer
* OpCacheGUI
* SQL/NoSQL database viewer
* Info pages (showing detailed configurations for the attached container)
If you are interested in doing database backups, either use phpMyAdmin or Adminer. You can however also use the PHP container itself. Read more about this on [Backups](Backups.md)

View File

@ -1,2 +0,0 @@
theme: jekyll-theme-slate
google_analytics: UA-51797082-4

View File

@ -1,62 +0,0 @@
<!DOCTYPE html>
<html lang="{{ site.lang | default: "en-US" }}">
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="width=device-width,maximum-scale=2">
<meta name="description" content="{{ site.title | default: site.github.repository_name }} : {{ site.description | default: site.github.project_tagline }}">
<link rel="stylesheet" type="text/css" media="screen" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}">
<title>{{ site.title | default: site.github.repository_name }}</title>
</head>
<body>
<!-- HEADER -->
<div id="header_wrap" class="outer">
<header class="inner">
<a id="forkme_banner" href="{{ site.github.repository_url }}">View on GitHub</a>
<h1 id="project_title">{{ site.title | default: site.github.repository_name }}</h1>
<h2 id="project_tagline">{{ site.description | default: site.github.project_tagline }}</h2>
{% if site.show_downloads %}
<section id="downloads">
<a class="zip_download_link" href="{{ site.github.zip_url }}">Download this project as a .zip file</a>
<a class="tar_download_link" href="{{ site.github.tar_url }}">Download this project as a tar.gz file</a>
</section>
{% endif %}
</header>
</div>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
{{ content }}
</section>
</div>
<!-- FOOTER -->
<div id="footer_wrap" class="outer">
<footer class="inner">
{% if site.github.is_project_page %}
<p class="copyright">{{ site.title | default: site.github.repository_name }} maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a></p>
{% endif %}
<p>Published with <a href="https://pages.github.com">GitHub Pages</a></p>
</footer>
</div>
{% if site.google_analytics %}
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
</body>
</html>

View File

@ -1,46 +0,0 @@
---
---
@import "{{ site.theme }}";
.inner {
max-width: 850px;
position: relative;
padding: 20px 10px;
margin: 0 auto;
}
#header_wrap {
background-image: url('/assets/img/devilbox-dash.png');
background-repeat: no-repeat;
background-size: cover;
min-height: 100%;
}
h1, h2, h3 {
text-align: center;
}
h2, h3 {
margin-top:30px;
}
table {
margin: auto;
width: 50%;
padding: 10px;
}
.center {
text-align: center;
}
img.battery {
/*border: 1px solid black;*/
border-radius: 15px;
}
/* remove gh pages link */
footer.inner p {
display: none;
}
footer.inner p.copyright {
display: block;
}

View File

@ -393,7 +393,7 @@ HOST_PORT_MONGO=27017
###
### Expose Bind Port to Host
###
HOST_PORT_BIND=53
HOST_PORT_BIND=1053
###
### Add comma separated DNS server from which you want to receive DNS

101
update-docker.sh Executable file
View File

@ -0,0 +1,101 @@
#!/bin/sh
#
# This script will pull all Docker images that are currently
# bound to your devilbox git state.
#
# When updating the devilbox via git, do run this script once
# in order to download all images locally.
#
###
### Path of devilbox repository
###
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
###
### DNS
###
TAG="$( grep '^[[:space:]]*image:[[:space:]]*cytopia/bind' "${CWD}/docker-compose.yml" | sed 's/^.*://g' )"
docker pull cytopia/bind:${TAG}
###
### PHP
###
TAG="$( grep '^[[:space:]]*image:.*\${PHP_SERVER' "${CWD}/docker-compose.yml" | sed 's/^.*://g' )"
docker pull cytopia/php-fpm-5.4:${TAG}
docker pull cytopia/php-fpm-5.5:${TAG}
docker pull cytopia/php-fpm-5.6:${TAG}
docker pull cytopia/php-fpm-7.0:${TAG}
docker pull cytopia/php-fpm-7.1:${TAG}
docker pull cytopia/hhvm-latest:${TAG}
###
### HTTPD
###
TAG="$( grep '^[[:space:]]*image:.*\${HTTPD_SERVER' "${CWD}/docker-compose.yml" | sed 's/^.*://g' )"
docker pull cytopia/nginx-stable:${TAG}
docker pull cytopia/nginx-mainline:${TAG}
docker pull cytopia/apache-2.2:${TAG}
docker pull cytopia/apache-2.4:${TAG}
###
### MYSQL
###
TAG="$( grep '^[[:space:]]*image:.*\${MYSQL_SERVER' "${CWD}/docker-compose.yml" | sed 's/^.*://g' )"
docker pull cytopia/mysql-5.5:${TAG}
docker pull cytopia/mysql-5.6:${TAG}
docker pull cytopia/mysql-5.7:${TAG}
docker pull cytopia/mysql-8.0:${TAG}
docker pull cytopia/mariadb-5.5:${TAG}
docker pull cytopia/mariadb-10.0:${TAG}
docker pull cytopia/mariadb-10.1:${TAG}
docker pull cytopia/mariadb-10.2:${TAG}
docker pull cytopia/mariadb-10.3:${TAG}
###
### PGSQL
###
docker pull postgres:9.1
docker pull postgres:9.2
docker pull postgres:9.3
docker pull postgres:9.4
docker pull postgres:9.5
docker pull postgres:9.6
###
### REDIS
###
docker pull redis:2.8
docker pull redis:3.0
docker pull redis:3.2
###
### MEMCACHED
###
docker pull memcached:1.4.21
docker pull memcached:1.4.22
docker pull memcached:1.4.23
docker pull memcached:1.4.24
docker pull memcached:1.4.25
docker pull memcached:1.4.26
docker pull memcached:1.4.27
docker pull memcached:1.4.28
docker pull memcached:1.4.29
docker pull memcached:1.4.30
docker pull memcached:1.4.31
docker pull memcached:1.4.32
docker pull memcached:1.4.33
docker pull memcached:1.4.34
docker pull memcached:1.4.35
docker pull memcached:1.4.36
docker pull memcached:latest
###
### MONGODB
###
docker pull mongo:2.8
docker pull mongo:3.0
docker pull mongo:3.2
docker pull mongo:3.4
docker pull mongo:3.5