This guide covers keeping a running CloudSOE OpenEMR instance patched and up to date. It covers PHP, the Ubuntu 26.04 LTS operating system and OpenEMR itself, plus moving to a fresh image when an in-place upgrade isn’t the right call.
It’s especially important right now. PHP2Shell (CVE-2026-109618 and CVE-2026-109619) is a critical remote code execution flaw in PHP that attackers are already exploiting, and it’s one of several recent CVEs in the web stack. OpenEMR holds patient records, so a compromise is a reportable breach in most jurisdictions. Patch PHP today.
What you can upgrade in place
| Component | In place? | How |
|---|---|---|
| Operating system (Ubuntu 26.04 LTS) | Yes, for updates within 26.04 | apt (see Update the operating system). For a new Ubuntu release, use a fresh image |
| PHP 8.5 (Ubuntu packages) | Yes | apt, then restart Apache (see Patch PHP) |
| OpenEMR patch and minor releases | Yes, with care | OpenEMR’s own upgrade procedure (see Upgrade OpenEMR) |
| OpenEMR major release | Use a fresh image | See Move to a fresh CloudSOE image |
| Apache and MariaDB | Yes, for updates within 26.04 | apt, along with the rest of the OS |
| Node.js 22 (C-CDA service) | Yes, within 22.x | apt (from the NodeSource repository configured in the image) |
Before you start: back up
Take both kinds of backup before you patch or upgrade anything. Store them encrypted, somewhere that meets your regulatory requirements, because they contain patient data.
1. A cloud disk snapshot. This lets you roll the whole instance back in minutes:
- AWS: open EC2 → Volumes, select the instance’s root volume, then choose Actions → Create snapshot.
- Azure: open the VM, go to Disks, select the OS disk, then choose Create snapshot.
2. An application-level backup. This is the database plus the sites tree (configuration and patient documents):
sudo mysqldump --single-transaction openemr | gzip > /home/$(whoami)/openemr-db-$(date +%F).sql.gz
sudo tar czf /home/$(whoami)/openemr-sites-$(date +%F).tar.gz -C /var/www/html sites
Copy these files off the instance, for example with scp to your own machine or to encrypted S3 or Azure Blob storage. Schedule upgrades outside clinic hours.
Patch PHP (PHP2Shell)
PHP2Shell is a pair of vulnerabilities, CVE-2026-109618 and CVE-2026-109619, published on 21 October 2026. They allow critical remote code execution in PHP 5.4 through 8.5 and are being exploited in the wild. Updating PHP is the only complete fix. The published workarounds are incomplete, so don’t rely on them.
Upstream PHP fixed it in 8.2.35, 8.3.36, 8.4.27 and 8.5.12. Ubuntu keeps its own version numbers and backports the fix, so what matters is the package version, not the number php -v prints.
Check your PHP version
php -v
dpkg -l | grep -E '^ii +php[0-9.]+-(cli|common) '
Compare the version column with the patched package:
| Base OS | PHP package | Patched version (or later) |
|---|---|---|
| Ubuntu 26.04 LTS | php8.5 | 8.5.4-0ubuntu1.5 |
php -v still reports PHP 8.5.4 after the patch, because Ubuntu backports the fix without changing the upstream number. Go by the dpkg -l output.
Update PHP
sudo apt update
sudo apt upgrade
The OpenEMR image uses the distribution’s PHP running inside Apache, so restart Apache to load the patched PHP:
sudo systemctl restart apache2
To confirm which PHP integration Apache uses, run ls /etc/apache2/mods-enabled/ | grep php. You should see php8.5.load. If you see no PHP module and use PHP-FPM instead, restart it as well: sudo systemctl restart php8.5-fpm.
Confirm the fix
dpkg -l | grep -E '^ii +php[0-9.]+-(cli|common) '
Both php8.5-cli and php8.5-common should show 8.5.4-0ubuntu1.5 or later. If they don’t, run apt policy php8.5-common to check that the resolute-security or resolute-updates repository is reachable.
Update the operating system
The OpenEMR image runs on Ubuntu 26.04 LTS, and Ubuntu publishes security updates for it through apt. The same command also updates Node.js 22 from the NodeSource repository configured in the image:
sudo apt update
sudo apt upgrade
If apt upgrade reports packages as “kept back” (often a new kernel), run sudo apt full-upgrade. Review the list before you confirm.
Then check whether a reboot is needed:
[ -f /var/run/reboot-required ] && cat /var/run/reboot-required.pkgs
If the file exists, reboot outside clinic hours. Apache and MariaDB start automatically:
sudo reboot
After the reboot, clear out the old kernels with sudo apt autoremove --purge.
Automatic security updates
CloudSOE images don’t change the base OS’s automatic-update settings. To see whether unattended-upgrades is active on your instance:
systemctl status unattended-upgrades
apt-config dump APT::Periodic::Unattended-Upgrade
If the setting shows "1", Ubuntu security updates (including PHP fixes) install automatically. You still need to restart Apache and reboot yourself. Node.js updates from NodeSource aren’t included by default. To turn it on, run sudo apt install unattended-upgrades && sudo dpkg-reconfigure -plow unattended-upgrades.
New Ubuntu releases
Don’t run do-release-upgrade on a production OpenEMR instance. A release upgrade replaces PHP, MariaDB and Apache all at once, which makes problems hard to roll back. When you want a newer Ubuntu release, move to a fresh CloudSOE image instead.
Upgrade OpenEMR
The image installs OpenEMR from the official release archive on GitHub (github.com/openemr/openemr/releases), not from a package. The application lives directly in /var/www/html, owned by www-data. The site configuration and patient documents live under /var/www/html/sites. An OpenEMR upgrade means replacing the code with the new release, carrying over the sites tree, then letting OpenEMR upgrade its database.
Check which version you’re running first:
grep -E '^\$v_(major|minor|patch|realpatch)' /var/www/html/version.php
Which upgrades to do in place
- Patch and minor releases within your current major version can be done in place, following the steps below.
- Major releases can change the required PHP, Node.js or MariaDB versions. Use a fresh CloudSOE image built for that release, and restore your data into it.
- Always read the release notes for your target version on open-emr.org. If they give different instructions (for example, a patch delivered as a separate package), follow them.
Step by step
- Download the new release and check its checksum. Replace
X.Y.Zwith the version, and use the tag format from the releases page, e.g.v8_4_1for 8.4.1:
mkdir -p /tmp/oe-new && cd /tmp/oe-new
curl -fLO https://github.com/openemr/openemr/releases/download/vX_Y_Z/openemr-X.Y.Z.tar.gz
curl -fLO https://github.com/openemr/openemr/releases/download/vX_Y_Z/openemr-X.Y.Z.tar.gz.sha256
sha256sum openemr-X.Y.Z.tar.gz; cat openemr-X.Y.Z.tar.gz.sha256 # the two hashes must match
tar xzf openemr-X.Y.Z.tar.gz
- Take the site offline and swap in the new code. Keep the old tree for rollback:
sudo systemctl stop apache2
sudo mv /var/www/html /var/www/html.old
sudo mkdir /var/www/html
sudo cp -a /tmp/oe-new/openemr-*/. /var/www/html/
- Carry over your
sitestree (configuration,sqlconf.phpand patient documents):
sudo rm -rf /var/www/html/sites
sudo cp -a /var/www/html.old/sites /var/www/html/sites
sudo chown -R www-data:www-data /var/www/html
- Reinstall the C-CDA service’s dependencies:
cd /var/www/html/ccdaservice && sudo npm install
- Bring Apache back and run OpenEMR’s database upgrade. Browse to
https://<public-ip>/sql_upgrade.php, select the version you’re upgrading from, and start the upgrade. Wait for it to report that it has finished.
sudo systemctl start apache2
- Log in and check that patients, documents and the calendar look right. Then remove the old tree with
sudo rm -rf /var/www/html.old.
If anything goes wrong, stop Apache, put the old tree back (sudo rm -rf /var/www/html && sudo mv /var/www/html.old /var/www/html), and restore the database dump or the cloud snapshot.
Custom code and modules
If you’ve changed OpenEMR’s own files, or added custom modules or forms outside sites, step 2 doesn’t carry them over. Re-apply them to the new release from /var/www/html.old once you’ve checked they’re compatible.
Move to a fresh CloudSOE image
Launching a new instance from the latest CloudSOE OpenEMR image and moving your data across is the right approach when:
- you’re moving to a new major OpenEMR release,
- your instance’s Ubuntu release is approaching end of life, or you want a newer release,
- the instance has drifted a long way from a clean state, or you suspect it was compromised before you patched. In that case, review user accounts and the audit log after you restore.
The new instance’s OpenEMR version must be the same as or newer than your old one. OpenEMR upgrades a restored database forward, never backward.
1. Back up the old instance
On the old instance, stop Apache so nobody changes records mid-backup:
sudo systemctl stop apache2
grep -E '^\$v_(major|minor|patch|realpatch)' /var/www/html/version.php # note the old version
mkdir -p ~/migration
sudo mysqldump --single-transaction openemr | gzip > ~/migration/openemr-db.sql.gz
sudo tar czf ~/migration/openemr-sites.tar.gz -C /var/www/html sites
sudo chown -R $(whoami) ~/migration
2. Launch the new instance
Launch the latest CloudSOE OpenEMR image, following the AWS or Azure getting-started guide. Let first boot finish (systemctl status openemr-firstboot).
3. Copy the backup across
From your own machine, use ubuntu on AWS or your chosen admin user on Azure. Keep the files on encrypted storage and delete your local copy afterwards:
scp -r ubuntu@<old-ip>:migration ./migration
scp -r ./migration ubuntu@<new-ip>:
4. Restore on the new instance
On the new instance:
sudo systemctl stop apache2
# Keep the new instance's database connection settings
sudo cp -p /var/www/html/sites/default/sqlconf.php ~/sqlconf.php.new
# Database: replace the fresh install
sudo mysql -e "DROP DATABASE openemr; CREATE DATABASE openemr;"
gunzip -c ~/migration/openemr-db.sql.gz | sudo mysql openemr
# Sites tree: configuration and patient documents
sudo rm -rf /var/www/html/sites
sudo tar xzf ~/migration/openemr-sites.tar.gz -C /var/www/html
sudo cp -p ~/sqlconf.php.new /var/www/html/sites/default/sqlconf.php
sudo chown -R www-data:www-data /var/www/html/sites
sudo systemctl start apache2
The openemruser database user and its privileges survive the drop and re-create. The restored sites tree uses the new instance’s sqlconf.php, so the connection settings match the new database.
If the new image runs a newer OpenEMR than the old instance, browse to https://<new-ip>/sql_upgrade.php, select your old version and run the database upgrade before anyone logs in.
Your users and their passwords come across with the database. The rotated Administrator password in /opt/openemr-default-credentials.txt no longer applies, so log in with your existing accounts. If you’ve lost the Administrator password, reset it with sudo php /usr/local/bin/change-password.php 'my-new-strong-password'.
5. Switch traffic and retire the old instance
- Point your DNS A record at the new instance’s IP. You can also move the address itself: on AWS, re-associate your Elastic IP with the new instance; on Azure, dissociate the static public IP from the old VM’s network interface and associate it with the new one.
- Once DNS points at the new instance, request a new trusted certificate there with
sudo certbot --apache -d emr.example.com. See the configuration guide. If you changed hostname, update the site address in OpenEMR’s settings as described there. - Stop (don’t delete) the old instance and keep it for a few days in case you need something from it. It holds patient data, so keep it locked down.
- When you’re happy, terminate or delete the old instance, its disks and the snapshots you took for this upgrade, in line with your data-retention policy.
Check everything works
After any patch, upgrade or migration:
# Services are running
systemctl status apache2 mariadb --no-pager
# PHP is the patched package
dpkg -l | grep -E '^ii +php[0-9.]+-(cli|common) '
# OpenEMR version
grep -E '^\$v_(major|minor|patch|realpatch)' /var/www/html/version.php
From your own machine, since an Azure VM often can’t reach its own public IP:
curl -skI https://<public-ip>/interface/login/login.php
Then, in OpenEMR:
- Log in as
Administratorand as a normal clinical user. - Open a test patient and check their demographics, encounters and an uploaded document.
- Check the calendar and, if you use it, a C-CDA export.
- Review Administration → System → Logs for errors since the upgrade.
Next steps
- Configure OpenEMR: file locations, database access, HTTPS, domains and password resets
- Tips & tricks: backups, hardening and troubleshooting