Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Virtual Hosts #249

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ MIT License

Copyright (c) 2017 Narendra Vaghela
Copyright (c) 2019 Malte Graebner aka (MrOffline77)
Copyright (c) 2024 Nishant Vaity aka (enishant)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 3 additions & 0 deletions bin/php54/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-di
RUN pecl install xdebug-2.4.0RC4 && docker-php-ext-enable xdebug \
&& echo "xdebug.remote_enable=1" >> /usr/local/etc/php/php.ini

# Insure VHOSTS directory exists
RUN mkdir -p /var/www/vhosts

# Insure an SSL directory exists
RUN mkdir -p /etc/apache2/ssl

Expand Down
3 changes: 3 additions & 0 deletions bin/php56/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ RUN docker-php-ext-install curl \
&& pecl install xdebug-2.5.5 && docker-php-ext-enable xdebug \
&& echo "xdebug.remote_enable=1" >> /usr/local/etc/php/php.ini

# Insure VHOSTS directory exists
RUN mkdir -p /var/www/vhosts

# Insure an SSL directory exists
RUN mkdir -p /etc/apache2/ssl

Expand Down
3 changes: 3 additions & 0 deletions bin/php71/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install -j$(nproc) gd

# Insure VHOSTS directory exists
RUN mkdir -p /var/www/vhosts

# Insure an SSL directory exists
RUN mkdir -p /etc/apache2/ssl

Expand Down
3 changes: 3 additions & 0 deletions bin/php72/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install -j$(nproc) gd

# Insure VHOSTS directory exists
RUN mkdir -p /var/www/vhosts

# Insure an SSL directory exists
RUN mkdir -p /etc/apache2/ssl

Expand Down
3 changes: 3 additions & 0 deletions bin/php73/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ RUN apt-get -y update && \
# Insure an SSL directory exists
RUN mkdir -p /etc/apache2/ssl

# Insure VHOSTS directory exists
RUN mkdir -p /var/www/vhosts

# Enable SSL support
RUN a2enmod ssl && a2enmod rewrite

Expand Down
3 changes: 3 additions & 0 deletions bin/php74/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ libpng-dev && \
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && \
docker-php-ext-install gd

# Insure VHOSTS directory exists
RUN mkdir -p /var/www/vhosts

# Insure an SSL directory exists
RUN mkdir -p /etc/apache2/ssl

Expand Down
3 changes: 3 additions & 0 deletions bin/php8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ libpng-dev && \
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && \
docker-php-ext-install gd

# Insure VHOSTS directory exists
RUN mkdir -p /var/www/vhosts

# Insure an SSL directory exists
RUN mkdir -p /etc/apache2/ssl

Expand Down
3 changes: 3 additions & 0 deletions bin/php81/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ libpng-dev && \
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && \
docker-php-ext-install gd

# Insure VHOSTS directory exists
RUN mkdir -p /var/www/vhosts

# Insure an SSL directory exists
RUN mkdir -p /etc/apache2/ssl

Expand Down
3 changes: 3 additions & 0 deletions bin/php82/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ libpng-dev && \
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && \
docker-php-ext-install gd

# Insure VHOSTS directory exists
RUN mkdir -p /var/www/vhosts

# Insure an SSL directory exists
RUN mkdir -p /etc/apache2/ssl

Expand Down
23 changes: 23 additions & 0 deletions config/vhosts/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@
</Directory>
</VirtualHost>

<VirtualHost example.com:80>
ServerAdmin [email protected]
DocumentRoot ${APACHE_VHOSTS_DOCUMENT_ROOT}/example.com
ServerName example.com
ServerAlias www.example.com
<Directory ${APACHE_VHOSTS_DOCUMENT_ROOT}/example.com>
AllowOverride all
</Directory>
</VirtualHost>

<VirtualHost secure.example.com:443>
ServerAdmin [email protected]
DocumentRoot ${APACHE_VHOSTS_DOCUMENT_ROOT}/secure.example.com
ServerName secure.example.com
<Directory ${APACHE_VHOSTS_DOCUMENT_ROOT}/secure.example.com>
AllowOverride all
</Directory>

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/secure.example.com-cert.pem
SSLCertificateKeyFile /etc/apache2/ssl/secure.example.com-cert-key.pem
</VirtualHost>

# Allows HTTPS on localhost. You will need to use mkcert on your local machine
# to create the `cert.pem` and `cert-key.pem` files, and then place them in the
# `./config/ssl` directory. You could also create certificates for any local
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ services:
- database
volumes:
- ${DOCUMENT_ROOT-./www}:/var/www/html:rw
- ${VHOSTS_DOCUMENT_ROOT-./vhosts}:/var/www/vhosts:rw
- ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini
- ${SSL_DIR-./config/ssl}:/etc/apache2/ssl/
- ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled
- ${LOG_DIR-./logs/apache2}:/var/log/apache2
- ${XDEBUG_LOG_DIR-./logs/xdebug}:/var/log/xdebug
environment:
APACHE_DOCUMENT_ROOT: ${APACHE_DOCUMENT_ROOT-/var/www/html}
APACHE_VHOSTS_DOCUMENT_ROOT: ${APACHE_VHOSTS_DOCUMENT_ROOT-/var/www/vhosts}
PMA_PORT: ${HOST_MACHINE_PMA_PORT}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_USER: ${MYSQL_USER}
Expand Down
2 changes: 2 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ COMPOSE_PROJECT_NAME=lamp
# Possible values: php54, php56, php71, php72, php73, php74, php8, php81, php82
PHPVERSION=php8
DOCUMENT_ROOT=./www
VHOSTS_DOCUMENT_ROOT=./vhosts
APACHE_DOCUMENT_ROOT=/var/www/html
APACHE_VHOSTS_DOCUMENT_ROOT=/var/www/vhosts
VHOSTS_DIR=./config/vhosts
APACHE_LOG_DIR=./logs/apache2
PHP_INI=./config/php/php.ini
Expand Down
Empty file added vhosts/example.com/.gitkeep
Empty file.
Empty file.