This guide will walk though setting up a WordPress site using an Azure VM. Some of the perks of doing this are:
- Cost-wise, you can spend as little as ~$8 a month to get a fully functional WordPress site running. If you try using MySQL and App Services in Azure, you’ll looking to spend ~$40 a month for worse specs.
- You can scale the site up as needed if performance demands arise.
Step 1: Create An Azure VM
First, create an Azure VM with the following specs:
- Image of Ubuntu 18.04 LTS
- Size of B1s (anything less and you’ll run into issues)
- Azure Backup (optional, provides a means to restore VM from scratch)
Once the VM is set, set the following Network Security Group rules:
- Public Access – ports 80/443
- Private Access (such as your IP address) – ports 22/3306
Step 2: Set up LAMP Server
SSH into the server and install a LAMP server with the following:
After installation, verify correct installation:
Step 3: Configure MySQL
Run the following:
Do the following:
- Install the Validate Password Plugin at “Medium”
- Say yes to all options except “Disallow root login remotely”
Run a query to allow access:
Edit the file /etc/mysql/mysql.conf.d/mysqld.cnf and comment out the bind-address line.
Finally, test connecting to the database server using a tool like MySQL Workbench. When connected to the database server, do the following:
- Create a DB (either copied from a migration or a fresh database)
- Create a user that has access to the DB above.
Step 4: Install WordPress
Download and unzip WordPress into /var/www/html:
Configure /etc/apache2/apache2.conf and allow AllowOverride to All in the /var/www directory.
Set the correct permissions for Apache:
As a final step, delete the index.html file from Apache:
You should now be able to run the WordPress installer and connect the database.
Once the WordPress Installer has run, log into the backend and check the site health to see if there are any misconfigurations within the system:
Setting Up SSL With Let’s Encrypt
Before setting up SSL, you’ll need to set up a domain and set the appropriate DNS settings to be able to run the Let’s Encrypt process.
Enable SSL and restart Apache:
Run the commands provided by CertBot.
The easiest way to enable mail is to use the WP Mail SMTP plugin. Once configured, you can use the plugin to set up alongside the email carrier of choice and test the submission functionality.
Increase Upload Size
To increase upload size (for things like uploading themes/plugins/media), edit the /etc/php/7.2/apache2/php.ini file:
Then restart Apache:
Restore from a Backup
If opted into backup when creating the VM, the VM will have an automatic daily backup progress that you can use to restore the VM at any point.
To restore a new VM, access the Recovery Vault and go to Backup Items -> Your VM Name -> Restore VM. Once you go this, you have two options:
- Completely create a new VM with the data restored.
- Restore the disks into your current VM (VM must be turned off to do this).