Skip to content
Advertisement

How to enable output_buffering on wordpress official image

I’m taking my first steps with Docker, specifically with wordpress official image, which is just amazing to use.

However, after installing (via docker-compose as below) and checking phpinfo() it appears that output_buffering = 0. I spent the weekend trying to find the best way to expose, or bind to php.ini to set it to on without success. Could I ask for your guidance on the best way to achieve this, please?

Thanks

version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html
      - ./wp-content:/var/www/html/wp-content

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:

Advertisement

Answer

There are several ways to achieve your goal (see below) but here is a straightforward example

Inside your docker-compose project, create an ob.ini file containing:

output_buffering=1

Modify your wordpress service volumes as follow:

    volumes:
      - wordpress:/var/www/html
      - ./wp-content:/var/www/html/wp-content
      - ./ob.ini:/usr/local/etc/php/conf.d/ob.ini

You can achieve the same goal by extending the WordPress image and copying that file inside the given dir, or create it during build, or append the directive to an other existing ini file there…

Since wordpress image is based on the php image read more info there on how to customize it to your liking.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement