Sign inSign up

vannhatcd/php8.3-fpm-nginx

By vannhatcd

•Updated 5 months ago

Image
0

1.4K

vannhatcd/php8.3-fpm-nginx repository overview

⁠Laravel Docker Template

⁠Usage Guide

⁠Using the Prebuilt Docker Image from Docker Hub

If you want to use the prebuilt image (without building), follow these steps:

⁠1. Pull the Image
docker pull vannhatcd/php8.3-fpm-nginx:latest

Example:

docker pull vannhatcd/php8.3-fpm-nginx:latest
⁠2. Update docker-compose.yml
  • In your docker-compose.yml, use the image field instead of build:
services:
  app:
    image: vannhatcd/php8.3-fpm-nginx:latest
    ports:
      - "8080:80"
    volumes:
      - .:/var/www/html
      - ./logs/nginx:/var/log/nginx
      - ./logs/php-fpm:/var/log/php-fpm
      - ./logs/supervisor:/var/log/supervisor
      - ./cronjobs/app-cron:/etc/cron.d/app-cron
    environment:
      - APP_PORT=8080
      - APP_ENV=production
      - DB_HOST=mysql
      - REDIS_HOST=redis
      - PHP_MEMORY_LIMIT=512M
      - PHP_OPCACHE_ENABLE=1
      # ... other variables
    depends_on:
      - mysql
      - redis

  mysql:
    image: mysql:8.0
    environment:
      MYSQL_DATABASE: ecommerce
      MYSQL_ROOT_PASSWORD: secret
    ports:
      - "3306:3306"
    volumes:
      - mysql-data:/var/lib/mysql

  redis:
    image: redis:7-alpine

volumes:
  mysql-data:
⁠3. Start the Container
docker compose up -d
⁠4. Customization
  • You can still customize PHP, Nginx, PHP-FPM, and install extensions using environment variables and the phpaddmod script as described above.
  • All mapped volumes and cronjob setup work the same way.

⁠Customizing PHP, Nginx, PHP-FPM, and Extensions

⁠1. Customizing PHP via Environment Variables
  • You can set PHP configuration options by adding environment variables in docker-compose.yml with the prefix PHP_.
  • Example:
    environment:
      - PHP_MEMORY_LIMIT=512M
      - PHP_UPLOAD_MAX_FILESIZE=100M
      - PHP_POST_MAX_SIZE=100M
      - PHP_OPCACHE_ENABLE=1
      - PHP_OPCACHE_MEMORY_CONSUMPTION=512
      # ... add more as needed
    
  • These will be automatically applied to php.ini inside the container.
⁠2. Customizing Nginx and PHP-FPM
  • For Nginx, you can override settings by mounting a custom config file or using environment variables (if supported in entrypoint).
  • For PHP-FPM, use environment variables with the prefix PHP_FPM_:
    environment:
      - PHP_FPM_MAX_CHILDREN=50
      - PHP_FPM_START_SERVERS=10
      - PHP_FPM_MIN_SPARE_SERVERS=5
      - PHP_FPM_MAX_SPARE_SERVERS=20
    
  • These will be applied to www.conf inside the container.
⁠3. Adding PHP Extensions Dynamically
  • The container includes the phpaddmod script to install PHP extensions at runtime.
  • Usage:
    phpaddmod <extension_name>
    # Example:
    phpaddmod redis
    phpaddmod gd
    
  • You can run this in the container shell or add to Dockerfile/entrypoint if needed.
⁠4. Example: Adding a Custom Extension on Startup
  • In your Dockerfile or entrypoint script, add:
    phpaddmod <extension_name>
    
  • This will download and install the extension using the official installer.

⁠Map files/folders to host

  • ./logs/nginx → Nginx logs
  • ./logs/php-fpm → PHP-FPM logs
  • ./logs/supervisor → Supervisor logs
  • ./storage/logs → Laravel logs
  • ./cronjobs/app-cron → cronjob file (create on host, mount into container)

⁠Using Cron Jobs

  • Create cronjobs/app-cron file on host, e.g.:
    * * * * * cd /var/www/html && php artisan schedule:run >> /var/log/cron.log 2>&1
    
  • This file will be mounted to /etc/cron.d/app-cron in the container.

⁠Notes

  • To display the correct access port, pass the APP_PORT variable in environment.
  • To change PHP config, just add PHP_* environment variables in docker-compose.
  • To use file session when sessions table is missing, set SESSION_DRIVER=file in .env.

⁠Contact & Support

If you encounter issues, check logs in the mapped folders or contact admin/dev for support.

Tag summary

Content type

Image

Digest

sha256:8ad10270a…

Size

103.5 MB

Last updated

5 months ago

docker pull vannhatcd/php8.3-fpm-nginx