commit be1620e077b2edc087fbfc16a20ad4435bd25b67 Author: cytopia Date: Sun Oct 9 18:47:49 2016 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6cd6c386 --- /dev/null +++ b/.gitignore @@ -0,0 +1,89 @@ +# Note: +# To effectively apply the changes you will have +# to re-index the git index (if there are already +# commited files) +# +# $ git rm -r --cached . +# $ git add . +# $ git commit -m ".gitignore index rebuild" +# + + +###################################### +# CUSTOM +###################################### + +.env +log/ +run/ + + + + +###################################### +# GENERIC +###################################### + +###### std ###### +.lock +*.log + +###### patches/diffs ###### +*.patch +*.diff +*.orig +*.rej + + +###################################### +# Operating Systems +###################################### + +###### OSX ###### +._* +.DS* +.Spotlight-V100 +.Trashes + +###### Windows ###### +Thumbs.db +ehthumbs.db +Desktop.ini +$RECYCLE.BIN/ +*.lnk +*.shortcut + +###################################### +# Editors +###################################### + +###### Sublime ###### +*.sublime-workspace +*.sublime-project + +###### Eclipse ###### +.classpath +.buildpath +.project +.settings/ + +###### Netbeans ###### +/nbproject/ + +###### Intellij IDE ###### +.idea/ +.idea_modules/ + +###### vim ###### +*.swp +*.swo +*~ + +###### TextMate ###### +.tm_properties +*.tmproj + +###### BBEdit ###### +*.bbprojectd +*.bbproject + diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..95154ee3 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 cytopia + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 00000000..eecc2fa0 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Devilbox + +The ultimate Docker LAMP/LEMP Stack for local development. + +## Specials + +* All logs are available on your Host computer +* MySQL localhost socket is available in PHP container +* MySQL `127.0.0.1:3006` is available in PHP container +* Xdebug is included + +## Run-time Matrix + +You can choose any combination of the following docker images during run-time: + +| Webserver | Database | PHP | +|-----------|----------|-----| +| Apache 2.2 | [MySQL 5.5](https://github.com/cytopia/docker-mysql-5.5) | [PHP 5.5](https://github.com/cytopia/docker-php-fpm-5.5) | +| [Apache 2.4](https://github.com/cytopia/docker-apache-2.4) | MySQL 5.6 | [PHP 5.6](https://github.com/cytopia/docker-php-fpm-5.6) | +| Nginx | MySQL 5.7 | [PHP 7.0](https://github.com/cytopia/docker-php-fpm-7.0) | +| | MariaDB 5 | [PHP 7.1](https://github.com/cytopia/docker-php-fpm-7.1) | +| | MariaDB 10 | | + + +## Start + +1. Copy `env-example` to `.env` +2. Edit `.env` +3. `docker-compose up` diff --git a/bin/apache-2.4/fix-virtual-docroot.php b/bin/apache-2.4/fix-virtual-docroot.php new file mode 100755 index 00000000..e2b6fc13 --- /dev/null +++ b/bin/apache-2.4/fix-virtual-docroot.php @@ -0,0 +1,3 @@ + $time) { + if ((time() - ($time+30)) >=0) { + fclose(${$vhost}); + unset(${$vhost}); + unset($lastwrite[$vhost]); + } + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..d096615c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,262 @@ +## +## ------------------------- +## | D E V I L S T A C K | +## ------------------------- +## +## Local LAMP/LEMP stack +## +## +## +## +## +## -- DO NOT EDIT THIS FILE -- +## +## Edit '.env' for configuration. +## +## If '.env' does not exist, copy 'env-example' to '.env' +## $ cp env-example .env +## + + +version: '2' + + +################################################################################ +# SERVICES +################################################################################ +services: + + # ---------------------------------------- + # HTTP + # ---------------------------------------- + httpd: + #image: cytopia/${HTTPD_SERVER}:1 + image: cytopia/${HTTPD_SERVER} + + # Manually build via `docker-compose build` + #build: + #context: https://github.com/cytopia/docker-${HTTPD_SERVER}.git#1 + # context: https://github.com/cytopia/docker-${HTTPD_SERVER}.git + + environment: + + # Show all executed commands during docker entrypoint? + - DEBUG_COMPOSE_ENTRYPOINT=${DEBUG_COMPOSE_ENTRYPOINT} + + # Adjust timezone + - TIMEZONE=${TIMEZONE} + + # Tell the webserver to look into this directory + # for additional configuration files. + # + # @see volumes:: - ./etc/${HTTPD_SERVER}:/etc/${HTTPD_SERVER} + - CUSTOM_HTTPD_CONF_DIR=/etc/${HTTPD_SERVER} + + ports: + # ---- Format: ---- + # [HOST-ADDR : ] HOST-PORT : DOCKER-PORT + - "127.0.0.1:80:80" + + networks: + app_net: + ipv4_address: 172.16.238.10 + + volumes: + # ---- Format: ---- + # HOST-DIRECTORY : DOCKER-DIRECTORY + + + # Custom scripts/binaries required for httpd server vhost + # configuration to work. + # (configured in /etc/${HTTPD_SERVER}/02-vhost-mass.conf) + - ./bin/${HTTPD_SERVER}:/opt/bin + + # Mount user-defined httpd configuration files + # @see environment::CUSTOM_HTTPD_CONF_DIR for how this + # is added in httpd server + - ./etc/${HTTPD_SERVER}:/etc/${HTTPD_SERVER} + + # Mount user-defined httpd log + # @see ./etc/${HTTPD_SERVER}/*.conf for log defines + - ./log/${HTTPD_SERVER}:/var/log/${HTTPD_SERVER} + + # Mount custom intranet + # (configured in /etc/${HTTPD_SERVER}/01-vhost-default.conf) + - ./www:/var/www/default + + # Mount custom mass virtual hosting + # (configured in /etc/${HTTPD_SERVER}/02-vhost-mass.conf) + - ${HOST_PATH_TO_WWW_DOCROOTS}:/shared/httpd + + links: + # ---- Format: ---- + # SERVICE [ : ALIAS] + + - "db:database" + - "php:php-fpm" + + + + # ---------------------------------------- + # PHP-FPM + # ---------------------------------------- + php: + #image: cytopia/${PHP_SERVER}:1 + image: cytopia/${PHP_SERVER} + + # Manually build via `docker-compose build` + #build: + #context: https://github.com/cytopia/docker-${PHP_SERVER}.git#1 + # context: https://github.com/cytopia/docker-${PHP_SERVER}.git + + environment: + + # Show all executed commands during docker entrypoint? + - DEBUG_COMPOSE_ENTRYPOINT=${DEBUG_COMPOSE_ENTRYPOINT} + + # Adjust timezone + - TIMEZONE=${TIMEZONE} + + ## + ## PHP-FPM Listening Port + ## + - PHP_FPM_PORT=9000 + + ## + ## PHP Xdebug + ## + - PHP_XDEBUG_ENABLE=${PHP_XDEBUG_ENABLE} + - PHP_XDEBUG_REMOTE_PORT=${PHP_XDEBUG_REMOTE_PORT} + - PHP_XDEBUG_REMOTE_HOST=${PHP_XDEBUG_REMOTE_HOST} + + ## + ## PHP Tweaks + ## + - PHP_MAX_EXECUTION_TIME=${PHP_MAX_EXECUTION_TIME} + - PHP_MAX_INPUT_TIME=${PHP_MAX_INPUT_TIME} + - PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT} + - PHP_POST_MAX_SIZE=${PHP_POST_MAX_SIZE} + - PHP_UPLOAD_MAX_FILESIZE=${PHP_UPLOAD_MAX_FILESIZE} + - PHP_MAX_INPUT_VARS=${PHP_MAX_INPUT_VARS} + + ### + ### PHP Error Handling + ### + - PHP_ERROR_REPORTING=${PHP_ERROR_REPORTING} + - PHP_DISPLAY_ERRORS=${PHP_DISPLAY_ERRORS} + - PHP_TRACK_ERRORS=${PHP_TRACK_ERRORS} + + ## + ## Map remote MySQL Port to 127.0.0.1 + ## + - FORWARD_MYSQL_PORT_TO_LOCALHOST=1 + - MYSQL_REMOTE_ADDR=172.16.238.12 + - MYSQL_REMOTE_PORT=3306 + - MYSQL_LOCAL_PORT=3306 + + ## + ## Mount remote MySQL socket file to local disk + ## + - MOUNT_MYSQL_SOCKET_TO_LOCALDISK=1 + - MYSQL_SOCKET_PATH=/tmp/mysql/mysqld.sock + + ## + ## Additional variables needed by custom intranet + ## + - HOST_PATH_TO_WWW_DOCROOTS=${HOST_PATH_TO_WWW_DOCROOTS} + - HOST_PATH_TO_MYSQL_DATADIR=${HOST_PATH_TO_MYSQL_DATADIR} + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} + + networks: + app_net: + ipv4_address: 172.16.238.11 + + volumes: + # ---- Format: ---- + # HOST-DIRECTORY : DOCKER-DIRECTORY + + # Mount logs + - ./log/${PHP_SERVER}:/var/log/php-fpm + + # Mount MySQL Socket directory + - ./run/mysql:/tmp/mysql + + # Mount custom intranet + # (configured in /etc/${HTTPD_SERVER}/01-vhost-default.conf) + - ./www:/var/www/default + + # Mount custom mass virtual hosting + # (configured in /etc/${HTTPD_SERVER}/02-vhost-mass.conf) + - ${HOST_PATH_TO_WWW_DOCROOTS}:/shared/httpd + + + + # ---------------------------------------- + # DATABASE + # ---------------------------------------- + db: + #image: cytopia/${MYSQL_SERVER}:1 + image: cytopia/${MYSQL_SERVER} + + # Manually build via `docker-compose build` + #build: + #context: https://github.com/cytopia/docker-${MYSQL_SERVER}.git#1 + # context: https://github.com/cytopia/docker-${MYSQL_SERVER}.git + + environment: + + # Show all executed commands during docker entrypoint? + - DEBUG_COMPOSE_ENTRYPOINT=${DEBUG_COMPOSE_ENTRYPOINT} + + # Adjust timezone + - TIMEZONE=${TIMEZONE} + + + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} + - MYSQL_SOCKET_DIR=/tmp/mysql + + # Runtime settings + - MYSQL_GENERAL_LOG=${MYSQL_GENERAL_LOG} + - MYSQL_INNODB_BUFFER_POOL_SIZE=${MYSQL_INNODB_BUFFER_POOL_SIZE} + - MYSQL_JOIN_BUFFER_SIZE=${MYSQL_JOIN_BUFFER_SIZE} + - MYSQL_SORT_BUFFER_SIZE=${MYSQL_SORT_BUFFER_SIZE} + - MYSQL_READ_RND_BUFFER_SIZE=${MYSQL_READ_RND_BUFFER_SIZE} + - MYSQL_SYMBOLIC_LINKS=${MYSQL_SYMBOLIC_LINKS} + - MYSQL_SQL_MODE=${MYSQL_SQL_MODE} + + ports: + # [local-machine:]local-port:docker-port + - "127.0.0.1:3306:3306" + + networks: + app_net: + ipv4_address: 172.16.238.12 + + volumes: + # ---- Format: ---- + # HOST-DIRECTORY : DOCKER-DIRECTORY + + # Mount logs + - ./log/${MYSQL_SERVER}:/var/log/mysql + + # Mount MySQL Socket directory + - ./run/mysql:/tmp/mysql + + # Mount MySQL Data directory + - ${HOST_PATH_TO_MYSQL_DATADIR}:/var/lib/mysql + + + +################################################################################ +# NETWORK +################################################################################ +networks: + app_net: + driver: bridge + driver_opts: + com.docker.network.enable_ipv6: "false" + ipam: + driver: default + config: + - subnet: 172.16.238.0/24 + gateway: 172.16.238.1 diff --git a/env-example b/env-example new file mode 100644 index 00000000..729f36c4 --- /dev/null +++ b/env-example @@ -0,0 +1,221 @@ +### +### --------------------------------------------------- +### D E V I L B O X R U N - T I M E S E T T I N G S +### --------------------------------------------------- +### +### All the following settings are applied during +### $ docker-compose up +### +### No need to rebuild any dockers! +### + + +### +### Show all executed commands in each +### docker image during docker-compose up? +### +### 1: Yes +### 0: No +DEBUG_COMPOSE_ENTRYPOINT=0 + + + +################################################################################ +### +### 1. Choose Images (Version) +### +################################################################################ + +### +### You can choose any combination of httpd, mysql or php. +### Each of them are fully compatible between one another. +### + + +### +### 1.1 Choose HTTP Server Image +### + +#HTTPD_SERVER=apache-2.2 +HTTPD_SERVER=apache-2.4 +#HTTPD_SERVER=nginx-1 + + +### +### 1.2 Choose MySQL Server Image +### + +MYSQL_SERVER=mysql-5.5 +#MYSQL_SERVER=mysql-5.6 +#MYSQL_SERVER=mysql-5.7 +#MYSQL_SERVER=mariadb-5 +#MYSQL_SERVER=mariadb-10 + + +### +### 1.3 Choose PHP Server Image +### + +#PHP_SERVER=php-5.5 +PHP_SERVER=php-fpm-5.6 +#PHP_SERVER=php-7.0 +#PHP_SERVER=php-7.1 +#PHP_SERVER=hhvm-3 + + + +### +### 1.4 Timezone for all dockers and service config files +### + +TIMEZONE=Europe/Berlin + + + + + + +################################################################################ +### +### 2. Host Settings (Your computer) +### +################################################################################ + + +## +## Local filesystem path to www projects. +## +## +HOST_PATH_TO_WWW_DOCROOTS=~/Sites + +## +## Local filesystem path to mysql datadir. +## +## This can be an existing mysql data directory or empty. +## If it already is a mysql data directory with content, +## it will be mounted into the docker and used. +## +## If this directory is empty, a new mysql database will be +## created. +## +HOST_PATH_TO_MYSQL_DATADIR=~/data/mysql6 + + + + +################################################################################ +### +### 3. HTTP Docker Settings +### +################################################################################ + +# - no options here + + + + +################################################################################ +### +### 4. MySQL Docker Settings +### +################################################################################ + +## +## MySQL root user password +## +## If $HOST_PATH_TO_MYSQL_DATADIR already contains an existing +## mysql datadir, enter the password for the existing mysql database +## +## If $HOST_PATH_TO_MYSQL_DATADIR is empty, choose a new password that +## will be applied +## +MYSQL_ROOT_PASSWORD= + + +### +### Custom MySQL Runtime Settings +### + +MYSQL_GENERAL_LOG=1 +MYSQL_INNODB_BUFFER_POOL_SIZE=512M +MYSQL_JOIN_BUFFER_SIZE=128M +MYSQL_SORT_BUFFER_SIZE=2M +MYSQL_READ_RND_BUFFER_SIZE=2M +MYSQL_SYMBOLIC_LINKS=0 +MYSQL_SQL_MODE=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES + + + + +################################################################################ +### +### 5. PHP-FPM Docker Settings +### +################################################################################ + + +### +### Xdebug +### + +# Enable/Disable Xdebug +PHP_XDEBUG_ENABLE=0 + +# Your local port (your computer host [not the docker]) +# where your ide/editor is listening for xdebug connections. +PHP_XDEBUG_REMOTE_PORT=9000 + +# Your local IP address (your computer host [not the docker]) +# where your ide/editor is listening for xdebug connections. +PHP_XDEBUG_REMOTE_HOST=172.20.10.2 +## TODO: Check if it works by automatically sending it to the broadcast address + + + +### +### PHP Tweaks +### + +# php.ini default setting: +# max_execution_time = 30 +PHP_MAX_EXECUTION_TIME=90 + +# php.ini default setting: +# max_input_time = 60 +PHP_MAX_INPUT_TIME=90 + +# php.ini default setting: +# memory_limit = 128M +PHP_MEMORY_LIMIT=256M + +# php.ini default setting: +# post_max_size = 8M +PHP_POST_MAX_SIZE=100M + +# php.ini default setting: +# upload_max_filesize = 2M +PHP_UPLOAD_MAX_FILESIZE=100M + +# php.ini default setting: +# max_input_vars = 1000 +PHP_MAX_INPUT_VARS=8000 + + + + +### +### PHP Error Handling +### + +# php.ini default setting: +# error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT +PHP_ERROR_REPORTING=E_ALL + +# php.ini default setting: +# display_errors = Off +PHP_DISPLAY_ERRORS=On + +# php.ini default setting: +# track_errors = Off +PHP_TRACK_ERRORS=On + diff --git a/etc/apache-2.4/00-defaults.conf b/etc/apache-2.4/00-defaults.conf new file mode 100644 index 00000000..3b05f01c --- /dev/null +++ b/etc/apache-2.4/00-defaults.conf @@ -0,0 +1,23 @@ +CustomLog "/var/log/apache-2.4/access_log" combined +ErrorLog "/var/log/apache-2.4/error_log" +LogLevel warn + +AddDefaultCharset UTF-8 + +# No DNS +HostnameLookups Off +# +Timeout 60 +KeepAlive On +KeepAliveTimeout 10 +MaxKeepAliveRequests 100 +# +# +EnableMMAP Off +EnableSendfile Off +# +# +# +# +XSendFile On +XSendFilePath /shared/httpd diff --git a/etc/apache-2.4/01-vhost-default.conf b/etc/apache-2.4/01-vhost-default.conf new file mode 100644 index 00000000..cc9b4c49 --- /dev/null +++ b/etc/apache-2.4/01-vhost-default.conf @@ -0,0 +1,57 @@ +## +## Default Host for http://localhost +## + + + ServerName localhost + ServerAdmin root@localhost + + ErrorLog /var/log/apache-2.4/localhost-error.log + CustomLog /var/log/apache-2.4/localhost-access.log combined + + DirectoryIndex index.php index.html + + + #RewriteEngine On + #RewriteRule ^/(.*\.php(/.*)?)$ fcgi://172.16.238.11:9000/var/www/default/htdocs/$1 [P] + + + # enablereuse + # Defining a worker will improve performance + # And in this case, re-use the worker (dependent on support from the fcgi application) + # If you have enough idle workers, this would only improve the performance marginally + # + # enablereuse requires Apache 2.4.11 or later + # + + Require all granted + # Pick one of the following approaches + # Use the standard TCP socket + SetHandler "proxy:fcgi://172.16.238.11:9000" + # If your version of httpd is 2.4.9 or newer (or has the back-ported feature), you can use the unix domain socket + #SetHandler "proxy:unix:/path/to/app.sock|fcgi://localhost/:9000" + + + + DocumentRoot "/var/www/default/htdocs" + + DirectoryIndex index.php index.html + + AllowOverride All + Options All + + RewriteEngine on + RewriteBase / + + + Order allow,deny + Allow from all + + # Apache 2.4 + Require all granted + + + + + + diff --git a/etc/apache-2.4/02-vhost-mass.conf b/etc/apache-2.4/02-vhost-mass.conf new file mode 100644 index 00000000..dc11ace2 --- /dev/null +++ b/etc/apache-2.4/02-vhost-mass.conf @@ -0,0 +1,69 @@ +## +## Default Mass Virtual Host +## + + + + # Get the server name from the Host: header + UseCanonicalName Off + + ServerName localhost + ServerAlias *.loc + ServerAdmin root@localhost + + # splitlogs.php is a custom script, which will filter the domain + # and create separate logfiles per domain. + LogFormat "%V;%h;%l;%u;%t;\"%r\";%>s;%b;\"%{Referer}i\";\"%{User-agent}i\"" vcommon + CustomLog "|/opt/bin/splitlogs.php" vcommon + + ErrorLog /var/log/apache-2.4/other-error.log + + DirectoryIndex index.php index.html + + # When using VirtualDocumentRoot the PHP Env var DOCUMENT_ROOT + # is not filled, so we need to do that manually with a custom script. + VirtualDocumentRoot /shared/httpd/%-2+/htdocs/ + php_admin_value auto_prepend_file /opt/bin/fix-virtual-docroot.php + + # + # Require all granted + # SetHandler proxy:fcgi://172.16.238.11:9000 + # + + + # enablereuse + # Defining a worker will improve performance + # And in this case, re-use the worker (dependent on support from the fcgi application) + # If you have enough idle workers, this would only improve the performance marginally + # + # enablereuse requires Apache 2.4.11 or later + # + + Require all granted + # Pick one of the following approaches + # Use the standard TCP socket + SetHandler "proxy:fcgi://172.16.238.11:9000" + # If your version of httpd is 2.4.9 or newer (or has the back-ported feature), you can use the unix domain socket + #SetHandler "proxy:unix:/path/to/app.sock|fcgi://localhost/:9000" + + + + + + DirectoryIndex index.php index.html + + AllowOverride All + Options All + + RewriteEngine on + RewriteBase / + + Order allow,deny + Allow from all + Require all granted + + + + + + diff --git a/www/config.php b/www/config.php new file mode 100644 index 00000000..732ae0fa --- /dev/null +++ b/www/config.php @@ -0,0 +1,31 @@ +.navbar-collapse, .container-fluid>.navbar-header, .container>.navbar-collapse, .container>.navbar-header { + margin-right: -15px; + margin-left: -15px; +} + + + +/* navbar toggle */ +.navbar-inverse .navbar-toggle { + border-color: #333; +} +.navbar-inverse .navbar-toggle .icon-bar { + background-color: #fff; +} +.navbar-toggle .icon-bar+.icon-bar { + margin-top: 4px; +} +.navbar-toggle .icon-bar { + display: block; + width: 22px; + height: 2px; + border-radius: 1px; +} +.navbar-toggle { + position: relative; + float: right; + padding: 9px 10px; + margin-top: 8px; + margin-right: 15px; + margin-bottom: 8px; + background-color: transparent; + background-image: none; + border: 1px solid transparent; + border-radius: 4px; +} +.navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form { + border-color: #101010; +} +.navbar-collapse { + padding-right: 15px; + padding-left: 15px; + overflow-x: visible; + -webkit-overflow-scrolling: touch; + border-top: 1px solid transparent; + -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.1); + box-shadow: inset 0 1px 0 rgba(255,255,255,.1); +} +.collapse { + display: none; +} + + + +/* navbar brand */ +span.navbar-brand { + background-color: transparent !important; + cursor:default; +} +.navbar-brand { + float: left; + height: 50px; + padding: 15px 15px; + font-size: 18px; + line-height: 20px; + color: #337ab7; +} + + + +/* misc */ +.container { + padding-right: 15px; + padding-left: 15px; + margin-right: auto; + margin-left: auto; +} + +.sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0,0,0,0); + border: 0; +} + + + +/* li */ +.nav>li { + position: relative; + display: block; +} +.navbar-inverse .navbar-nav>li>a { + background-color: transparent !important; +} +.navbar-inverse .navbar-nav>li>a { + color: #9d9d9d; +} +.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:focus, .navbar-inverse .navbar-nav>.active>a:hover { + color: #fff; + background-color: #080808; +} +.navbar-nav>li>a { + padding-top: 10px; + padding-bottom: 10px; + line-height: 20px; +} +.nav>li>a { + position: relative; + display: block; + padding: 10px 15px; +} + + + +/* container, row, column */ +.container { + padding-right: 15px; + padding-left: 15px; + margin-right: auto; + margin-left: auto; +} +.row { + margin-right: -15px; + margin-left: -15px; +} +.col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 { + position: relative; + min-height: 1px; + padding-right: 15px; + padding-left: 15px; +} + + + +/* table */ +.table { + width: 100%; + max-width: 100%; + margin-bottom: 20px; +} +.table-striped>tbody>tr:nth-of-type(odd) { + background-color: #f9f9f9; +} +.table>caption+thead>tr:first-child>td, .table>caption+thead>tr:first-child>th, .table>colgroup+thead>tr:first-child>td, .table>colgroup+thead>tr:first-child>th, .table>thead:first-child>tr:first-child>td, .table>thead:first-child>tr:first-child>th { + border-top: 0; +} +.table>thead>tr>th { + vertical-align: bottom; + border-bottom: 2px solid #ddd; +} +.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th { + padding: 8px; + line-height: 1.42857143; + vertical-align: top; + border-top: 1px solid #ddd; +} +.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th { + padding: 8px; + line-height: 1.42857143; + vertical-align: top; + border-top: 1px solid #ddd; +} + + + +/******************************************************************************** + * Media queries + ********************************************************************************/ +@media (min-width: 768px) { + .navbar-static-top { + border-radius: 0; + } + .navbar { + border-radius: 4px; + } + .container { + width: 750px; + } + .container-fluid>.navbar-collapse, .container-fluid>.navbar-header, .container>.navbar-collapse, .container>.navbar-header { + margin-right: 0; + margin-left: 0; + } + .navbar-header { + float: left; + } + .navbar-toggle { + display: none; + } + .container-fluid>.navbar-collapse, .container-fluid>.navbar-header, .container>.navbar-collapse, .container>.navbar-header { + margin-right: 0; + margin-left: 0; + } + .navbar-fixed-bottom .navbar-collapse, .navbar-fixed-top .navbar-collapse, .navbar-static-top .navbar-collapse { + padding-right: 0; + padding-left: 0; + } + .navbar-collapse.collapse { + display: block!important; + height: auto!important; + padding-bottom: 0; + overflow: visible!important; + } + .navbar-collapse { + width: auto; + border-top: 0; + -webkit-box-shadow: none; + box-shadow: none; + } + .navbar-nav { + float: left; + margin: 0; + } + .navbar-nav>li { + float: left; + } + .navbar-nav>li>a { + padding-top: 15px; + padding-bottom: 15px; + } +} +@media (min-width: 992px) { + .container { + width: 970px; + } + .col-md-12 { + width: 100%; + } + .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9 { + float: left; + } +} +@media (min-width: 1200px) { + .container { + width: 1170px; + } +} + + +/* Overwrites for PHPinfo(); */ +a.navbar-brand { + background-color: transparent !important; +} +.navbar-inverse .navbar-nav>li>a { + background-color: transparent !important; +} diff --git a/www/htdocs/databases.php b/www/htdocs/databases.php new file mode 100644 index 00000000..737f1555 --- /dev/null +++ b/www/htdocs/databases.php @@ -0,0 +1,73 @@ + + + + + + + + + + + + + DevilBox + + + + + + +
+ +

