Applications Azure

WordPress 7 on Ubuntu 24.04 on Azure User Guide

| Product: WordPress 7 on Ubuntu 24.04 on Azure

Overview

This image runs WordPress 7.1.5 on Ubuntu 24.04 LTS with Apache 2.4, PHP 8.3 and MySQL 8.0, all from Ubuntu's own package archive (no third party repositories). WordPress is downloaded from wordpress.org and checked against its published checksum when the image is built, and WP-CLI 3.0.0 is installed at /usr/local/bin/wp for managing the site from the command line.

WordPress installs itself on the first boot of every virtual machine. The WordPress administrator password, the WordPress database password and the MySQL root password are created on your virtual machine and never shared with another one. They are written to /stage/scripts/wordpress-credentials.log, readable by root only. Apache does not serve anything until that first boot has finished, so nobody can reach WordPress's setup screens before your site is installed.

The site is served on port 80 at your virtual machine's public IP address, as reported by Azure. One command (sudo cloudimg-set-public-address <your-domain>, step 8) moves it to your own domain, and certbot adds a free HTTPS certificate (step 9).

The image also ships with:

  • WordPress's automatic background updates on, so every 7.1.x security and maintenance release is applied for you; moving to a new major release stays your decision
  • Image uploads and thumbnails handled by PHP's GD library (ImageMagick is not installed)
  • MySQL listening on the local machine only
  • Ubuntu's unattended security upgrades switched on

The default operating system user is the administrator account you choose when you create the virtual machine (azureuser in the examples below). WordPress lives in /var/www/html/wordpress, and the WordPress administrator user is cloudimg.

Prerequisites

  • A Microsoft Azure subscription in which you can create resource groups, virtual networks and virtual machines
  • An SSH key pair for the administrator account
  • A network security group that allows inbound TCP 22 from your own network, and TCP 80 (and 443 once you add a certificate) from your visitors
  • The Azure CLI (az) if you deploy from the command line

The recommended size is Standard_B2s (2 vCPUs, 4 GiB memory) for small and medium sites. For a busier site, or a WooCommerce store, choose a Standard_D2s_v5 or larger.

Step 1: Deploy the Virtual Machine

Option A: the Azure Portal

  1. Sign in to the Azure Portal, open Marketplace, search for WordPress 7 on Ubuntu 24.04 by cloudimg and select Create.
  2. On Basics choose your subscription, a resource group, a region and a name, and pick Standard_B2s or larger. Under Administrator account choose SSH public key and enter your user name and key.
  3. Under Inbound port rules allow SSH (22) and HTTP (80). Limit SSH to your own address on the Networking tab afterwards if you can.
  4. Select Review + create, then Create.

First boot finishes about a minute after the virtual machine shows Running.

Option B: the Azure CLI

Accept the Marketplace terms once per subscription, then create the virtual machine. Replace <your-mgmt-cidr> with the network you connect from, for example 203.0.113.0/24.

az vm image terms accept --urn cloudimg1647283583153:wordpress-7-ubuntu-24-04:default:latest

RG=wordpress-rg
az group create --name $RG --location eastus
az vm create \
  --resource-group $RG \
  --name wordpress-01 \
  --image cloudimg1647283583153:wordpress-7-ubuntu-24-04:default:latest \
  --size Standard_B2s \
  --admin-username azureuser \
  --ssh-key-values ~/.ssh/id_rsa.pub \
  --public-ip-sku Standard \
  --nsg-rule NONE
az vm open-port --resource-group $RG --name wordpress-01 --port 80 --priority 1010
az network nsg rule create --resource-group $RG --nsg-name wordpress-01NSG \
  --name AllowSSHFromMgmt --priority 1000 --access Allow --protocol Tcp \
  --direction Inbound --source-address-prefixes <your-mgmt-cidr> --destination-port-ranges 22

Step 2: Connect to the Virtual Machine

Find the public IP address, then connect over SSH:

az vm show --resource-group wordpress-rg --name wordpress-01 --show-details --query publicIps -o tsv
ssh azureuser@<public-ip>

Check that the services are running, which versions you have, and that WordPress answers:

systemctl is-active apache2 mysql
sudo -u www-data wp core version --path=/var/www/html/wordpress
php -v | head -1
mysql --version
wp --version --allow-root
curl -s -o /dev/null -w 'wp-login.php %{http_code}\n' http://127.0.0.1/wp-login.php
active
active
7.1.5
PHP 8.3.6 (cli) (built: Nov 18 2026 23:42:07) (NTS)
mysql  Ver 8.0.46-0ubuntu0.24.04.5 for Linux on x86_64 ((Ubuntu))
WP-CLI 3.0.0
wp-login.php 200

Apache and MySQL running, WordPress 7.1.5 and the component versions

Step 3: Read the Administrator Credentials

sudo cat /stage/scripts/wordpress-credentials.log

The file holds the site address, the administrator user name (cloudimg) and the passwords created for this virtual machine:

