Nginx PHP-FPM Docker image for PHP Laravel or any php based application
10K+
A ready-to-use container designed for running PHP-based applications, including Laravel microservices. This Docker image combines Nginx and PHP-FPM, offering a robust foundation for your projects with built-in support for essential extensions and configurations.
This image is ideal for developers looking for a streamlined, high-performance solution to deploy PHP applications with essential tools already integrated.
This Docker image comes pre-installed with the following:
PHP Extensions:
Additional Features:
docker-compose.ymlservices:
app:
image: jkaninda/nginx-php-fpm:8.3
container_name: app
restart: unless-stopped
user: www-data # Optional for production
volumes:
# Project root
- ./src:/var/www/html
ports:
- "80:80"
networks:
- default
docker compose up -d
docker compose exec app composer create-project --prefer-dist laravel/laravel .
docker compose exec app php artisan key:generate
docker compose exec app php artisan storage:link
docker compose exec app chmod -R 777 storage bootstrap/cache
docker compose exec app php artisan migrate
docker exec -it app bash
docker-compose.yml Exampleversion: '3'
services:
app:
image: jkaninda/nginx-php-fpm
container_name: app
restart: unless-stopped
ports:
- "80:80"
volumes:
# Project root
- ./:/var/www/html
- ~/.ssh:/root/.ssh # Use private CVS if needed
# Optional custom PHP config
# - ./php.ini:/usr/local/etc/php/conf.d/php.ini
environment:
- APP_ENV=development # or production
- LARAVEL_PROCS_NUMBER=2 # Optional: Queue worker processes
# - CLIENT_MAX_BODY_SIZE=20M # Optional
# - DOMAIN=example.com # Optional
- DOCUMENT_ROOT=/var/www/html # Optional
/var/www/html
FROM jkaninda/nginx-php-fpm:8.3
# Copy Laravel project files
COPY . /var/www/html
# Storage Volume
VOLUME /var/www/html/storage
WORKDIR /var/www/html
# Fix permissions
RUN chown -R www-data:www-data /var/www/html
USER www-data
To enable custom Nginx configurations, use the following files:
/var/www/html/conf/nginx/nginx.conf/var/www/html/conf/nginx/nginx-site.confSupervisord can be used to manage tasks or processes within the container.
[program:kafkaconsume-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan kafka:consumer
autostart=true
autorestart=true
numprocs=1
user=www-data
redirect_stderr=true
stdout_logfile=/var/www/html/storage/logs/kafka.log
If you encounter storage permission issues, run the following commands:
docker compose exec php-fpm /bin/bash
Then inside the container:
chown -R www-data:www-data /var/www/html/
chmod -R 775 /var/www/html/storage
Are you building a microservices architecture? Do you need a powerful yet lightweight API Gateway or a high-performance reverse proxy to secure and manage your services effortlessly?
Check out my other project — Goma Gateway.
Goma Gateway is a high-performance, declarative API Gateway built for modern microservices. It comes with a rich set of built-in middleware, including:
Protocol support: REST, GraphQL, gRPC, TCP, and UDP
Security: Automatic HTTPS via Let’s Encrypt or use your own TLS certificates
Whether you're managing internal APIs or exposing public endpoints, Goma Gateway helps you do it efficiently, securely, and with minimal complexity.
If this project helped you, do not skip on giving it a star. Thanks!
Content type
Image
Digest
sha256:ab54d40b6…
Size
333.3 MB
Last updated
about 1 year ago
docker pull jkaninda/nginx-php-fpm