LiveZilla Azure App Service
This guide will walk you through the basics of setting up LiveZilla to run on PaaS service such as Azure App Service. In my case I had to migrate an existing LiveZilla instance running on a VM and run it on Azure App Service. This guide does require you to jump into the LiveZilla config files and update a few things. The LiveZilla version I was using was 5.4.0.2. I'm not going to go into every detail of Azure / App Service you should already have some experience on this front for you to be successful setting this up.
- Step One Create An Instance Of Azure App Service. https://azure.microsoft.com/en-us/services/app-service/
- Go to your physical VM and download all the LiveZilla web source code. FTP this content into the Azure App Service instance (AAS), once connected to the AAS, upload the LiveZilla web source code php into /site/wwwroot
- Once that is complete you should be able to go to the URL for your AAS instance yourazureappservice.azurewebsites.net
- Notice how LiveZilla will throw an error complaining about not being able to connect to the DB. This is the tricky part.
- Azure App Service supports MySQL In App DB hosting (in preview at this time). https://azure.microsoft.com/en-us/blog/mysql-in-app-preview-app-service/
- To manage the DB you must use PHPMyAdmin they way you hit PHPMyAdmin is as follows https://yourazureappservice.scm.azurewebsites.net/phpmyadmin/
- MAKE SURE You Disable Slow Query Log and General Log otherwise you will max out your disk space QUOTA, this might be a an issue only because the feature is still in preview I'm not sure. See below.
LiveZilla Database Import
- Log into your physical VM MySQL Database you will have to export 3-4 tables at a time and import them into PHPMyAdmin, the reason for this is currently Azure PHPMyAdmin has a max upload size of 8MB you cannot change this by modifying maxupload size in configs. I would recommend not zipping them as this also seems to crash PHPMyAdmin, its a little brittle Its a static setting from Azure at the writing of this article.
- Once you have each table imported into your new LiveZilla DB in PHPMyAdmin you will now modify the connection strings.These are all Base64 encoded. https://www.base64decode.org/ This will help you view / edit the values.
- All in all once the DB is in App Service its very fast, and a huge improvement over ClearDB (which by the way runs like a complete turd)
Parse Azure MySQL Environmental Variable
App Service Instance | Edit File: site/wwwroot/_config/config.inc.php add this below line 39.
//Loop Through And Pull Settings From Azure ENV Variable
foreach ($_SERVER as $key => $value) {
if (strpos($key, "MYSQLCONNSTR_localdb") !== 0) {
continue;
}
//Set Base 64 Version
$_CONFIG[0]["gl_db_host"] = base64_encode(preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $value));
$_CONFIG[0]["gl_db_name"] = base64_encode("livezilla");
$_CONFIG[0]["gl_db_user"] = base64_encode(preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $value));
$_CONFIG[0]["gl_db_pass"] = base64_encode(preg_replace("/^.*Password=(.+?)$/", "\\1", $value));
$connectstr_dbhost = preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $value);
$connectstr_dbname = preg_replace("/^.*Database=(.+?);.*$/", "\\1", $value);
$connectstr_dbusername = preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $value);
$connectstr_dbpassword = preg_replace("/^.*Password=(.+?)$/", "\\1", $value);
}
Issues
If you run into DB connection issues search through all the LiveZilla code and look for other places the connection string is used, replace the value with the above parsed out values, make sure you Base64 encode everything.