Multiple PHP versions (with PHP-FPM) + Webserver + Database
Run PHP versions (5.3, 5.4, 5.5) with PHP-FPM as docker containers and easily switch PHP versions within your webserver.
Apache Example
<VirtualHost *>
VirtualDocumentRoot /www/%0
Use PHP-5.4 /www/%{SERVER_NAME}
</VirtualHost>
nginx @todo
+---------- /www data ------------+
| |
mount mount
| |
v v
DB (i.e. MySQL 3306) <-link-> PHP 5.3 (PHP-FPM 20053) <-link-> Webserver (i.e. Apache 80)
PHP 5.4 (PHP-FPM 20054)
PHP 5.5 (PHP-FPM 20055)
PHP containers are linked to DB containers, so PHP is able to do mysql_connect('127.0.0.1', ..).
Behind the scenes there is some magic (rinetd) which maps all requests to 127.0.0.1:3306 to the actual IP of the DB container.
127.0.0.1:21 is mapped to the actual FTP container. Of course, the Webserver is linked to the PHP containers as well.
Your www data directory is mounted to both, the PHP containers and the Webserver container, under /www.
Prerequisites: VirtualBox, boot2docker, boot2docker.iso with VirtualBox Guest Additions, fig
git clone https://github.com/mattes/php-unicorn
cd php-unicorn
boot2docker up
./build-fig.sh ./www
fig up # see fig.yml
open http://<boot2docker-ip>:8080| Service | Host | Exposed Docker Container |
|---|---|---|
| Apache | 8080 | 80 |
| MySQL | 3306 | 3306 |
| FTP | 2121 | 2121 |
| PHP 5.3 | - | 20053 |
| PHP 5.4 | - | 20054 |
| PHP 5.5 | - | 20055 |
By default "dangerftp" is started. Type any path under wwww as username,
to make this the entry path for the FTP session. Field password is ignored.
# see aboveYou can build your own docker containers. Check the ./dockerfile.sh helper.
- Apache: Learn how the
Use PHP-5.xmacros work. See php-macros.conf and start.sh. - Apache: Customize a VirtualHost with a new configuration file
IncludeOptional /www/*.a2.conf. See 001-multi-virtualhosts.conf.