# WordPress 7 — Per-VM Credentials
# Generated: Tue Dec  1 18:45:12 UTC 2026
WP_URL=http://203.0.113.10/
WP_ADMIN_URL=http://203.0.113.10/wp-admin/
WP_ADMIN_USER=cloudimg
WP_ADMIN_PASSWORD=<32 hex characters, unique to this VM>
WP_DB_NAME=wordpress
WP_DB_USER=wpuser
WP_DB_PASSWORD=<32 hex characters, unique to this VM>
MYSQL_ROOT_PASSWORD=<32 hex characters, unique to this VM>
# To change the address this VM uses: sudo cloudimg-set-public-address <public-ip-or-dns-name>
#   (it points WordPress's home and siteurl settings at it and updates this file)

Store the passwords in a password manager. If Azure did not report a public IP address when the virtual machine first booted (for example, a virtual machine with only a private address behind a firewall), the addresses read <your-vm-public-ip> and the file ends with a note: run sudo cloudimg-set-public-address <public-ip-or-dns-name> (step 8) to point WordPress at the right address.

The per VM credentials file and its permissions

Step 4: Visit Your Site

Open http://<public-ip>/ in your browser. WordPress shows its front page with the sample Hello world! post, in the default block theme.

The WordPress 7 front page on a new VM

Step 5: Sign in to WordPress

Open http://<public-ip>/wp-admin/. WordPress shows its sign-in page; sign in as cloudimg with the WP_ADMIN_PASSWORD from the credentials file.

The WordPress sign-in page

Change the administrator password now: open Users, then Profile, and choose Set New Password. Also set your own email address on the same page, so password resets and site notices reach you. From the command line the same is:

sudo -u www-data wp user update cloudimg --user_pass='<new-password>' --user_email='<your-email>' --path=/var/www/html/wordpress

Step 6: The Dashboard

After you sign in, WordPress opens the dashboard. The left menu holds Posts, Media, Pages, Comments, Appearance (themes, the site editor and styles), Plugins, Users, Tools and Settings. Open Settings > General to give your site its title and tagline.

The WordPress 7.1.5 dashboard

Step 7: Write and Publish a Post

Open Posts > Add Post. The block editor opens: type a title, press Enter and start writing; the + button adds images, galleries, headings, lists, embeds and every other block. Select Publish, then Publish again to confirm, and the post appears on your front page.

Writing a post in the WordPress 7 block editor

Themes and plugins install from Appearance > Themes > Add New Theme and Plugins > Add New Plugin. Akismet and Hello Dolly ship with WordPress and are inactive until you turn them on.

Step 8: Serve WordPress on Your Own Domain

WordPress builds its links from two settings, the WordPress Address and the Site Address. On first boot both are http:// followed by the public IP address Azure reports for the virtual machine. To use your own domain, point an A record at the public IP address, then run:

sudo cloudimg-set-public-address <your-domain>

The command points both settings at the new address and updates the credentials file. It only changes a setting that still holds the virtual machine's old address, so it never overwrites an address you set yourself. Check the result with:

sudo -u www-data wp option get home --path=/var/www/html/wordpress
sudo -u www-data wp option get siteurl --path=/var/www/html/wordpress
http://203.0.113.10
http://203.0.113.10

While the site still uses the IP address, and that address changes (for example after you stop and deallocate a virtual machine with a dynamic public IP), run sudo cloudimg-set-public-address with no argument: it reads the new address from Azure.

Step 9: Add HTTPS

With a domain pointed at the virtual machine (step 8), get a free Let's Encrypt certificate with certbot. Open TCP 443 in the network security group first, and keep port 80 open: certbot proves you own the domain over it, and renews the certificate the same way.

sudo apt-get install -y certbot python3-certbot-apache
sudo certbot --apache -d <your-domain> -m <your-email> --agree-tos -n --redirect
sudo -u www-data wp option update home https://<your-domain> --path=/var/www/html/wordpress
sudo -u www-data wp option update siteurl https://<your-domain> --path=/var/www/html/wordpress

certbot adds an HTTPS site to Apache, redirects HTTP to HTTPS, and its timer renews the certificate before it expires.

Step 10: Configure Outgoing Email

WordPress sends password resets, comment notices and update reports by email. Azure blocks outbound port 25, so send through an SMTP relay on port 587 (Azure Communication Services, SendGrid, Microsoft 365 or similar). Install an SMTP plugin from Plugins > Add New Plugin (for example WP Mail SMTP), enter the relay's host, port 587 with TLS, user name and password, and send its test email.

Step 11: Updates and Backups

WordPress checks for updates twice a day and installs every 7.1.x security and maintenance release by itself. Plugins and themes, and moving to a new major release, are updated from Dashboard > Updates, or from the command line:

sudo -u www-data wp core check-update --path=/var/www/html/wordpress
sudo -u www-data wp plugin list --path=/var/www/html/wordpress
Success: WordPress is at the latest version.
name    status  update  version update_version  auto_update
akismet inactive    none    5.7.2       off
hello   inactive    none    1.7.2       off

Ubuntu's unattended upgrades install security updates for Apache, PHP, MySQL and the operating system every day.

Automatic WordPress updates on, core files matching wordpress.org's checksums, and Ubuntu's daily upgrades on

