This project utilizes Docker Compose to manage a production-ready environment with Nginx, PHP-FPM 7.1, and PHP-FPM 7.4 containers for different applications. The setup includes a convenient Makefile for managing the Docker Compose services.
- Prerequisites
- Getting Started
- Docker Installation
- Makefile Commands
- Nginx Configuration
- Security Considerations
- Customization
Make sure you have Docker and Docker Compose installed on your system. If Docker is not found, the Makefile will attempt to use Podman as a fallback.
-
Clone this repository:
git clone https://github.com/globalgatedc/docker-compose-nginx-php-fpm.git cd docker-compose-nginx-php-fpm
-
Make any changes as needed on
config/nginx/nginx.conf
file with a production-ready Nginx configuration. Ensure the configuration includes proper hardening, request limits, SSL settings, etc. (you can use the provided example as a starting point). -
Make any changes as needed on
docker/php-fpm-7.1/Dockerfile
anddocker/php-fpm-7.4/Dockerfile
for PHP-FPM 7.1 and PHP-FPM 7.4 respectively (you can use your own PHP configurations). -
Adjust the volumes in the
docker-compose.yml
file to point to your application directories and configuration files. -
Run the following commands:
# Start the Docker Compose services make up # View logs from the Docker Compose services make logs
The Docker installation instructions can vary based on your operating system. Please refer to the official Docker documentation for detailed installation instructions:
make up
: Starts the Docker Compose services in the background.make down
: Stops and removes the Docker Compose services.make ps
: Lists the status of Docker Compose services.make exec-nginx
: Opens a Bash shell in the Nginx container.make exec-php-7.1
: Opens a Bash shell in the PHP-FPM 7.1 container.make exec-php-7.4
: Opens a Bash shell in the PHP-FPM 7.4 container.make exec-composer
: Opens a Bash shell in the default dir, or accepts a path argument to open a Bash shell or run a command in a specific directory. example:make exec-composer dir=/var/www/app1 cmd="composer install"
make logs
: Views logs from the Docker Compose services.make clean
: Stops and removes the Docker Compose services along with volumes.
Ensure that your config/nginx/nginx.conf
includes proper hardening, request limits, SSL settings, and follows best practices for a production environment. Make adjustments based on your specific security requirements.
Make sure to secure your Nginx configurations, PHP configurations, and application code before deploying in production.
This setup is a starting point; customize the Nginx, PHP, and other configurations according to your production requirements. Review and adjust configurations based on your specific security and performance requirements.
Feel free to customize and expand upon these instructions based on the specifics of your project and deployment requirements.