Databases

+
+
+ +
+
+ + + + + + + + + + $size): ?> + + + + + + +
NameSize
MB
+
+
+ +
+ + + diff --git a/www/htdocs/index.php b/www/htdocs/index.php new file mode 100644 index 00000000..26c64bae --- /dev/null +++ b/www/htdocs/index.php @@ -0,0 +1,218 @@ + + + + + + + + + + + + + DevilBox + + + + + + +
+ +

DevilBox Overview

+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Docker Images

Webserver   (IP: )
PHP   (IP: )
MySQL Server   (IP: )

Host computer

MySQL datadir
MySQL socket./run/mysql/mysql.sock
WWW Document Roots
Log dir./log

[docker] HTTPD

--

[docker] PHP

MySQL Remote Port forwarded to PHP Docker?
MySQL Remote Socket mounted on PHP Docker? + +
PHP-MySQL connection test: localhost
PHP-MySQL connection test: 127.0.0.1
PHP-MySQL connection test:
PHP custom run-time options +
+
+
+xdebug.remote_enable  = 
+xdebug.remote_port    = 
+xdebug.remote_host    = 
+
+
+max_execution_time    = 
+max_input_time        = 
+memory_limit          = 
+post_max_size         = 
+upload_max_filesize   = 
+max_input_vars        = 
+
+error_reporting       = 
+display_errors        = 
+track_errors          = 
+									
+

