search

Home  >  Q&A  >  body text

Docker - Why do changes to the php configuration file not take effect?

solve

When the configuration file is posted, the answer is obvious. The system has two PHP files.

  1. php.ini-production

  2. php.ini

I changed it to php.ini -_-!!!

- ./php-fpm/php.ini-production:/usr/local/etc/php/php.ini:ro

Tip Modify the configuration file without deleting docker, just restart docker docker-compose restart

Problem process

If the docker and php configuration files used change, use docker-compose rm and then docker-comose up. Why is there no change when looking at phpinfo()?

Project Directory

Configuration file

docker-compose.yml

# web server
nginx:
  image: nginx:latest
  ports:
    - "80:80"
    - "443:443"
  volumes:
    # app
    - ./app/src:/usr/share/nginx/html
    # nginx configs
    - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
    - ./nginx/conf.d/:/etc/nginx/conf.d/:ro
    # certificates
    #- ./nginx/ca/server.crt/:/etc/nginx/server.crt:ro
    #- ./nginx/ca/server.key/:/etc/nginx/server.key:ro
  links:
    - fpm:__DOCKER_PHP_FPM__

# php-fpm
fpm:
  build: ./php-fpm
  ports:
    - "9000"
  volumes:
    - ./app/src:/usr/share/nginx/html
    # Your php.ini
    - ./php-fpm/php.ini-production:/usr/local/etc/php/php.ini:ro
  # environment:
    # Set your APP env variables here:
    # - APP_KEY=
    # - DB_HOST=
    # - DB_DATABASE=
    # - DB_USERNAME=
    # - DB_PASSWORD=
  links:
    - mysql:mysql

# database
mysql:
  image: mysql:latest
  ports:
    # Allow client to access 3306
    - "3306:3306"
  volumes:
    # NOTE: your data will be stored in ./mysql
    - ./mysql:/var/lib/mysql
  environment:
    - MYSQL_ROOT_PASSWORD=root123
曾经蜡笔没有小新曾经蜡笔没有小新2723 days ago1686

reply all(4)I'll reply

  • PHP中文网

    PHP中文网2017-06-30 09:54:41

    The reasonable explanation is that the php.ini you modified is not the php.ini loaded by running PHP in docker.

    Check which path is loaded in php.ini.

    reply
    0
  • 三叔

    三叔2017-06-30 09:54:41

    docker rm will delete the modified configuration. You need to configure the local php.ini to map to docker in docker-compose.yml

    reply
    0
  • PHP中文网

    PHP中文网2017-06-30 09:54:41

    Docker loads php in the image package, it is useless to modify the local one

    reply
    0
  • PHP中文网

    PHP中文网2017-06-30 09:54:41

    php -i|grep php.ini to see if the loaded file is correct

    reply
    0
  • Cancelreply