Giter VIP home page Giter VIP logo

docker-php-fpm's Introduction

Docker PHP-FPM

Homemade PHP-FPM Docker image with additional extensions based on official PHP images.

This image is mainly used for development environments but the default configurations are production-ready to handle small to medium-sized PHP sites.

Available Tags

  • 8 (default), 8.1, 8.0, 7.4
  • local, dockerhub, <branch>, edge, sha-<hash>, latest (default to 8)

Built-in Extensions

This image is bundled with additional extensions that should work with most modern PHP applications. Tested with WordPress, MediaWiki and Flarum.

  • apcu
  • bcmath
  • exif
  • gd (with freetype, jpeg, and webp)
  • igbinary
  • imagick
  • intl
  • msgpack
  • opcache
  • pdo_mysql
  • pdo_pgsql
  • redis
  • zip

You can view full built-in extensions:

docker run --rm -it --name tmp-php-fpm sparanoid/php-fpm:latest php -m

Key Files and Directories

  • /app - Default PHP working directory (WORKDIR)
  • /usr/local/etc/php-fpm.conf - Global FPM settings
  • /usr/local/etc/php/conf.d/ - Custom PHP configurations
  • /usr/local/etc/php-fpm.d/ - PHP-FPM configurations
    • /usr/local/etc/php-fpm.d/www.conf - Default www pool settings

You can eject and inspect these configs by using the following commands:

docker run --name tmp-php -d sparanoid/php-fpm:latest
docker cp tmp-php:/usr/local/etc/ $(pwd)/ejected-php-fpm
docker rm -f tmp-php

Extra Packages

  • ImageMagick
  • zip
  • unzip

Examples

Using this image with ejected WordPress, Nginx, MariaDB, Redis and Adminer.

Edit docker-compose.yml:

version: '3'

services:
  nginx:
    image: nginx:alpine
    restart: always
    ports:
      - 80:80
      # Enable 443 on production
      # - 443:443
    depends_on:
      - php
    volumes:
      - ./data/nginx:/app
      - ./config/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf:ro

  php:
    image: sparanoid/php-fpm:8-latest
    restart: always
    depends_on:
      - redis
      - mariadb
    volumes:
      - ./data/nginx:/app

  mariadb:
    image: mariadb
    restart: always
    volumes:
      - wordpress-db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-password}
      - MYSQL_DATABASE=wordpress

  redis:
    image: redis
    restart: always

  adminer:
    image: adminer
    restart: always
    ports:
      - 127.0.0.1:8080:8080
    depends_on:
      - php

volumes:
  wordpress-db:

Edit ./config/nginx/conf.d/default.conf:

  server {
    listen                  80;
    index                   index.html index.htm index.php;

    root                    /app;

    location / {
      try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
      try_files               $uri =404;
      fastcgi_pass            php:9000;
      include                 fastcgi_params;
      fastcgi_index           index.php;
      fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
  }

In order to make Redis Object Cache plugin work with Redis container. Add the following line in ./data/nginx/wp-config.php:

define( 'WP_REDIS_HOST', 'redis' );

docker-php-fpm's People

Contributors

dependabot[bot] avatar renovate[bot] avatar sparanoid avatar

Watchers

 avatar  avatar  avatar

docker-php-fpm's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

dockerfile
Dockerfile
  • php 8-fpm
github-actions
.github/workflows/build.yml
  • actions/checkout v4
  • docker/setup-qemu-action v3
  • docker/setup-buildx-action v3
  • docker/login-action v3
  • docker/login-action v3
  • docker/metadata-action v5
  • docker/bake-action v4

  • Check this box to trigger a request for Renovate to run again on this repository

Cannot write to files

Hi thanks for this image, because I need bcmath for a project, I decided to use this image.

I have one problem though, I need to write to a file for this project, and I keep getting this error:
NOTICE: PHP message: PHP Warning: file_put_contents(file.txt): Failed to open stream: Permission denied in /var/www/html/filetest.php on line 4

/var/www/html is mapped to a local directory, like /app in the original docker-compose file here: https://hub.docker.com/r/sparanoid/php-fpm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.