Applications Azure

CiviCRM on Ubuntu 26.04 on Azure User Guide

| Product: CiviCRM 6.21 on Ubuntu 26.04 LTS on Azure

Overview

This image runs CiviCRM 6.21.0 Standalone on Ubuntu 26.04 LTS. CiviCRM is the open source constituent relationship management system for nonprofits, charities, associations and advocacy groups: contacts and households, donations and recurring giving, memberships, events and registration, email mailings, cases and reports, all from a web browser. Standalone means CiviCRM runs on its own, with no separate content management system to install or maintain.

CiviCRM is served by nginx and PHP 8.5 FPM on port 80, with a local MariaDB 11.8 server that listens on the virtual machine only. The database, CiviCRM's settings and your uploaded files are on a dedicated 20 GiB Azure data disk. Each virtual machine makes its own administrator password, its own site and signing keys and its own database password on its first boot, and no default or shared login works.

cloudimg is not affiliated with or endorsed by CiviCRM LLC or the CiviCRM project. CiviCRM is free and open source software, licensed under the GNU AGPL v3 with the CiviCRM Licensing Exception; this image ships the unmodified upstream release. cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours.

What is included:

  • CiviCRM 6.21.0 Standalone, served by nginx and PHP 8.5 FPM on port 80
  • A local MariaDB 11.8 server holding the CiviCRM database, listening on 127.0.0.1 only
  • A per VM administrator password, made on first boot and kept in a file only root can read
  • Per VM CIVICRM_SITE_KEY, credential and signing keys, and a per VM database password, all made on first boot
  • A dedicated 20 GiB Azure data disk for the database, CiviCRM's settings and uploads
  • Links that CiviCRM writes (emails included) use your virtual machine's address or the domains you list, never a name taken from a request
  • An unauthenticated /healthz endpoint for Azure Load Balancer health probes
  • Ubuntu's unattended security upgrades, on

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 HTTPS in step 8) from the people who will use CiviCRM
  • The Azure CLI (az) if you deploy from the command line

The recommended size is Standard_B2s (2 vCPUs, 4 GiB memory), which suits a small organisation. For large contact databases, big mailings or many staff at once, choose a Standard_B2ms (2 vCPUs, 8 GiB) or larger.

Step 1: Deploy the Virtual Machine

Option A: the Azure Portal

  1. Sign in to the Azure Portal, open Marketplace, search for CiviCRM 6.21 on Ubuntu 26.04 LTS 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). The Disks tab shows the image's 20 GiB data disk for CiviCRM's data; keep it.
  4. Select Review + create, then Create. Once the virtual machine is created, limit SSH to your own network on its Networking page.

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:civicrm-ubuntu-26-04:default:latest

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

These rules let only your own network reach CiviCRM. To let staff elsewhere in, add their networks to --source-address-prefixes on the web rule, and add HTTPS first (step 8).

Step 2: Connect to the Virtual Machine

Find the public IP address, then connect over SSH:

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

Check that first boot has finished, that nginx, PHP and MariaDB run, which ports they listen on, which CiviCRM version you have, and that the health check answers:

systemctl is-active nginx php8.5-fpm mariadb civicrm-firstboot
sudo ss -tlnH | awk '{print $4}' | grep -E ':(80|3306)$' | sort -u
curl -s -o /dev/null -w '/healthz -> HTTP %{http_code}\n' http://127.0.0.1/healthz
sed -n 's:.*<version_no>\(.*\)</version_no>.*:CiviCRM \1:p' /var/www/civicrm/core/xml/version.xml
active
active
active
active
0.0.0.0:80
127.0.0.1:3306
[::]:80
/healthz -> HTTP 200
CiviCRM 6.21.0

MariaDB listens on 127.0.0.1:3306 only, so the database is never reachable from the network. If civicrm-firstboot shows activating, first boot is still running: wait a minute and check again.

nginx, PHP 8.5 FPM, MariaDB and the first boot service active, nginx on port 80, MariaDB on 127.0.0.1:3306, the health check answering 200 and CiviCRM 6.21.0

Step 3: Read the Admin Password

The address and the administrator's sign-in made on your virtual machine's first boot are in a file only root can read:

sudo cat /root/civicrm-credentials.txt
# CiviCRM (Standalone) - generated on first boot by civicrm-firstboot.service
# These credentials are unique to this VM. Store them somewhere safe.

CIVICRM_URL=http://203.0.113.10/civicrm/login
CIVICRM_ADMIN_USER=admin
CIVICRM_ADMIN_PASSWORD=<your-admin-password>
#
# Sign in to CiviCRM at the URL above. No default/shipped CiviCRM credential works -
# only the per-VM 'admin' credential above. The CIVICRM_SITE_KEY and crypto keys are
# also unique to this VM. The bundled MariaDB listens on 127.0.0.1:3306 (loopback only).
# On-box DB maintenance: sudo mariadb (root@localhost, no password).
#
# CiviCRM writes the address above into its links (emails included); it never takes one
# from a request's Host header. To serve CiviCRM on your own domain, add the domain on a
# line of its own in /etc/cloudimg/civicrm-hosts. If this VM's address changes, run
# sudo cloudimg-set-public-address. For PRODUCTION add your own domain + TLS (HTTPS),
# an SMTP mailer + a payment processor, and follow standard hardening before use.

The password is 24 characters long and unique to this virtual machine.

The per VM credentials file with the sign-in address, the admin user and the password, which is masked here

Step 4: Sign In

Open http://<public-ip>/civicrm/login in your browser. CiviCRM shows its sign-in page:

The CiviCRM Standalone sign-in page with the username and password fields

Sign in with the user admin and the password from step 3. CiviCRM opens on its home dashboard, with Search, Contacts, Contributions, Events, Mailings, Memberships, Reports and Administer across the top:

The CiviCRM home dashboard after signing in, with the main menu across the top and the dashlets below

To change the administrator's password, open http://<public-ip>/civicrm/my-account/password. To give each person their own sign-in and role, go to Administer > Users and Permissions > User Accounts and User Roles.

Step 5: Manage Contacts

Open Contacts > New Individual or New Organization to add a contact, or Contacts > Import Contacts to bring in a CSV file from another system. Search > Find Contacts lists the people and organisations in your database; each contact has its own record with communication preferences, groups, tags, relationships, activities and contribution history:

Find Contacts in CiviCRM listing individuals and an organisation, with their email addresses and actions on each row

Step 6: Record Contributions and Run Events

CiviCRM's fundraising tools are under Contributions: record donations and payments against contacts, set up financial types, and report on totals over time. Under Events, Manage Events lists your events with their type, dates and whether they are public; from there you set up online registration, fees and participant tracking:

Manage Events in CiviCRM listing an upcoming event with its type, public status and dates

To take payments online, add your payment provider under Administer > CiviContribute > Payment Processors.

Step 7: How the Image Keeps Your Sign-in Safe

CiviCRM was installed with a password that was thrown away, and the image carries no password, key or database credential that any other virtual machine shares. You can check this at any time: this script confirms, with CiviCRM's own password check, that the admin password from step 3 signs in and that common guesses such as admin, admin123, civicrm, password and changeme are refused:

sudo bash /usr/local/sbin/civicrm-cred-roundtrip.sh
sudo cat /etc/cloudimg/civicrm-hosts
OK per-VM admin authenticates via CiviCRM checkPassword; default/weak guesses rejected
203.0.113.10

The second command shows the names CiviCRM uses in the links it writes, password reset emails included. The first line is your virtual machine's address, written on first boot. A request that names any other host gets links to that address, so a forged request can never make CiviCRM send links to someone else's site.

The credential check signing in with the per VM password and refusing the default guesses, and the address CiviCRM uses in its links

Step 8: Serve CiviCRM on Your Own Domain with HTTPS

Before people outside your own network sign in, give CiviCRM a domain and a free, trusted certificate from Let's Encrypt, so passwords never cross the internet in clear text. Point an A record for your domain at the virtual machine's public IP address, and allow TCP 80 and 443 in the network security group (Let's Encrypt checks the domain over port 80). Then, replacing <your-domain> and <your-email>:

echo '<your-domain>' | sudo tee -a /etc/cloudimg/civicrm-hosts
sudo apt-get install -y certbot python3-certbot-nginx
sudo sed -i 's/server_name _;/server_name <your-domain>;/' /etc/nginx/sites-available/cloudimg-civicrm
sudo certbot --nginx -d <your-domain> -m <your-email> --agree-tos -n --redirect

The first command adds your domain to the names CiviCRM answers as, so pages you open at https://<your-domain>/ link to your domain. Certbot adds the certificate to nginx's site, redirects HTTP to HTTPS, and renews the certificate on its own timer. To make your domain the address CiviCRM uses in emails and scheduled jobs too, run sudo civicrm-set-url-base <your-domain>, which moves it to the first line.

If the virtual machine's public IP address changes (for example after you stop it with a dynamic address), run sudo cloudimg-set-public-address: it reads the new address from Azure and updates the first line and the credentials file.

Step 9: Outbound Email and Production Checks

  • Outbound email. Set an SMTP relay under Administer > System Settings > Outbound Email (SMTP/Sendmail), so receipts and mailings are delivered. Azure blocks outbound TCP 25 from most subscriptions, so use your provider's submission port (587).
  • System status. Open Administer > Administration Console > System Status and work through what it recommends, such as setting up the scheduled jobs (cron) for mailings and reminders.
  • Backups. Back up the data disk (below) before every upgrade.

Step 10: Updates

Ubuntu's unattended upgrades install the operating system's security updates every day, PHP, nginx and MariaDB included. CiviCRM itself is not a Ubuntu package, so update it when a new release comes out (https://civicrm.org/blog/tags/release): CiviCRM fixes security issues in its current release only. Back up the data disk first, then follow CiviCRM's Standalone upgrade steps (https://docs.civicrm.org/installation/en/latest/standalone/upgrade/): replace the code under /var/www/civicrm with the new release (keep private/ and public/, which are on the data disk), then run the database upgrade:

sudo -u www-data env HOME=/var/www/civicrm/private cv upgrade:db --cwd=/var/www/civicrm

Server Components

Component Version Notes
CiviCRM 6.21.0 Standalone, AGPL v3 with the CiviCRM Licensing Exception
PHP 8.5.4 Ubuntu's own, PHP FPM behind nginx
MariaDB 11.8.6 Ubuntu's own, on 127.0.0.1:3306 only, data on the data disk
nginx 1.28.3 Port 80
cv 0.3.72 CiviCRM's command line tool, at /usr/local/bin/cv
Ubuntu 26.04.1 LTS Azure kernel, unattended security upgrades on

Filesystem Layout

Mount Size What is there
/ 30 GB OS disk (28 GB root partition) Ubuntu, nginx, PHP and MariaDB, and CiviCRM's code in /var/www/civicrm
/data 20 GiB Azure data disk The MariaDB database (/data/mysql, mounted at /var/lib/mysql) and CiviCRM's settings, logs and uploads (/data/civicrm/private and /data/civicrm/public, mounted at /var/www/civicrm/private and /var/www/civicrm/public)
/mnt Azure temporary disk (size depends on the VM size) Scratch space only: Azure may wipe it on a stop, resize or redeploy
df -h /data | tail -1
mount | grep -E ' /data | /var/lib/mysql | /var/www/civicrm/(private|public) ' | cut -d' ' -f1-5
/dev/sdc         20G  200M   19G   2% /data
/dev/sdc on /data type ext4
/dev/sdc on /var/lib/mysql type ext4
/dev/sdc on /var/www/civicrm/private type ext4
/dev/sdc on /var/www/civicrm/public type ext4

The 20 GiB data disk mounted at /data, with the MariaDB database and CiviCRM's private and public folders on it

Back up the data disk with Azure Backup, or snapshot it. Keep /var/www/civicrm/private/civicrm.settings.php with the database: CiviCRM needs its keys to read the credentials it stored.

Managing the Services

systemctl status nginx php8.5-fpm mariadb --no-pager

Restart CiviCRM's web side with sudo systemctl restart php8.5-fpm nginx. CiviCRM's command line tool runs as the web server's account: sudo -u www-data env HOME=/var/www/civicrm/private cv flush --cwd=/var/www/civicrm clears CiviCRM's caches. For the database, sudo mariadb opens a MariaDB shell as root on the virtual machine itself.

Scripts and Log Files

Path What it does
/usr/local/sbin/civicrm-firstboot.sh First boot: makes this virtual machine's admin password, keys and database password, and writes the credentials file
/root/civicrm-credentials.txt The address and the administrator's sign-in (root only)
/etc/cloudimg/civicrm-hosts The names CiviCRM answers as; the first line is the address it writes into links
/usr/local/sbin/civicrm-set-url-base Makes a name the first line of that file
/usr/local/sbin/cloudimg-set-public-address Points CiviCRM at the virtual machine's new public address
/usr/local/sbin/civicrm-cred-roundtrip.sh Checks that the admin password signs in and default guesses are refused (step 7)
/var/www/civicrm/private/civicrm.settings.php CiviCRM's settings, database connection and keys
/etc/nginx/sites-available/cloudimg-civicrm nginx's site
/var/log/civicrm-firstboot.log The first boot log (also journalctl -u civicrm-firstboot)

On Startup

On the first boot civicrm-firstboot.service runs once, after MariaDB is up. It gives the civicrm database user a new password, makes new site, credential and signing keys, sets a new password for admin, records the virtual machine's address in /etc/cloudimg/civicrm-hosts, writes the credentials file, and records /var/lib/cloudimg/civicrm-firstboot.done so it never runs again. On every later boot nginx, PHP FPM and MariaDB start as normal, and Ubuntu's unattended upgrades run on their usual timers.

Troubleshooting

The browser cannot connect. Check that the network security group allows TCP 80 from your address, and that first boot has finished: systemctl status civicrm-firstboot --no-pager and sudo cat /var/log/civicrm-firstboot.log.

Pages open without their styles, or links go to the wrong address. Open CiviCRM at the address on the first line of /etc/cloudimg/civicrm-hosts, or add the name you use on a line of its own (step 8). If the public IP address changed, run sudo cloudimg-set-public-address.

The sign-in is refused. Use the user admin and the password from /root/civicrm-credentials.txt. If you changed the password, the file still shows the first one.

nginx answers 502 Bad Gateway. PHP FPM has stopped: systemctl status php8.5-fpm --no-pager, then sudo systemctl restart php8.5-fpm.

CiviCRM shows a database error. Check that MariaDB runs (systemctl status mariadb --no-pager) and that the data disk is mounted (df -h /data).

Security Recommendations

  • Add HTTPS on your own domain (step 8) before anyone signs in from outside your own network.
  • Change the administrator password once you have signed in (step 4), and give each person their own sign-in with only the permissions they need.
  • Allow SSH only from your own network in the network security group, and TCP 80 and 443 only from the people who use CiviCRM.
  • Keep CiviCRM on its current release (step 10): its security fixes go into the current release only.
  • Back up the data disk regularly.

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 CiviCRM itself, see its documentation at https://docs.civicrm.org/ and the community at https://civicrm.org/. cloudimg is not affiliated with or endorsed by CiviCRM LLC or the CiviCRM project.