Is there an equivalent to config transforms that work with PHP / WordPress on Microsoft Azure?

I experimented with using WebMatrix and a web platform installer to deploy simple WordPress sites. This is very impressive - the experience with ready-made articles is really good and publishing directly from WebMatrix works well.

I'm now looking at deploying Azure from GitHub instead of relying on WebMatrix. The deployment hook works fine, but some configuration changes are applied when publishing the WebMatrix publishing pipeline that doesn't seem to replicate when published from GitHub - specifically the database connection details for connecting to the MySQL database that hosts the WordPress site. There wp-config.php

are four parameters in the file that I need to change during deployment, so the live site points to the MySQL instance hosted in ClearDB, not my local development db.

In .NET, I just used a config transform for this; is there anything comparable to make changes to wp-config.php

as part of the Azure deployment process?

+3


source to share


1 answer


Yes, we can do it. Checking the request url and setting the DB configurations in the wp-config.

I am just looking at strpos , but you can use any string operations .



if(strpos($_SERVER['HTTP_HOST'],'google.com')>=0){
    define('DB_NAME', 'DATABASENAME');

    /** MySQL database username */
    define('DB_USER', 'DATABASENAME');

    /** MySQL database password */
    define('DB_PASSWORD', 'PASSCODE');

    /** MySQL hostname */
    define('DB_HOST', 'localhost');

    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8mb4');

    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
}
else
{
    //Your other configuration, May be local
}

      

+1


source







All Articles