Wordpress wp-config.php doesn't update in Dockers?

前端 未结 3 1656
我寻月下人不归
我寻月下人不归 2021-02-15 14:50

I am using Wordpress and docker container. The problem is that I updated the wp-config.php file but everything looks the same. I have something like this:

CONTA         


        
相关标签:
3条回答
  • 2021-02-15 15:15

    The trick:

    wp:
      image: wordpress:latest
      ports:
        - 80:80
      volumes:
        - ./wp-content:/var/www/html/wp-content
        - ./wp-config.php:/usr/src/wordpress/wp-config-sample.php
    

    When local wp-config.php changes you should delete /var/www/html/wp-config.php from container, docker will copy it again... but it works!

    0 讨论(0)
  • You can make use of the WORDPRESS_CONFIG_EXTRA environment variable to define any other config values in the wp-config.php file.

    As an example:

    WORDPRESS_CONFIG_EXTRA: |
      define('WP_ALLOW_MULTISITE', true );
      define('MULTISITE', true);
      define('SUBDOMAIN_INSTALL', false);
    
    0 讨论(0)
  • 2021-02-15 15:28

    The official WordPress docker image will automatically configure wp-config.php using the environment variables you set [documentation].

    If there are any variables such as WORDPRESS_DB_HOST, WORDPRESS_DB_PASSWORD, etc., they will be used to build a wp-config.php file upon container creation.

    If you want to provide a custom wp-config.php file, you need to make sure there are no related environment variables, and create a volume mapping for your modified file, like so:

    version: '2'
    ...
    volumes:
      - ./wp-content:/var/www/html/wp-content 
      - ./wp-config.php:/var/www/html/wp-config.php
    ...
    

    On docker-compose up, Docker will load your custom wp-config.php into the container and then run the WordPress image's docker-entrypoint.sh which updates the file with the values set in your environment variables.

    0 讨论(0)
提交回复
热议问题