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

I’ve been experimenting with using WebMatrix and Web Platform Installer to spin up simple WordPress sites. It’s quite impressive – the out-of-the-box experience is really good, and publishing directly from within WebMatrix works well.

I’m now looking at deploying to Azure from GitHub, instead of relying on WebMatrix. The deployment hook is working fine, but there’s some configuration changes getting applied by the WebMatrix publish pipeline that don’t seem to be replicated when publishing from GitHub – specifically, the database connection details for connecting to the MySQL database hosting the WordPress site. There’s four settings defined in the wp-config.php file which I need to change during deployment, so the live site points to the ClearDB-hosted MySQL instance instead of to my local development DB.

Read More

In .NET, I’d just use a config transform for this; is there anything comparable for making changes to wp-config.php as part of the Azure deployment process?

Related posts

Leave a Reply

1 comment

  1. Yes, We can make.
    By checking the Request URL and setting the DB Configurations on wp-config file.

    I’m just exampling via 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
    }