简体   繁体   中英

Change to pm = static on php-fpm docker image

I'm trying to change this value in fpm configuration of PHP.

Here, you can see my simple docker-compose file:

version: '3.6'
services:

  wordpress:
    image: wordpress:${WORDPRESS_VERSION:-php7.3-fpm}
    container_name: ${WORDPRESS_CONTAINER:-wordpress}
    volumes:
      - ./php/pool.d:/usr/local/etc/php-fpm.d
    environment:
      - WORDPRESS_DB_NAME=${WORDPRESS_DB_NAME:-wordpress}
      - WORDPRESS_TABLE_PREFIX=${WORDPRESS_TABLE_PREFIX:-wp_}
      - WORDPRESS_DB_HOST=${WORDPRESS_DB_HOST:-mysql}
      - WORDPRESS_DB_USER=${WORDPRESS_DB_USER:-root}
      - WORDPRESS_DB_PASSWORD=${WORDPRESS_DB_PASSWORD:-password}
    depends_on:
      - mysql
    restart: always
...

Inside ./php/pool.d/my-www.conf I have only:

pm = static
pm.max_children = 10

And I get the error:

ERROR: [/usr/local/etc/php-fpm.d/my-www.conf:2] unknown entry 'pm'

If I include the www pool namespace:

[www]
pm = static
pm.max_children = 10

And I get the error:

ALERT: [pool www] user has not been defined

Any ideas?

actually, when you mount a directory to the inside of the docker-image (like something you did ./php/pool.d:/usr/local/etc/php-fpm.d)

version: '3.6'
services:

  wordpress:
    ...
    volumes:
      - ./php/pool.d:/usr/local/etc/php-fpm.d
    ...

you replaced it. thus, you have no configuration of the pool except a little part of it that is something like this

pm = static
pm.max_children = 10

therefore, you get the errors. to solve this trouble I can propose two ways:

  • you can pass a complete pool configuration file to the inside of the docker-image and change anything you want in the new config file then change the docker-compose file from this
version: '3.6'
services:

  wordpress:
    ...
    volumes:
      - ./php/pool.d:/usr/local/etc/php-fpm.d
    ...

to this

version: '3.6'
services:

  wordpress:
    ...
    volumes:
      - ./php/pool.d/www.conf:/usr/local/etc/php-fpm.d/www.conf
    ...
  • you can overwrite a part of the pool configuration by passing your new config value as a second config file to the pool directory to the inside of the docker-image. but, you must care about the file name. for example, usually, the default pool configuration file's name is www.conf so, to overwrite its configs, you must create a file with name www2.conf to load after the www.conf file (for more information see this issue: https://serverfault.com/a/806530/529531 ). also, your docker-compose file will be something like this
version: '3.6'
services:

  wordpress:
    ...
    volumes:
      - ./php/pool.d/www2.conf:/usr/local/etc/php-fpm.d/www2.conf
    ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM