Run Nginx, phpMyAdmin and phpRedisAdmin (php-fpm) - Alpine via docker-compose Tested at AWS EC2 and RDS - Amazon Linux 2
Docker Reference: https://github.com/phpmyadmin/docker
Docker Reference: https://github.com/erikdubbelboer/phpRedisAdmin
3 Docker containers: phpMyAdmin and phpRedisAdmin will share the same nginx container.
phpMyAdmin <-> Nginx <-> phpRedisAdmin
phpMyAdmin and phpRedisAdmin containers are separated. They are using different network interfaces to talk to nginx. All 3 containers are using the shared html document root, /var/www/html/. phpMyAdmin is under /var/www/html/phpMyAdmin/, and phpRedisAdmin is under /var/www/html/phpRedisAdmin/. The php-fpm port for phpMyAdmin is changed to 9001 while phpRedisAdmin is using the default port 9000. It is not necessary to use different ports for 2 isolated php-fpm containers. Reference: docker-library/php#479
This solution is to run 2 isolate php-fpm containers in different directories, and there is another solution for running isolated containers in 2 different server blocks. Reference: https://dev.to/johnmccuk/isolating-php-with-docker-containers-4epn
NGINX_VERSION
- Nginx (alpine) docker image tag, e.g.,mainline-alpine
NGINX_PORT
- Default port 80DOCKER_NGINX_PORT
- Default port 8080PHP_FPM_VERSION
- PHP-FPM docker image tag, e.g.,7.3-fpm-alpine
HTML_VOLUME
- Full path of the html root for nginx. Default value is/var/www/html
PMA_HOSTS
- Define comma separated list of address/host names of the MySQL serversPMA_ABSOLUTE_URI
- Define user-facing URI. Our docker-entrypoint.sh will automatically create the phpMyAdmin directory under /var/www/html/. Please change that accordingly if you want to use other path.
Example:
NGINX_VERSION=mainline-alpine
NGINX_PORT=80
DOCKER_NGINX_PORT=8080
PHP_FPM_VERSION=7.3-fpm-alpine
HTML_VOLUME=/var/www/html
PMA_HOSTS=YOUR_DB_HOSTNAME(S)
PMA_ABSOLUTE_URI=YOUR_HOSTNAME/phpMyAdmin
The new user and group will be running the nginx and php-fpm instances. UID and GID for app:app
are 3000.
Example at EC2 - Amazon Linux 2
sudo groupadd -g 3000 app
sudo useradd -s /sbin/nologin -g 3000 -u 3000 app
nginx/nginx.conf
# php-fpm configuration for phpMyAdmin
phpmyadmin/php-fpm.conf
phpmyadmin/php.ini
phpmyadmin/www.conf
# php-fpm configuration for phpRedisAdmin
phpredisadmin/php-fpm.conf
phpredisadmin/php.ini
phpredisadmin/www.conf
touch phpredisadmin/config.inc.php
Sample file can be obtained from https://github.com/erikdubbelboer/phpRedisAdmin/blob/master/includes/config.sample.inc.php
chmod +x phpmyadmin/docker-entrypoint.sh
chmod +x phpredisadmin/docker-entrypoint.sh
Reference: composer/docker#7
Our phpmyadmin/docker-entrypoint.sh and phpredisadmin/docker-entrypoint.sh will automatically create phpMyAdmin and phpRedisAdmin directories under /var/www/html/. It may cause unexpected issue if phpMyAdmin or phpRedisAdmin exists.
docker-compose up -d
docker-compose down
docker-compose up --build -d
http://YOUR_HOSTNAME/phpMyAdmin
http://YOUR_HOSTNAME/phpRedisAdmin