Skip to content

Commit

Permalink
Add jessie supported legacy build
Browse files Browse the repository at this point in the history
  • Loading branch information
macropin committed Aug 13, 2018
1 parent 2882630 commit 49271e9
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Apache Mass Virtual Host

Apache Mass Virtual Host for PHP and static HTML websites:

More information:

- [Jessie Base](jessie)
- [Stretch Base](stretch)
34 changes: 34 additions & 0 deletions jessie/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM debian:jessie

EXPOSE 80

# Install Requirements
RUN apt-get update && \
apt-get install -y apache2-mpm-prefork ca-certificates msmtp && \
apt-get install -y libapache2-mod-php5 php5 php5-gd php-pear php5-mysql php5-pgsql php5-sqlite php5-mcrypt php5-intl php5-ldap && \
apt-get install -y vim wget && \
# Install Pear Requirements
pear install mail_mime mail_mimedecode net_smtp net_idna2-beta auth_sasl net_sieve crypt_gpg && \
# Cleanup
rm -rf /var/lib/apt/lists/*

# Install PHP Extras
RUN cd /tmp \
&& wget https://github.com/panubo/php-extras/archive/master.tar.gz \
&& tar --wildcards -C /usr/share/php/ -xvf master.tar.gz --strip 1 '*.php' \
&& rm -f /tmp/master.tar.gz

# Host Configuration
COPY apache2.conf /etc/apache2/apache2.conf
COPY mpm_prefork.conf /etc/apache2/mods-available/
COPY vhost.conf /etc/apache2/sites-available/
RUN rm /etc/apache2/conf-enabled/* /etc/apache2/sites-enabled/* && \
a2enmod vhost_alias mpm_prefork deflate rewrite expires headers php5 && \
a2ensite vhost.conf && \
sed -i -e 's@^;sendmail_path =.*@sendmail_path = /usr/bin/msmtp -t -i@g' /etc/php5/apache2/php.ini /etc/php5/cli/php.ini && \
sed -i -e 's@short_open_tag =.*@short_open_tag = On@g' /etc/php5/apache2/php.ini /etc/php5/cli/php.ini && \
mkdir -p /srv/www

ADD entry.sh /
ENTRYPOINT ["/entry.sh"]
CMD [ "/usr/sbin/apache2ctl", "-D", "FOREGROUND", "-k", "start" ]
16 changes: 16 additions & 0 deletions jessie/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
TAG := $(shell basename ${PWD})
IMAGE := panubo/apache-mvh
REGISTRY := docker.io

build:
docker build --pull -t $(IMAGE):$(TAG) .

run:
docker run --rm -it --name $(TAG)-run $(IMAGE):$(TAG)

shell:
docker run --rm -it --name $(TAG)-shell $(IMAGE):$(TAG) bash

push:
docker tag $(IMAGE):$(TAG) $(REGISTRY)/$(IMAGE):$(TAG)
docker push $(REGISTRY)/$(IMAGE):$(TAG)
38 changes: 38 additions & 0 deletions jessie/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Apache Mass Virtual Host

Apache Mass Virtual Host for PHP and static HTML websites.

## Features

- Uses [Debian](https://hub.docker.com/_/debian/) base image
- Thin Container. Optionally uses linked [MariaDB](https://hub.docker.com/_/mariadb/) and [SMTP](https://hub.docker.com/r/panubo/postfix/) containers for those services.
- Mod PHP5 enabled
- Both "www" and "naked" domains are served from files found at `/srv/www/sitename`
- Mass virtual host. No additional configuration required to add additional domains. Just create the "sitename"
directory and the contents will be automatically served for the "sitename" domain.

## Environment variables

SMTP Setting:

- `SMTP_PORT`
- `SMTP_HOST`

or `--link` your smtp container. `msmtp` is used for mail delivery. So PHP `mail()` function works without configuration changes.

Proxy helper:

- `BEHIND_PROXY` - Default: False. Set to true to preload [`ProxyHelper_prepend.php`](https://github.com/panubo/php-extras/blob/master/SSLHelper_prepend.php) which will register
the remote IP and SSL status (when using compatible X- proxy headers).

Apache MPM Tuning:

- `MPM_START` - Optional: Default '5'
- `MPM_MINSPARE` - Optional: Default '5'
- `MPM_MAXSPARE` - Optional: Default '10'
- `MPM_MAXWORKERS` - Optional: Default '150'
- `MPM_MAXCONNECTIONS` - Optional: Default '0'

## Status

Production ready.
68 changes: 68 additions & 0 deletions jessie/apache2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# from https://github.com/docker-library/php/blob/master/5.6/apache/apache2.conf

Mutex file:/var/lock/apache2 default
PidFile /var/run/apache2/apache2.pid
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User www-data
Group www-data
HostnameLookups Off
ErrorLog /proc/self/fd/2
LogLevel warn
ServerTokens Prod

IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# ports.conf
Listen 80
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>

<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>

<Directory /var/www/>
AllowOverride All
Require all granted
</Directory>

DocumentRoot /var/www/html

AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

CustomLog /proc/self/fd/1 combined

<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
SSLEngine on
SSLCertificateFile ${SSL_CRT}
SSLCertificateKeyFile ${SSL_KEY}
SSLCertificateChainFile ${SSL_CA}
</VirtualHost>
</IfModule>

IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
26 changes: 26 additions & 0 deletions jessie/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -e

[ "$DEBUG" == 'true' ] && set -x

# Apache MPM Tuning
export MPM_START=${MPM_START:-5}
export MPM_MINSPARE=${MPM_MINSPARE:-5}
export MPM_MAXSPARE=${MPM_MAXSPARE:-10}
export MPM_MAXWORKERS=${MPM_MAXWORKERS:-150}
export MPM_MAXCONNECTIONS=${MPM_CONNECTIONS:-0}

# SMTP
export SMTP_HOST=${SMTP_PORT_25_TCP_ADDR-${SMTP_HOST:-'localhost'}}
export SMTP_PORT=${SMTP_PORT_25_TCP_PORT-${SMTP_PORT:-'25'}}
cat << EOF > /etc/msmtprc
account default
auto_from on
# The SMTP smarthost.
host ${SMTP_HOST}
port ${SMTP_PORT}
EOF

exec $@
7 changes: 7 additions & 0 deletions jessie/mpm_prefork.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<IfModule mpm_prefork_module>
StartServers ${MPM_START}
MinSpareServers ${MPM_MINSPARE}
MaxSpareServers ${MPM_MAXSPARE}
MaxRequestWorkers ${MPM_MAXWORKERS}
MaxConnectionsPerChild ${MPM_MAXCONNECTIONS}
</IfModule>
22 changes: 22 additions & 0 deletions jessie/mvhost.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# http://httpd.apache.org/docs/2.4/mod/core.html#usecanonicalname
# http://httpd.apache.org/docs/2.4/mod/mod_vhost_alias.html
UseCanonicalName Off

<Directory /srv/www/>
AllowOverride All
Require all granted
<If "-T env('BEHIND_PROXY')">
php_value auto_prepend_file "ProxyHelper_prepend.php"
</If>
</Directory>

# Send www and non www to same directory.
<VirtualHost *:80>
ServerAlias www.*
VirtualDocumentRoot /srv/www/%2+
</VirtualHost>

<VirtualHost *:80>
ServerAlias *
VirtualDocumentRoot /srv/www/%1+
</VirtualHost>
22 changes: 22 additions & 0 deletions jessie/vhost.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# http://httpd.apache.org/docs/2.4/mod/core.html#usecanonicalname
# http://httpd.apache.org/docs/2.4/mod/mod_vhost_alias.html
UseCanonicalName Off

<Directory /srv/www/>
AllowOverride All
Require all granted
<If "-T env('BEHIND_PROXY')">
php_value auto_prepend_file "ProxyHelper_prepend.php"
</If>
</Directory>

# Send www and non www to same directory.
<VirtualHost *:80>
ServerAlias www.*
VirtualDocumentRoot /srv/www/%2+
</VirtualHost>

<VirtualHost *:80>
ServerAlias *
VirtualDocumentRoot /srv/www/%1+
</VirtualHost>

0 comments on commit 49271e9

Please sign in to comment.