Back up the database and the WordPress files together. mysqldump asks for the database password, WP_DB_PASSWORD in the credentials file:

mysqldump -u wpuser -p --single-transaction --no-tablespaces wordpress > <backup-dir>/wordpress-db.sql
sudo tar -czf <backup-dir>/wordpress-files.tgz -C /var/www/html wordpress

Copy both files off the virtual machine, for example to Azure Blob Storage. Azure Backup can also take scheduled snapshots of the whole virtual machine.

Server Components

Component Version Notes
WordPress 7.1.5 Official release from wordpress.org, /var/www/html/wordpress, default theme Twenty Twenty-Five
Apache 2.4.58 Port 80, mod_rewrite on for pretty permalinks
PHP 8.3.6 Ubuntu 24.04 packages, mod_php, GD for images
MySQL 8.0.46 Ubuntu 24.04 packages, local only (127.0.0.1:3306)
WP-CLI 3.0.0 /usr/local/bin/wp, checked against its published SHA-512
Ubuntu 24.04.5 LTS Azure kernel, unattended security upgrades on

Filesystem Layout

Mount Size What is there
/ 30 GB OS disk (29 GB root partition) Ubuntu, WordPress in /var/www/html/wordpress (uploads in wp-content/uploads), MySQL data in /var/lib/mysql
/boot 881 MB Kernels
/boot/efi 105 MB EFI system partition
/mnt Azure temporary disk (size depends on the VM size) Scratch space only: Azure may wipe it on a stop, resize or redeploy. Never keep WordPress data here

For a large media library, attach a managed data disk and move /var/www/html/wordpress/wp-content/uploads onto it.

Managing the Services

sudo systemctl status apache2 mysql --no-pager
sudo systemctl restart apache2
sudo -u www-data wp cache flush --path=/var/www/html/wordpress

wp (WP-CLI) runs every WordPress task from the command line. Run it as www-data, the user that owns the WordPress files, with --path=/var/www/html/wordpress.

To open the MySQL shell as root, run mysql -u root -p and enter MYSQL_ROOT_PASSWORD from the credentials file. WordPress itself connects as wpuser, which can reach the wordpress database only.

Scripts and Log Files

Path What it does
/usr/local/sbin/wordpress-firstboot.sh First boot: sets the MySQL root password, creates the database and its user, writes wp-config.php, installs WordPress with a new administrator password, then writes /var/lib/cloudimg/wordpress-firstboot.done
/usr/local/sbin/cloudimg-set-public-address Points WordPress at a new address or domain (step 8)
/stage/scripts/wordpress-credentials.log The site address and the passwords (root only)
/var/log/wordpress-firstboot.log The first boot log (also journalctl -u wordpress-firstboot)
/etc/apache2/sites-available/wordpress.conf The Apache site
/var/log/apache2/wordpress-access.log, wordpress-error.log Apache access and error logs
/var/log/mysql/error.log MySQL log

On Startup

On the first boot wordpress-firstboot.service runs once, after MySQL starts and before Apache: it reads the virtual machine's public IP address from Azure, creates the passwords, the database and wp-config.php, installs WordPress, and records /var/lib/cloudimg/wordpress-firstboot.done so it never runs again. Apache starts only once that file exists. On every later boot Apache and MySQL start as normal systemd services, and Ubuntu's unattended upgrades and WordPress's update checks run on their usual timers.

Troubleshooting

The browser cannot connect. First boot may still be running: Apache starts only when it has finished. Wait a minute, then check systemctl status wordpress-firstboot --no-pager and sudo cat /var/log/wordpress-firstboot.log. Also check that the network security group allows TCP 80.

Links or the sign-in page go to an old address. WordPress still holds the previous address. Run sudo cloudimg-set-public-address <your-domain> (step 8).

Uploads fail for large files. PHP limits an upload to 2 MB by default. Raise upload_max_filesize and post_max_size in /etc/php/8.3/apache2/php.ini, then sudo systemctl restart apache2.

A plugin broke the site. Turn it off from the command line: sudo -u www-data wp plugin deactivate <plugin> --path=/var/www/html/wordpress.

Security Recommendations

The image listens only on SSH (22) and HTTP (80); MySQL answers on the local machine only, and WordPress's setup screens are closed once first boot has installed the site:

Listening ports, MySQL accounts, Apache held until first boot finishes, and no ImageMagick

  • Change the administrator password after the first sign in, and give every author their own account with the lowest role they need.
  • Allow SSH only from your own network in the network security group.
  • Add HTTPS (step 9) before you sign in from a public network.
  • Keep plugins and themes few and up to date, and remove the ones you do not use.
  • Leave unattended upgrades and WordPress's automatic updates on.
  • Keep wp-config.php readable by the web server only (it ships as mode 640, owned by www-data): it holds the database password and the keys that sign WordPress's cookies.

Support

cloudimg's support team is on hand 24 hours a day by email at support@cloudimg.co.uk, with a guaranteed response within 24 hours. For WordPress itself, see the documentation at https://wordpress.org/documentation/ and the support forums at https://wordpress.org/support/.