├── .dockerignore ├── Dockerfile ├── LICENSE ├── README.md ├── apache_default └── run /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER Alexander Schenkel 3 | 4 | VOLUME ["/var/www"] 5 | 6 | RUN apt-get update && \ 7 | apt-get install -y \ 8 | apache2 \ 9 | php5 \ 10 | php5-cli \ 11 | libapache2-mod-php5 \ 12 | php5-gd \ 13 | php5-json \ 14 | php5-ldap \ 15 | php5-mysql \ 16 | php5-pgsql 17 | 18 | COPY apache_default /etc/apache2/sites-available/000-default.conf 19 | COPY run /usr/local/bin/run 20 | RUN chmod +x /usr/local/bin/run 21 | RUN a2enmod rewrite 22 | 23 | EXPOSE 80 24 | CMD ["/usr/local/bin/run"] 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Alexander Schenkel 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 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | apache-php 2 | =================================== 3 | 4 | A Docker image based on Ubuntu, serving PHP 5.5 running as Apache Module. Useful for Web developers in need for a fixed PHP version. In addition, the `error_reporting` setting in php.ini is configurable per container via environment variable. 5 | 6 | Tags 7 | ----- 8 | 9 | * latest: Ubuntu 14.04 (LTS), Apache 2.4, PHP 5.5.9 with support for setting `error_reporting` 10 | 11 | Usage 12 | ------ 13 | 14 | ``` 15 | $ docker run -d -P bylexus/apache-php55 16 | ``` 17 | 18 | With all the options: 19 | 20 | ```bash 21 | $ docker run -d -p 8080:80 \ 22 | -v /home/user/webroot:/var/www \ 23 | -e PHP_ERROR_REPORTING='E_ALL & ~E_STRICT' \ 24 | docker run -d -P bylexus/apache-php55 25 | ``` 26 | 27 | * `-v [local path]:/var/www` maps the container's webroot to a local path 28 | * `-p [local port]:80` maps a local port to the container's HTTP port 80 29 | * `-e PHP_ERROR_REPORTING=[php error_reporting settings]` sets the value of `error_reporting` in the php.ini files. 30 | 31 | ### Access apache logs 32 | 33 | Apache is configured to log both access and error log to STDOUT. So you can simply use `docker logs` to get the log output: 34 | 35 | `docker logs -f container-id` 36 | 37 | 38 | Installed packages 39 | ------------------- 40 | * Ubuntu Server 14.04, based on ubuntu docker image 41 | * apache2 42 | * php5 43 | * php5-cli 44 | * libapache2-mod-php5 45 | * php5-gd 46 | * php5-json 47 | * php5-ldap 48 | * php5-mysql 49 | * php5-pgsql 50 | 51 | Configurations 52 | ---------------- 53 | 54 | * Apache: .htaccess-Enabled in webroot (mod_rewrite with AllowOverride all) 55 | * php.ini: 56 | * display_errors = On 57 | * error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE (default, overridable per env variable) 58 | -------------------------------------------------------------------------------- /apache_default: -------------------------------------------------------------------------------- 1 | 2 | # The ServerName directive sets the request scheme, hostname and port that 3 | # the server uses to identify itself. This is used when creating 4 | # redirection URLs. In the context of virtual hosts, the ServerName 5 | # specifies what hostname must appear in the request's Host: header to 6 | # match this virtual host. For the default virtual host (this file) this 7 | # value is not decisive as it is used as a last resort host regardless. 8 | # However, you must set it for any further virtual host explicitly. 9 | #ServerName www.example.com 10 | 11 | ServerAdmin webmaster@localhost 12 | DocumentRoot /var/www 13 | 14 | 15 | AllowOverride All 16 | Require all granted 17 | 18 | 19 | # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 20 | # error, crit, alert, emerg. 21 | # It is also possible to configure the loglevel for particular 22 | # modules, e.g. 23 | #LogLevel info ssl:warn 24 | 25 | ErrorLog /dev/stdout 26 | CustomLog /dev/stdout combined 27 | 28 | # For most configuration files from conf-available/, which are 29 | # enabled or disabled at a global level, it is possible to 30 | # include a line for only one particular virtual host. For example the 31 | # following line enables the CGI configuration for this host only 32 | # after it has been globally disabled with "a2disconf". 33 | #Include conf-available/serve-cgi-bin.conf 34 | 35 | 36 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet 37 | -------------------------------------------------------------------------------- /run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | PHP_ERROR_REPORTING=${PHP_ERROR_REPORTING:-"E_ALL & ~E_DEPRECATED & ~E_NOTICE"} 5 | sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/apache2/php.ini 6 | sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/cli/php.ini 7 | sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/apache2/php.ini 8 | sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/cli/php.ini 9 | echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/apache2/php.ini 10 | echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/cli/php.ini 11 | 12 | # Apache gets grumpy about PID files pre-existing 13 | rm -f /var/run/apache2/apache2.pid 14 | 15 | source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND 16 | --------------------------------------------------------------------------------