[docker] MySQL

MySQL root password
MySQL socket
MySQL custom run-time options +
+general_log             = 
+innodb_buffer_pool_size = 
+join_buffer_size        = 
+sort_buffer_size        = 
+read_rnd_buffer_size    = 
+symbolic_links          = 
+sql_mode                = 
+									
+
+ + +
+
+ +
+ + + + diff --git a/www/htdocs/php.php b/www/htdocs/php.php new file mode 100644 index 00000000..d287e32f --- /dev/null +++ b/www/htdocs/php.php @@ -0,0 +1,51 @@ + + + + + + + + + + + + + DevilBox + + + + + + +
+ +
+
+ +
+
+ +
+ + + diff --git a/www/htdocs/vhosts.php b/www/htdocs/vhosts.php new file mode 100644 index 00000000..0b758ff9 --- /dev/null +++ b/www/htdocs/vhosts.php @@ -0,0 +1,111 @@ + + + + + + + + + + + + + DevilBox + + + + + + +
+ +

Virtual Hosts

+
+
+ +
+
+ + + + + + + + + + + + + + htdocs directory in: '.$ENV['HOST_PATH_TO_WWW_DOCROOTS'].'/'.$vHost['name'].'/'; + $ern++; + } + if ($vHost['dns_ok']) { + + if ($vHost['dns_ip'] != '127.0.0.1') { + $err[] = 'Error in /etc/hosts
'. + 'Found:
'. + ''.$vHost['dns_ip'].' '.$vHost['domain'].'
'. + 'But it should be:
'. + '127.0.0.1 '.$vHost['domain'].'
'; + $ern++; + + } + } else { + $err[] = 'Missing entry in /etc/hosts:
127.0.0.1 '.$vHost['domain'].''; + $ern++; + } + ?> + + + + + + + + + + + + +
ProjectDocumentRootValidURL
//htdocs + ', $err); ?> + OK
+ +

