A comprehensive docker image to run Apache PHP applications like Wordpress, Laravel, etc
100K+
DIY AWS Lambda for PHP applications!
Docker image containing Ubuntu 20.04 LTS core with Apache 2.4 and PHP 7.4. This image is designed to be used in AWS environments for high density PHP application hosting. WordPress 5.x and Drupal 7.x are tested to work.
/srv./srv/example.com/www as the Apache DocumentRoot to serve php applications.example-com is created with all the EC2 instances of the swarm and specific TCP port (eg tcp:8001) and attached to ALB.example-com Target Group.awslogs log driver./srv -- base dir to be published via AWS EFS to all nodes, subdirectories /srv/example.com, /srv/example.net, etc to be created for each website/domain./srv/example.com/www -- root folder for php applications (WordPress root, Drupal root, etc), mounted within docker containers as Apache DocumentRoot/srv/example.com/etc/apache and /srv/example.com/etc/php -- optional apache/php config/srv/example.com/mysqlbackup -- used for storing MySQL dumps$WP_ROOT/wp-content/cache. EFS is slow, so it's recommended to move the cache folder inside the docker container. Delete the cache folder and run ln -s /srv/example.com/www/wp-content/cache /tmp. Cache folder will be hosted within docker instance and run faster.www-data. Inside the docker instance, none of the processes are run as root. setcap is used to permit non-root apache process to bind to TCP port 80./svr/example.com/etc and then bind mount it inside the container. Eg. docker run -v /srv/example.com/etc/php:/etc/php:ro -v /srv/example.com/etc/apache:/etc/apache:ro ...cd /srv/example.com/www && wp-cli plugin update --all.To build:
docker build --no-cache -t rsubr/php-apache-ubuntu:bionic .
Run with internal document root to reveal Apache/PHP config. See http://localhost/index.php and http://localhost/.config/
docker run --name=test -p 80:80 rsubr/php-apache-ubuntu:bionic
Run a WordPress site from /srv/example.com/www
docker run --name=example-com -v /srv/example.com/www:/var/www/html -p 80:80 rsubr/php-apache-ubuntu:bionic
Run a WordPress site from /srv/example.com/www, but this time use custom apache and php config from /srv/example.com/etc/{apache,php}
docker run --name=example-com -v /srv/example.com/www:/var/www/html -v /srv/example.com/etc/apache2:/etc/apache2:ro -v /srv/example.com/etc/php:/etc/php:ro -p 80:80 rsubr/php-apache-ubuntu:bionic
Run 2 replicas of the container as a docker service. This command must be run from a docker swarm manager node. AWS ALB and Target Group must be created to route traffic for example.com to this container:
docker service create --replicas 2 --name example-com --publish published=8000,target=80,mode=host --mount type=bind,source=/srv/example.com/www,destination=/var/www/html rsubr/php-apache-ubuntu:bionic
Content type
Image
Digest
sha256:b8f4ae9c6…
Size
97.7 MB
Last updated
7 months ago
docker pull rsubr/php-apache-ubuntu