documentation: work inside the PHP container

This commit is contained in:
cytopia 2018-03-25 12:07:45 +02:00
parent 6f79f007de
commit a621d4b6f7
No known key found for this signature in database
GPG Key ID: 6D56EDB8695128A2
6 changed files with 369 additions and 163 deletions

199
README.md
View File

@ -1,22 +1,19 @@
<p align="center">
<h1 align="center">The devilbox</h1>
<h1 align="center">The Devilbox</h1>
</p>
![Devilbox](docs/img/devilbox-banner.png)
[![Join the chat at https://gitter.im/devilbox/Lobby](https://badges.gitter.im/devilbox/Lobby.svg)](https://gitter.im/devilbox/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
**[Usage](#usage)** |
**[Community](#community)** |
**[Features](#feature-overview)** |
**[Documentation](#documentation)** |
**[Intranet](#intranet-overview)** |
**[Screenshots](#screenshots)** |
**[Contributing](#contributing-)** |
**[Logos](#logos)** |
**[License](#license)**
![Devilbox](docs/img/devilbox-dash-full.png)
![Devilbox](docs/_static/img/devilbox-dash-full.png)
[![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)
@ -25,6 +22,42 @@ The devilbox is a modern and highly customisable **dockerized PHP stack** suppor
![Linux](https://raw.githubusercontent.com/cytopia/icons/master/64x64/linux.png) ![Windows](https://raw.githubusercontent.com/cytopia/icons/master/64x64/windows.png) ![OSX](https://raw.githubusercontent.com/cytopia/icons/master/64x64/osx.png)
## Community
<table width="100%" style="width:100%; display:table;">
<thead>
<tr>
<th width="33%" style="width:33%;">Documentation</th>
<th width="33%" style="width:33%;">Chat</th>
<th width="33%" style="width:33%;">Forum</th>
</tr>
</thead>
<tbody style="vertical-align: middle; text-align: center;">
<tr>
<td>
<a href="https://devilbox.readthedocs.io">
<img title="Documentation" name="Documentation" src="https://pbs.twimg.com/profile_images/525686734760067072/OhsWgbsr_400x400.png" />
</a>
</td>
<td>
<a href="https://gitter.im/devilbox/Lobby">
<img title="Chat" name="Chat" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR9A68ZmRt6PKTkCXXslzCQkqGh2Q0FmLKvRaVrRNY7xTOAzYa4_Q" />
</a>
</td>
<td>
<img title="Forum" name="Forum" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ6ryI8VGmL0vXjMgrNH4EregCko9sm9godr8-ZHiwDGlXab92v" />
</td>
</tr>
<tr>
<td><a href="https://devilbox.readthedocs.io">devilbox.readthedocs.io</a></td>
<td><a href="https://gitter.im/devilbox/Lobby">gitter.im/devilbox</a></td>
<td>coming soon</td>
</tr>
</tbody>
</table>
## Usage
#### Quick start
@ -53,7 +86,7 @@ The above will start all containers, you can however also just start the contain
```shell
$ docker-compose up httpd php mysql redis
```
![Devilbox](docs/img/devilbox-dash-selective.png)
![Devilbox](docs/_static/img/devilbox-dash-selective.png)
#### Run different versions
@ -78,7 +111,7 @@ Every single attachable container comes with many different versions. In order t
<tr>
<td><a target="_blank" title="Apache 2.2" href="https://github.com/devilbox/docker-apache-2.2">2.2</a></td>
<td><a target="_blank" title="Nginx stable" href="https://github.com/devilbox/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="PHP 5.4" href="https://github.com/devilbox/docker-php-fpm">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="PerconaDB 5.5" href="https://github.com/cytopia/docker-percona-5.5">5.5</a></td>
@ -90,7 +123,7 @@ Every single attachable container comes with many different versions. In order t
<tr>
<td><a target="_blank" title="Apache 2.4" href="https://github.com/devilbox/docker-apache-2.4">2.4</a></td>
<td><a target="_blank" title="Nginx mainline" href="https://github.com/devilbox/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="PHP 5.5" href="https://github.com/devilbox/docker-php-fpm">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="PerconaDB 5.6" href="https://github.com/cytopia/docker-percona-5.6">5.6</a></td>
@ -102,7 +135,7 @@ Every single attachable container comes with many different versions. In order t
<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="PHP 5.6" href="https://github.com/devilbox/docker-php-fpm">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="PerconaDB 5.7" href="https://github.com/cytopia/docker-percona-5.7">5.7</a></td>
@ -114,7 +147,7 @@ Every single attachable container comes with many different versions. In order t
<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="PHP 7.0" href="https://github.com/devilbox/docker-php-fpm">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></td>
@ -126,7 +159,7 @@ Every single attachable container comes with many different versions. In order t
<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><a target="_blank" title="PHP 7.1" href="https://github.com/devilbox/docker-php-fpm">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></td>
@ -138,7 +171,7 @@ Every single attachable container comes with many different versions. In order t
<tr>
<td></td>
<td></td>
<td><a target="_blank" title="PHP 7.2" href="https://github.com/cytopia/docker-php-fpm-7.2">7.2</a></td>
<td><a target="_blank" title="PHP 7.2" href="https://github.com/devilbox/docker-php-fpm">7.2</a></td>
<td></td>
<td></td>
<td></td>
@ -150,7 +183,7 @@ Every single attachable container comes with many different versions. In order t
<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></td>
<td></td>
@ -304,17 +337,16 @@ Well-known and popular tools will be at your service as well:
<a target="_blank" title="NodeJS" href="https://nodejs.org"><img width="64" style="width:64px;" src="docs/img/logo_tools/nodejs.png" alt="Devilbox"/></a>
<a target="_blank" title="NPM" href="https://www.npmjs.com"><img width="64" style="width:64px;" src="docs/img/logo_tools/npm.png" alt="Devilbox"/></a>
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.
#### Available 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*
> *amqp, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongodb, msgpack, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib*
#### Custom PHP Modules
You can also copy any custom modules into `mod/(php-fpm|hhvm)-<VERSION>` and add a custom `*.ini` file to load them. See [Custom PHP Modules](docs/Configure.md#425-custom-php-modules) in the Configuration documentation for how to do that in two simple steps.
You can also copy any custom modules into `mod/(php-fpm|hhvm)-<VERSION>` and add a custom `*.ini` file to load them.
#### Supported Frameworks
@ -331,105 +363,6 @@ As far as tested there are no limitations and you can use any Framework or CMS j
[![Zend](docs/img/logo_fw/zend.png)](https://framework.zend.com)
## 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#11-linux)
2. [Windows](docs/Install.md#12-windows)
3. [OSX](docs/Install.md#13-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)
1. [/etc/hosts](docs/Configure.md#61-etchosts)
2. [Auto-DNS](docs/Configure.md#62-auto-dns)
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#21-mysql-database-backup)
2. [MySQL Database Restore](docs/Backups.md#22-mysql-database-restore)
3. [PostgreSQL](docs/Backups.md#3-postgresql)
1. [PostgreSQL Database Backup](docs/Backups.md#31-postgresql-database-backup)
2. [PostgreSQL Database Restore](docs/Backups.md#31-postgresql-database-restore)
4. [MongoDB](docs/Backups.md#4-mongodb)
1. [MongoDB Database Backup](docs/Backups.md#41-mongodb-database-backup)
2. [MongoDB Database Restore](docs/Backups.md#41-mongodb-database-restore)
10. **[Examples](docs/Examples.md)**
1. [Introduction](docs/Examples.md#1-introduction)
1. [Framework/CMS tools](docs/Examples.md#11-framework-cms-tools)
2. [Code analysis tools](docs/Examples.md#12-code-analysis-tools)
2. [Project setup](docs/Examples.md#2-project-setup)
1. [Setup CakePHP](docs/Examples.md#21-setup-cakephp)
2. [Setup Drupal](docs/Examples.md#22-setup-drupal)
3. [Setup Joomla](docs/Examples.md#23-setup-joomla)
4. [Setup Laravel](docs/Examples.md#24-setup-laravel)
5. [Setup Phalcon](docs/Examples.md#25-setup-phalcon)
6. [Setup Symfony](docs/Examples.md#26-setup-symfony)
7. [Setup Wordpress](docs/Examples.md#27-setup-wordpress)
8. [Setup Yii](docs/Examples.md#28-setup-yii)
9. [Setup Zend](docs/Examples.md#29-setup-zend)
3. [Code analysis](docs/Examples.md#3-code-analysis)
1. [awesome-ci](docs/Examples.md#31-awesome-ci)
2. [phpcs](docs/Examples.md#32-phpcs)
3. [eslint](docs/Examples.md#33-eslint)
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)**
## Intranet overview
The devilbox comes with a pre-configured intranet on `http://localhost`. This can be explicitly disabled or password-protected. The intranet will not only show you, the chosen configuration, but also validate the status of the current configuration, such as if **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.
@ -445,31 +378,25 @@ The devilbox comes with a pre-configured intranet on `http://localhost`. This ca
## Screenshots
#### Homepage with host / docker information
The homepage shows you the status of your current configured setup.
* which versions are used
* what directories are mounted
* where does DNS point to
* what other settings have been set
* did any errors occur?
A few examples of how the built-in intranet looks like.
<table>
<tbody>
<tr>
<td rowspan="2">
<img style="width:250px;" width="250" src="docs/img/screenshots/01_intranet_home.png" />
<a href="docs/img/screenshots/01_intranet_home.png"><img style="width:250px;" width="250" src="docs/img/screenshots/01_intranet_home.png" /></a>
</td>
<td>
<img style="width:250px" width="250" src="docs/img/screenshots/02_intranet_vhosts.png" />
<a href="docs/img/screenshots/02_intranet_vhosts.png"><img style="width:250px" width="250" src="docs/img/screenshots/02_intranet_vhosts.png" /></a>
</td>
<td>
<img style="width:250px;" width="250" src="docs/img/screenshots/03_intranet_databases.png" />
<a href="docs/img/screenshots/03_intranet_databases.png"><img style="width:250px;" width="250" src="docs/img/screenshots/03_intranet_databases.png" /></a>
</td>
</tr>
<tr>
<td><img style="width:250px;" width="250" src="docs/img/screenshots/04_intranet_emails.png" /></td>
<td>
<a href="docs/img/screenshots/04_intranet_emails.png"><img style="width:250px;" width="250" src="docs/img/screenshots/04_intranet_emails.png" /></a>
</td>
<td></td>
</tr>
</table>
@ -477,15 +404,17 @@ The homepage shows you the status of your current configured setup.
## Contributing [![Open Source Helpers](https://www.codetriage.com/cytopia/devilbox/badges/users.svg)](https://www.codetriage.com/cytopia/devilbox)
Contributers are welcome in any way.
The Devilbox is still a young project with a long roadmap of features to come. Features are
decided by you - **the community**, so any kind of contribution is welcome.
First of all, if you like the project, please **do star it**. 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.
To increase visibility and bug-free operation:
Secondly, please **do report all bugs**. This will not only help you get your problem fixed, but also help others as they might encounter the same. You can also help triage existing issues.This can include reproducing bug reports, or asking for vital information such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to devilbox on CodeTriage](https://www.codetriage.com/cytopia/devilbox).
* Star this project
* Open up issues for bugs and feature requests
* Clone this project and submit fixes or features
And last but not least, you can also get actively involved. **Do clone the project** and start improving whatever you think is useful. There is quite a lot todo and planned. If you like to contribute, view [CONTRIBUTING.md](CONTRIBUTING.md) and [ROADMAP](https://github.com/cytopia/devilbox/issues/23).
Major contributors will be credited within the intranet and on the github page.
Additionally you can [subscribe to devilbox on CodeTriage](https://www.codetriage.com/cytopia/devilbox),
read up on [CONTRIBUTING.md](CONTRIBUTING.md) and check the [ROADMAP](https://github.com/cytopia/devilbox/issues/23) about what is already planned for the near future.
## Logos

View File

@ -203,6 +203,8 @@ and you do not have to fix permissions afterwards.
the host system and a running Docker container.
.. _env_new_gid:
NEW_GID
-------

View File

@ -1,3 +1,5 @@
.. _auto_dns:
********
Auto-DNS
********

View File

@ -79,29 +79,6 @@ the password-less ``sudo``.
platforms.
Directory mapping
=================
One thing you should understand is the relation between the directories on your host operating
system and the corresponding directory inside the PHP container.
The location of the data directory (:ref:`env_httpd_datadir`) on your host computer is controlled
via the ``HOST_PATH_HTTPD_DATADIR`` variable inside the ``.env`` file. No matter what location you
set it to, inside the container it will always be mapped to ``/shared/httpd``.
See the following table for a few examples:
+----------+-----------------------+----------------------+
| | Host operating system | Inside PHP container |
+==========+=======================+======================+
| Data dir | ``./www/data`` | ``/shared/httpd`` |
+----------+-----------------------+----------------------+
| Data dir | ``/home/user1/www`` | ``/shared/httpd`` |
+----------+-----------------------+----------------------+
| Data dir | ``/var/www`` | ``/shared/httpd`` |
+----------+-----------------------+----------------------+
Tools
=====
@ -126,10 +103,19 @@ The only thing you have to do, is to update the Docker images itself, simply by
.. seealso:: :ref:`getting_started_update_the_docker_images`
Advanced
========
This is just a short overview about the possibility to work inside the container.
If you want to dig deeper into this topic there is also a more advanced tutorial available:
.. seealso:: :ref:`tutorial_work_inside_the_php_container`
Checklist
=========
* You know how to enter the PHP container on Linux, MacOS or Windows
* You know how to become ``root`` inside the PHP container
* You understand the directory relation between inside the container and your host operating system
* You know what tools are available inside the PHP container
* You know how to update the tools by pulling new versions of the Docker images

View File

@ -28,6 +28,18 @@ devilbox documentation
getting-started/enter-the-php-container
.. toctree::
:caption: Maintenance
:maxdepth: 2
maintenance/install
maintenance/update
maintenance/uninstall
tutorials/backup-mysql
tutorials/backup-pgsql
tutorials/backup-mongo
.. toctree::
:maxdepth: 2
:caption: Tutorials
@ -40,9 +52,7 @@ devilbox documentation
tutorials/enable-auto-dns
tutorials/enable-xdebug
tutorials/customize-vhost
tutorials/backup-mysql
tutorials/backup-pgsql
tutorials/backup-mongo
tutorials/custom-apache-modules
tutorials/custom-environment-variables
tutorials/password-protect-intranet
tutorials/disable-intranet

View File

@ -4,5 +4,282 @@
Work inside the container
*************************
The Devilbox allows you to completely work inside the PHP container (no matter what version),
instead of your host operating system.
asdasda
This brings a lot of advantages, such as that you don't
have to install any development tool on your OS or if you are on Windows, you get a full blown
Linux environment.
Additionally, special port-bindings and forwards are in place that allows you to even
interchangably work locally or inside the container without having to alter any php config for
database and other connections.
.. seealso:: :ref:`available_tools`
**Table of Contents**
.. contents:: :local:
Enter the container
===================
Entering the computer is fairly simple. The Devilbox ships with two scripts to do that. One for
Linux and MacOS (``shell.sh``) and another one for Windows (``shell.bat``).
Entering from Linux or MacOS: ``shell.sh``
------------------------------------------
.. code-block:: bash
# Navigate to the Devilbox directory
host> cd /path/to/devilbox
# Run provided script
host> ./shell.sh
# Now you are inside the PHP Linux container
devilbox@php-7.0.19 in /shared/httpd $
Entering from Windows: ``shell.bat``
------------------------------------
.. code-block:: bash
# Navigate to the Devilbox directory
C:/> cd C:/Users/user1/devilbox
# Run provided script
C:/Users/user1/devilbox> shell.bat
# Now you are inside the PHP Linux container
devilbox@php-7.0.19 in /shared/httpd $
Inside the container
====================
``devilbox`` user
-----------------
By using the provided scripts to enter the container you will become the user ``devilbox``.
This user will have the same uid and gid as the user from your host operating system.
So no matter what files or directories you create inside the container, they will have the same
permissions and uid/gid set your host operating system. This of course also works the other way
round.
The uid and gid mappings are controlled via two ``.env`` variables called :ref:`env_new_uid` and
:ref:`env_new_gid`
.. seealso::
If you want to find out more about synronized container permissions read up here:
:ref:`syncronize_container_permissions`
``root`` user
-------------
Sometimes however it is also necessary to do some actions that require super user privileges.
You can always become root inside the container by either impersonating it or by using ``sudo``
to issue commands.
By default ``sudo`` is configured to be used without passwords, so you can simply do the following:
.. code-block:: bash
# As user devilbox inside the container
devilbox@php-7.0.19 in /shared/httpd $ sudo su -
# You are now the root user
root@php-7.0.19 in /shared/httpd $
You can also use ``sudo`` to run commands with root privileges without having to become root first.
.. code-block:: bash
# As user devilbox inside the container
devilbox@php-7.0.19 in /shared/httpd $ sudo apt update
devilbox@php-7.0.19 in /shared/httpd $ sudo apt install nmap
Leave the container
===================
When you are inside the container and want to return to your host operating, just type ``exit``
and you are out.
.. code-block:: bash
# As user devilbox inside the container
devilbox@php-7.0.19 in /shared/httpd $ exit
# You are now back on your host operating system
host>
Host to Container mappings
==========================
This section will give you an idea that there is actually no difference from inside the container
and on your host operating system. Directory permissions, IP addresses, ports and DNS entries
are fully syncronized allowing you to switch between container and host without having to
change any settings.
File and directory Permissions
------------------------------
The username inside the container (``devilbox``) might be different from your local host operating
system username, however its actual uid and gid will match. This is to ensure file and directory
permissions are synronized inside and outside the container and no matter from which side you
create files and directories, it will always look as if they are owned by your system user.
The uid and gid mappings are controlled via two ``.env`` variables called :ref:`env_new_uid` and
:ref:`env_new_gid`
Directory mappings
------------------
One thing you should understand is the relation between the directories on your host operating
system and the corresponding directory inside the PHP container.
The location of the data directory (:ref:`env_httpd_datadir`) on your host computer is controlled
via the ``HOST_PATH_HTTPD_DATADIR`` variable inside the ``.env`` file. No matter what location you
set it to, inside the container it will always be mapped to ``/shared/httpd``.
See the following table for a few examples:
+----------+-----------------------+----------------------+
| | Host operating system | Inside PHP container |
+==========+=======================+======================+
| Data dir | ``./www/data`` | ``/shared/httpd`` |
+----------+-----------------------+----------------------+
| Data dir | ``/home/user1/www`` | ``/shared/httpd`` |
+----------+-----------------------+----------------------+
| Data dir | ``/var/www`` | ``/shared/httpd`` |
+----------+-----------------------+----------------------+
IP address mappings
-------------------
The following table shows a mapping of IP addresses of available service from the perspective
of your host operating system and from within the PHP container.
+--------------+-----------------+------------------------------+
| Service | IP from host os | IP from within PHP container |
+==============+=================+==============================+
| PHP | ``127.0.0.1`` | ``127.0.0.1`` |
+--------------+-----------------+------------------------------+
| Apache/Nginx | ``127.0.0.1`` | ``127.0.0.1`` |
+--------------+-----------------+------------------------------+
| MySQL | ``127.0.0.1`` | ``127.0.0.1`` |
+--------------+-----------------+------------------------------+
| PostgreSQL | ``127.0.0.1`` | ``127.0.0.1`` |
+--------------+-----------------+------------------------------+
| Redis | ``127.0.0.1`` | ``127.0.0.1`` |
+--------------+-----------------+------------------------------+
| Memcached | ``127.0.0.1`` | ``127.0.0.1`` |
+--------------+-----------------+------------------------------+
| MongoDB | ``127.0.0.1`` | ``127.0.0.1`` |
+--------------+-----------------+------------------------------+
As you can see, everyhing is available under ``127.0.0.1``.
The PHP container is using ``socat`` to forward the services from all other available containers
to its own ``127.0.0.1`` address.
An example to access the MySQL database from either host or within the PHP container is the same:
.. code-block:: bash
# Access MySQL from your host operating system
host> mysql -h 127.0.0.1
# Access MySQL from within the PHP container
devilbox@php-7.0.19 in /shared/httpd $ mysql -h 127.0.0.1
.. important::
Do not use ``localhost`` to access the services, it does not map to ``127.0.0.1`` on
all cases.
So when setting up a configuration file from your PHP project you would for example use
``127.0.0.`` as the host for your MySQL database connection:
.. code-block:: php
<?php
// MySQL server connection
mysql_host = '127.0.0.1';
mysql_port = '3306';
mysql_user = 'someusername';
mysql_pass = 'somepassword';
?>
Imagine your PHP framework ships a command line tool to run database migration. You could run
it from your host operating system or from within the PHP container. It would work from both
sides as the connection to the database is exactly the same locally or within the container.
You could also even switch between the Devilbox and a locally installed LAMP stack
and still use the same configuration.
.. warning::
The mapping of ``127.0.0.1`` to your host operating system does not work with
:ref:`docker_toolbox`.
Port mappings
-------------
By default, ports are also synronized between host operating system (the ports that are exposed)
and the ports within the PHP container. This is however also configurable inside the ``.env`` file.
+--------------+-------------------+--------------------------------+
| Service | Port from host os | Port from within PHP container |
+==============+===================+================================+
| PHP | NA | ``9000`` |
+--------------+-------------------+--------------------------------+
| Apache/Nginx | ``80`` | ``80`` |
+--------------+-------------------+--------------------------------+
| MySQL | ``3306`` | ``3306`` |
+--------------+-------------------+--------------------------------+
| PostgreSQL | ``5432`` | ``5432`` |
+--------------+-------------------+--------------------------------+
| Redis | ``6379`` | ``6379`` |
+--------------+-------------------+--------------------------------+
| Memcached | ``11211`` | ``11211`` |
+--------------+-------------------+--------------------------------+
| MongoDB | ``27017`` | ``27017`` |
+--------------+-------------------+--------------------------------+
DNS mappings
------------
All project DNS records are also available from inside the PHP container independent of the
value of :ref:`env_tld_suffix`.
The PHP container is hooked up by default to the bundled DNS server and makes use :ref:`auto_dns`.
.. seealso::
You can achieve the same on your host operating system by explicitly enabling auto-dns.
See also: :ref:`auto_dns` and :ref:`tutorial_enable_auto_dns`.
Checklist
=========
1. You know how to enter the PHP container
2. You know how to become root inside the PHP container
3. You know how to leave the container
4. You know that file and directory permissions are synronized
5. You know that ``127.0.0.1`` is available on your host and inside the PHP container
6. You know that ports are the same inside the container and on your host os
7. You know that project urls are available inside the container and on your host
8. You know about the limitations of :ref:`docker_toolbox`