WordCamp 2018
My talk at the WordCamp conference was about practical experiences from deploying WordPress to Azure and tips/tricks for better operations.
February 23, 2018
Slides
Slides can be downloaded from my OneDrive.
Links
- https://devlog.deedx.cz/windows-mobile-6-5/
- https://blogs.msdn.microsoft.com/vyvojari/
- https://www.visualstudio.com/dev-essentials/
- https://azure.microsoft.com/en-us/free/
Demos
Fast start:
- WordPress deployment template in Azure Marketplace.
- Automatically creates hosted MySQL database.
- Allows changing the PHP version and other hosting properties quickly.
Docker for development:
- Docker for Windows in Azure virtual machine with Windows Server 2016.
- docker-compose.yml -> deploy mysql & wordpress:latest container.
- Changes happen in the html folder and immediately show up on the site.
Git deployment:
-
New Azure Web App with new Staging Deployment Slot.
-
Deployment set to come from Local Git Repository.
-
WordPress added to Git
- git init
- git remote add azure https://.... (Git deployment URL for the staging slot).
- git add .
- git commit -m "Initial commmit"
- git push --set-upstream azure master
-
Doesn't connect to database yet.
-
Modified wp-config.php for Azure:
// ** MySQL settings - You can get this info from your web host ** // foreach ($_SERVER as $key => $value) { if (strpos($key, "MYSQLCONNSTR_") !== 0) { continue; } $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); } /** The name of the database for WordPress */ define('DB_NAME', $connectstr_dbname); /** MySQL database username */ define('DB_USER', $connectstr_dbusername); /** MySQL database password */ define('DB_PASSWORD', $connectstr_dbpassword); /** MySQL hostname */ define('DB_HOST', $connectstr_dbhost); /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', '');
-
Added custom deployment script:
-
.deployment
file:[config] command = deploy.cmd
-
deploy.cmd
file (added) - how to get the whole file is described in the docs:...
echo Moving configs... move /Y %DEPLOYMENT_TARGET%\wp-config.php %DEPLOYMENT_TARGET%\wp-config.php.local move /Y %DEPLOYMENT_TARGET%\wp-config-azure.php %DEPLOYMENT_TARGET%\wp-config.php
...
-
-
git add . -> git commit -m "Deployment" -> git push
-
Added connection string to slot's Application Settings.
-
Finally, swapped to production.
Operations tips
- Use "Always On".
- Don't use "MySQL in App" for production.
- Use "Microsoft Azure Storage for WordPress" plugin and save uploads to Storage.
- Understand scaling - manual/auto, up/out.
- Use WP Super Cache plugin.
- Think about Local Cache, but understand how it works.
- Use CDN, if needed.
- Stack multiple sites to one App Service plan, as long as performance allows.
- Use App Service Backup.
- Try SendGrid for e-mail: https://docs.microsoft.com/en-us/azure/store-sendgrid-php-how-to-send-email
Feedback
Found something inaccurate or plain wrong? Was this content helpful to you? Let me know!
š§ codez@deedx.cz