No projects here.

+

Simply create a folder in (on your host computer - not inside the docker).

+

Example:
/my_project

+ +
+
+ +
+ + + diff --git a/www/include/functions.php b/www/include/functions.php new file mode 100644 index 00000000..e61ce167 --- /dev/null +++ b/www/include/functions.php @@ -0,0 +1,189 @@ + size + */ +function getDatabases() { + global $MYSQL_HOST_ADDR; + global $MYSQL_ROOT_PASS; + $conn = mysqli_connect($MYSQL_HOST_ADDR, 'root', $MYSQL_ROOT_PASS); + + $sql = 'SELECT + table_schema AS db_name, + SUM( data_length + index_length ) / 1024 / 1024 "MB" + FROM + information_schema.TABLES + WHERE + table_schema != "mysql" AND + table_schema != "performance_schema" AND + table_schema != "information_schema" + GROUP BY + table_schema + ORDER BY db_name;'; + + $result = mysqli_query($conn, $sql); + $data = array(); + while ($row = $result->fetch_array(MYSQLI_NUM)) { + // name => size + $data[$row[0]] = $row[1]; + } + mysqli_close($conn); + return $data; +} + + +function is_valid_dir($path) { + return (is_dir($path) || (is_link($path) && is_dir(readlink($path)))); +} + +/** + * Get all VirtualHosts + * @return [type] [description] + */ +function getVhosts() { + global $ENV; + + $docRoot = '/shared/httpd'; + $vhosts = array(); + + + if ($handle = opendir($docRoot)) { + while (false !== ($directory = readdir($handle))) { + if (is_valid_dir($docRoot . DIRECTORY_SEPARATOR . $directory) && $directory != '.' && $directory != '..') { + + $output; + $domain = $directory.'.loc'; + $url = 'http://'.$domain; + + $htdocs_ok = is_valid_dir($docRoot.DIRECTORY_SEPARATOR.$directory.DIRECTORY_SEPARATOR.'htdocs'); + $dns_ok = my_exec('getent hosts '.$domain, $output) == 0 ? TRUE : FALSE; + $dns_ip = ''; + if (isset($output[0])) { + $tmp = explode(' ', $output[0]); + if (isset($tmp[0])) { + $dns_ip = $tmp[0]; + } + } + + $vhosts[] = array( + 'name' => $directory, + 'htdocs' => $htdocs_ok, + 'dns_ok' => $dns_ok, + 'dns_ip' => $dns_ip, + 'domain' => $directory.'.loc', + 'href' => 'http://' . $directory.'.loc' + ); + } + } + } + return $vhosts; +} + + + +/******************************************************************************** + * + * G E T V E R S I O N + * + ********************************************************************************/ +/** + * Get HTTPD Version + * @return [type] [description] + */ +function getHttpVersion() { + preg_match('/\w+\/[.0-9]+/i', $_SERVER['SERVER_SOFTWARE'], $matches); + if (isset($matches[0])) { + return $matches[0]; + } else { + return 'Unknown Webserver'; + } +} + +/** + * Get MySQL Version + * @return [type] [description] + */ + +function getMySQLVersion() { + return getMySQLConfig('version_comment') . ' ' . getMySQLConfig('version'); +} + +function getPHPVersion() { + return 'PHP ' . phpversion() .' (' . php_sapi_name().')'; +} + + + +function getMySQLConfig($key) { + global $MYSQL_HOST_ADDR; + global $MYSQL_ROOT_PASS; + + $link = @mysqli_connect($MYSQL_HOST_ADDR, 'root', $MYSQL_ROOT_PASS); + + if (!$link) { + return 'Cannot conncet to MySQL Database: '.mysqli_connect_error(); + } + $key = str_replace('-', '_', $key); + $query = 'SHOW VARIABLES WHERE Variable_Name = "'.$key.'";'; + $result = mysqli_query($link, $query); + $data = mysqli_fetch_array($result); + if (isset($data[1])) { + return $data[1]; + } + return FALSE; +} + + + +/******************************************************************************** + * + * T E S T M Y S Q L C O N N E C T I O N + * + ********************************************************************************/ + + +function testMySQLLocalhost() { + global $MYSQL_ROOT_PASS; + + $link = @mysqli_connect('localhost', 'root', $MYSQL_ROOT_PASS); + if (!$link) { + return 'Cannot conncet to MySQL Database: '.mysqli_connect_error(); + } + return 'OK: Connection via localhost socket'; +} +function testMySQLLocalIp() { + global $MYSQL_ROOT_PASS; + + $link = @mysqli_connect('127.0.0.1', 'root', $MYSQL_ROOT_PASS); + if (!$link) { + return 'Cannot conncet to MySQL Database: '.mysqli_connect_error(); + } + return 'OK: Connection via 127.0.0.1'; +} +function testMySQLRemotelIp() { + global $MYSQL_HOST_ADDR; + global $MYSQL_ROOT_PASS; + + $link = @mysqli_connect($MYSQL_HOST_ADDR, 'root', $MYSQL_ROOT_PASS); + if (!$link) { + return 'Cannot conncet to MySQL Database: '.mysqli_connect_error(); + } + return 'OK: Connection via '.$MYSQL_HOST_ADDR; +} +