• Resolved newodrawde

    (@newodrawde)


    Hello, I am using this plugin in a WordPress app running on AWS Elastic Beanstalk. I have a Elasticache Memcached cluster setup and would like to reference an environment variable instead of hardcoding the server address in master.php. Here is what my master.php file looks like. this file appears to be ignored and a default master.php is created.

    <?php
    if (!defined('W3TC_DIR')) {
    exit;
    }

    // Set the Memcached server dynamically with a fallback
    $memcached_server = isset($_SERVER['MEMCACHED_ENDPOINT']) ? $_SERVER['MEMCACHED_ENDPOINT'] : '127.0.0.1:11211';

    return array(
    "version" => "2.8.2",
    "cluster.messagebus.debug" => false,
    "cluster.messagebus.enabled" => false,
    "cluster.messagebus.sns.region" => "",
    "cluster.messagebus.sns.api_key" => "",
    "cluster.messagebus.sns.api_secret" => "",
    "cluster.messagebus.sns.topic_arn" => "",
    "dbcache.configuration_overloaded" => false,
    "dbcache.debug" => false,
    "dbcache.debug_purge" => false,
    "dbcache.enabled" => true,
    "dbcache.engine" => "memcached",
    "dbcache.file.gc" => 3600,
    "dbcache.file.locking" => false,
    "dbcache.lifetime" => 180,
    "dbcache.memcached.persistent" => true,
    "dbcache.memcached.aws_autodiscovery" => false,
    "dbcache.memcached.servers" => array($memcached_server),
    "dbcache.memcached.username" => "",
    "dbcache.memcached.password" => "",
    "dbcache.memcached.binary_protocol" => true,
    "dbcache.redis.persistent" => true,
    "dbcache.redis.servers" => array(
    "127.0.0.1:6379"
    ),
    // ... remainder of settings
    • This topic was modified 1 year, 4 months ago by newodrawde.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @newodrawde

    Thank you for reaching out and I am happy to help!
    Let me check this with the team and I’ll get back to you about this question.
    The master.php is a configuration file that is created once the W3TC is active and stores the configuration of the plugin there.

    Are you trying to manually modify the master.php?

    Thanks!

    Thread Starter newodrawde

    (@newodrawde)

    Hi @vmarko
    Appreciate your reply.

    First let me say that the plugin works great.

    I am developing locally with no need for caching in my local environment. However, as I am deploying the app to AWS Elastic Beanstalk, all local files are packaged and pushed during deployment. At the moment, I’ve exported the W3TC config(master.php) from the remote staging environment after configuring it as needed. I replaced the local version of master.php with that file so that when deployed the plugin picks up the settings. Not ideal, but this works fine except for the fact it leaves the Elasticache Memcached cluster address exposed in my GIT repo.

    Looking for an alternative to reconfiguring the plugin after each deployment by dynamically setting/replacing config values with environment values.

    Thanks for you time

    • This reply was modified 1 year, 4 months ago by newodrawde.
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @newodrawde

    Thank you for your feedback and I am glad you found a working solution.

    I’ll have to check this more because as you understand, this is not specificaly related to the W3TC, but the setup you are running which is not common.

    I’ll get back to you with more information

    Thanks!

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @newodrawde

    Currenlty the only way to do this is your way.
    I’ve share this with the team and We’ll try to see if this is something we can work on

    Thanks!

    ckeeney

    (@ckeeney)

    I opened a Github issue for this request.

    https://github.com/BoldGrid/w3-total-cache/issues/1098

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Using environment variables in master.php config file’ is closed to new replies.