├── Dockerfile ├── LICENSE ├── README.md ├── debconf.selections ├── docker_139x115.png ├── docker_fauria_161x115.png ├── index.php └── run-lamp.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | MAINTAINER Fer Uria 3 | LABEL Description="Cutting-edge LAMP stack, based on Ubuntu 16.04 LTS. Includes .htaccess support and popular PHP7 features, including composer and mail() function." \ 4 | License="Apache License 2.0" \ 5 | Usage="docker run -d -p [HOST WWW PORT NUMBER]:80 -p [HOST DB PORT NUMBER]:3306 -v [HOST WWW DOCUMENT ROOT]:/var/www/html -v [HOST DB DOCUMENT ROOT]:/var/lib/mysql fauria/lamp" \ 6 | Version="1.0" 7 | 8 | RUN apt-get update 9 | RUN apt-get upgrade -y 10 | 11 | COPY debconf.selections /tmp/ 12 | RUN debconf-set-selections /tmp/debconf.selections 13 | 14 | RUN apt-get install -y zip unzip 15 | RUN apt-get install -y \ 16 | php7.0 \ 17 | php7.0-bz2 \ 18 | php7.0-cgi \ 19 | php7.0-cli \ 20 | php7.0-common \ 21 | php7.0-curl \ 22 | php7.0-dev \ 23 | php7.0-enchant \ 24 | php7.0-fpm \ 25 | php7.0-gd \ 26 | php7.0-gmp \ 27 | php7.0-imap \ 28 | php7.0-interbase \ 29 | php7.0-intl \ 30 | php7.0-json \ 31 | php7.0-ldap \ 32 | php7.0-mbstring \ 33 | php7.0-mcrypt \ 34 | php7.0-mysql \ 35 | php7.0-odbc \ 36 | php7.0-opcache \ 37 | php7.0-pgsql \ 38 | php7.0-phpdbg \ 39 | php7.0-pspell \ 40 | php7.0-readline \ 41 | php7.0-recode \ 42 | php7.0-snmp \ 43 | php7.0-sqlite3 \ 44 | php7.0-sybase \ 45 | php7.0-tidy \ 46 | php7.0-xmlrpc \ 47 | php7.0-xsl \ 48 | php7.0-zip 49 | RUN apt-get install apache2 libapache2-mod-php7.0 -y 50 | RUN apt-get install mariadb-common mariadb-server mariadb-client -y 51 | RUN apt-get install postfix -y 52 | RUN apt-get install git nodejs npm composer nano tree vim curl ftp -y 53 | RUN npm install -g bower grunt-cli gulp 54 | 55 | ENV LOG_STDOUT **Boolean** 56 | ENV LOG_STDERR **Boolean** 57 | ENV LOG_LEVEL warn 58 | ENV ALLOW_OVERRIDE All 59 | ENV DATE_TIMEZONE UTC 60 | ENV TERM dumb 61 | 62 | COPY index.php /var/www/html/ 63 | COPY run-lamp.sh /usr/sbin/ 64 | 65 | RUN a2enmod rewrite 66 | RUN ln -s /usr/bin/nodejs /usr/bin/node 67 | RUN chmod +x /usr/sbin/run-lamp.sh 68 | RUN chown -R www-data:www-data /var/www/html 69 | 70 | VOLUME /var/www/html 71 | VOLUME /var/log/httpd 72 | VOLUME /var/lib/mysql 73 | VOLUME /var/log/mysql 74 | VOLUME /etc/apache2 75 | 76 | EXPOSE 80 77 | EXPOSE 3306 78 | 79 | CMD ["/usr/sbin/run-lamp.sh"] 80 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Fer Uría 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | fauria/lamp 2 | ========== 3 | 4 | ![docker_logo](https://raw.githubusercontent.com/fauria/docker-lamp/master/docker_139x115.png)![docker_fauria_logo](https://raw.githubusercontent.com/fauria/docker-lamp/master/docker_fauria_161x115.png) 5 | 6 | [![Docker Pulls](https://img.shields.io/docker/pulls/fauria/lamp.svg?style=plastic)](https://hub.docker.com/r/fauria/lamp/) 7 | [![Docker Build Status](https://img.shields.io/docker/build/fauria/lamp.svg?style=plastic)](https://hub.docker.com/r/fauria/lamp/builds/) 8 | [![](https://images.microbadger.com/badges/image/fauria/lamp.svg)](https://microbadger.com/images/fauria/lamp "fauria/lamp") 9 | 10 | This Docker container implements a last generation LAMP stack with a set of popular PHP modules. Includes support for [Composer](https://getcomposer.org/), [Bower](http://bower.io/) and [npm](https://www.npmjs.com/) package managers and a Postfix service to allow sending emails through PHP [mail()](http://php.net/manual/en/function.mail.php) function. 11 | 12 | If you dont need support for MySQL/MariaDB, or your app runs on PHP 5.4, maybe [fauria/lap](https://hub.docker.com/r/fauria/lap) suits your needs better. 13 | 14 | Includes the following components: 15 | 16 | * Ubuntu 16.04 LTS Xenial Xerus base image. 17 | * Apache HTTP Server 2.4 18 | * MariaDB 10.0 19 | * Postfix 2.11 20 | * PHP 7 21 | * PHP modules 22 | * php-bz2 23 | * php-cgi 24 | * php-cli 25 | * php-common 26 | * php-curl 27 | * php-dbg 28 | * php-dev 29 | * php-enchant 30 | * php-fpm 31 | * php-gd 32 | * php-gmp 33 | * php-imap 34 | * php-interbase 35 | * php-intl 36 | * php-json 37 | * php-ldap 38 | * php-mcrypt 39 | * php-mysql 40 | * php-odbc 41 | * php-opcache 42 | * php-pgsql 43 | * php-phpdbg 44 | * php-pspell 45 | * php-readline 46 | * php-recode 47 | * php-snmp 48 | * php-sqlite3 49 | * php-sybase 50 | * php-tidy 51 | * php-xmlrpc 52 | * php-xsl 53 | * Development tools 54 | * git 55 | * composer 56 | * npm / nodejs 57 | * bower 58 | * vim 59 | * tree 60 | * nano 61 | * ftp 62 | * curl 63 | 64 | Installation from [Docker registry hub](https://registry.hub.docker.com/r/fauria/lamp/). 65 | ---- 66 | 67 | You can download the image using the following command: 68 | 69 | ```bash 70 | docker pull fauria/lamp 71 | ``` 72 | 73 | Environment variables 74 | ---- 75 | 76 | This image uses environment variables to allow the configuration of some parameteres at run time: 77 | 78 | * Variable name: LOG_STDOUT 79 | * Default value: Empty string. 80 | * Accepted values: Any string to enable, empty string or not defined to disable. 81 | * Description: Output Apache access log through STDOUT, so that it can be accessed through the [container logs](https://docs.docker.com/reference/commandline/logs/). 82 | 83 | ---- 84 | 85 | * Variable name: LOG_STDERR 86 | * Default value: Empty string. 87 | * Accepted values: Any string to enable, empty string or not defined to disable. 88 | * Description: Output Apache error log through STDERR, so that it can be accessed through the [container logs](https://docs.docker.com/reference/commandline/logs/). 89 | 90 | ---- 91 | 92 | * Variable name: LOG_LEVEL 93 | * Default value: warn 94 | * Accepted values: debug, info, notice, warn, error, crit, alert, emerg 95 | * Description: Value for Apache's [LogLevel directive](http://httpd.apache.org/docs/2.4/en/mod/core.html#loglevel). 96 | 97 | ---- 98 | 99 | * Variable name: ALLOW_OVERRIDE 100 | * Default value: All 101 | * All, None 102 | * Accepted values: Value for Apache's [AllowOverride directive](http://httpd.apache.org/docs/2.4/en/mod/core.html#allowoverride). 103 | * Description: Used to enable (`All`) or disable (`None`) the usage of an `.htaccess` file. 104 | 105 | ---- 106 | 107 | * Variable name: DATE_TIMEZONE 108 | * Default value: UTC 109 | * Accepted values: Any of PHP's [supported timezones](http://php.net/manual/en/timezones.php) 110 | * Description: Set php.ini default date.timezone directive and sets MariaDB as well. 111 | 112 | ---- 113 | 114 | * Variable name: TERM 115 | * Default value: dumb 116 | * Accepted values: dumb 117 | * Description: Allow usage of terminal programs inside the container, such as `mysql` or `nano`. 118 | 119 | Exposed port and volumes 120 | ---- 121 | 122 | The image exposes ports `80` and `3306`, and exports four volumes: 123 | 124 | * `/var/log/httpd`, containing Apache log files. 125 | * `/var/log/mysql` containing MariaDB log files. 126 | * `/var/www/html`, used as Apache's [DocumentRoot directory](http://httpd.apache.org/docs/2.4/en/mod/core.html#documentroot). 127 | * `/var/lib/mysql`, where MariaDB data files are stored. 128 | * `/etc/apache2`, where Apache configuration files are stored. 129 | 130 | Please, refer to https://docs.docker.com/storage/volumes for more information on using host volumes. 131 | 132 | The user and group owner id for the DocumentRoot directory `/var/www/html` are both 33 (`uid=33(www-data) gid=33(www-data) groups=33(www-data)`). 133 | 134 | The user and group owner id for the MariaDB directory `/var/log/mysql` are 105 and 108 repectively (`uid=105(mysql) gid=108(mysql) groups=108(mysql)`). 135 | 136 | Use cases 137 | ---- 138 | 139 | #### Create a temporary container for testing purposes: 140 | 141 | ``` 142 | docker run -i -t --rm fauria/lamp bash 143 | ``` 144 | 145 | #### Create a temporary container to debug a web app: 146 | 147 | ``` 148 | docker run --rm -p 8080:80 -e LOG_STDOUT=true -e LOG_STDERR=true -e LOG_LEVEL=debug -v /my/data/directory:/var/www/html fauria/lamp 149 | ``` 150 | 151 | #### Create a container linking to another [MySQL container](https://registry.hub.docker.com/_/mysql/): 152 | 153 | ``` 154 | docker run -d --link my-mysql-container:mysql -p 8080:80 -v /my/data/directory:/var/www/html -v /my/logs/directory:/var/log/httpd --name my-lamp-container fauria/lamp 155 | ``` 156 | 157 | #### Get inside a running container and open a MariaDB console: 158 | 159 | ``` 160 | docker exec -i -t my-lamp-container bash 161 | mysql -u root 162 | ``` 163 | -------------------------------------------------------------------------------- /debconf.selections: -------------------------------------------------------------------------------- 1 | postfix postfix/mailname string localhost 2 | postfix postfix/main_mailer_type string 'Docker Postfix' 3 | -------------------------------------------------------------------------------- /docker_139x115.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fauria/docker-lamp/27c8884231e0ba3d7958bb8d34c230509abd6d10/docker_139x115.png -------------------------------------------------------------------------------- /docker_fauria_161x115.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fauria/docker-lamp/27c8884231e0ba3d7958bb8d34c230509abd6d10/docker_fauria_161x115.png -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /run-lamp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function exportBoolean { 4 | if [ "${!1}" = "**Boolean**" ]; then 5 | export ${1}='' 6 | else 7 | export ${1}='Yes.' 8 | fi 9 | } 10 | 11 | exportBoolean LOG_STDOUT 12 | exportBoolean LOG_STDERR 13 | 14 | if [ $LOG_STDERR ]; then 15 | /bin/ln -sf /dev/stderr /var/log/apache2/error.log 16 | else 17 | LOG_STDERR='No.' 18 | fi 19 | 20 | if [ $ALLOW_OVERRIDE == 'All' ]; then 21 | /bin/sed -i 's/AllowOverride\ None/AllowOverride\ All/g' /etc/apache2/apache2.conf 22 | fi 23 | 24 | if [ $LOG_LEVEL != 'warn' ]; then 25 | /bin/sed -i "s/LogLevel\ warn/LogLevel\ ${LOG_LEVEL}/g" /etc/apache2/apache2.conf 26 | fi 27 | 28 | # enable php short tags: 29 | /bin/sed -i "s/short_open_tag\ \=\ Off/short_open_tag\ \=\ On/g" /etc/php/7.0/apache2/php.ini 30 | 31 | # stdout server info: 32 | if [ ! $LOG_STDOUT ]; then 33 | cat << EOB 34 | 35 | ********************************************** 36 | * * 37 | * Docker image: fauria/lamp * 38 | * https://github.com/fauria/docker-lamp * 39 | * * 40 | ********************************************** 41 | 42 | SERVER SETTINGS 43 | --------------- 44 | · Redirect Apache access_log to STDOUT [LOG_STDOUT]: No. 45 | · Redirect Apache error_log to STDERR [LOG_STDERR]: $LOG_STDERR 46 | · Log Level [LOG_LEVEL]: $LOG_LEVEL 47 | · Allow override [ALLOW_OVERRIDE]: $ALLOW_OVERRIDE 48 | · PHP date timezone [DATE_TIMEZONE]: $DATE_TIMEZONE 49 | 50 | EOB 51 | else 52 | /bin/ln -sf /dev/stdout /var/log/apache2/access.log 53 | fi 54 | 55 | # Set PHP timezone 56 | /bin/sed -i "s/\;date\.timezone\ \=/date\.timezone\ \=\ ${DATE_TIMEZONE}/" /etc/php/7.0/apache2/php.ini 57 | 58 | # Run Postfix 59 | /usr/sbin/postfix start 60 | 61 | # Run MariaDB 62 | /usr/bin/mysqld_safe --timezone=${DATE_TIMEZONE}& 63 | 64 | # Run Apache: 65 | if [ $LOG_LEVEL == 'debug' ]; then 66 | /usr/sbin/apachectl -DFOREGROUND -k start -e debug 67 | else 68 | &>/dev/null /usr/sbin/apachectl -DFOREGROUND -k start 69 | fi 70 | --------------------------------------------------------------------------------