Skip to content

derdaoben/docker-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Nginx + PHP-FPM

A Docker container that combines Nginx and PHP-FPM.

🚀 Features

  • Nginx + PHP-FPM
  • Alpine Linux
  • Healthcheck

📦 Quick Start

⚠️ Warning: This container is designed for use with an ingress controller like Traefik. Therefore only port 80 enabled in nginx.

Build container

docker build -t nginx-php .

Start container (simple)

docker run -d -p 80:80 --name nginx-php nginx-php

Compose

Create a docker-compose.yml:

version: '3.8'

services:
  nginx-php:
    image: ghcr.io/derdaoben/nginx:master
    volumes:
      - /myWebsite:/var/www/html:ro
    ports:
      - "80:80"

Then start:

docker-compose up -d

🔧 Configuration

Directory Structure

├── Dockerfile
├── config/
│   ├── nginx.conf          # Nginx main configuration
│   ├── default.conf        # Virtual host configuration
│   └── php.ini-production  # PHP configuration
├── entry/
│   └── docker-entrypoint.sh # Container startup script
└── README.md

Environment Variables

Variable Default Description
WEBROOT /var/www/html Document Root

PHP Extensions

Installed extensions:

  • gd - Image processing
  • gmp - Mathematical functions
  • sockets - Socket communication
  • gettext - Internationalization
  • pdo_mysql - MySQL PDO Driver
  • mysqli - MySQL Improved Extension
  • pdo_pgsql - PostgreSQL PDO Driver

📊 Monitoring

Healthcheck

Logs

# Show container logs
docker logs nginx-php

# With docker-compose
docker-compose logs -f nginx-php

🛠️ Development

Add custom PHP files

# Copy files to container
docker cp myapp.php nginx-php:/var/www/html/

# Or mount volume
docker run -v /myapp:/var/www/html -p 80:80 nginx-php

Debugging

# Enter container
docker exec -it nginx-php /bin/sh

# Test Nginx configuration
docker exec nginx-php nginx -t

# PHP-FPM status
docker exec nginx-php php-fpm -t

📚 Further Reading

📄 License

MIT License - see details in the respective software documentation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages