Install and upgrade problems are the most common topics here, and many go unanswered. Most come down to the same dozen causes: a PHP that’s too old or too new, a missing extension (often intl, which turns the calendar into “Unknown”), files that didn’t finish copying, a database that’s a step behind the code, or encryption keys left behind in a move.
I’ve put together a read-only script that checks for those causes and says what each one means: openemr-doctor.php. Download it to the server and run:
libraries, built assets and files missing compared with your release or patch
the database connection, with what each error number means
whether the database matches the code (an unfinished sql_upgrade.php or sql_patch.php)
modules switched on but missing
encryption keys that don’t match the database
documents whose files aren’t where OpenEMR looks
The web server often runs a different PHP from the command line. To check that one, copy the file into your OpenEMR folder and open http://localhost/<your openemr folder>/openemr-doctor.php in a browser on the server itself. It refuses anyone else. Delete it afterwards.
It changes nothing and prints no passwords or keys. The only thing it downloads is the facts for your release; nothing about your server is sent anywhere. It runs on PHP 5.4 and later, so it can tell you a PHP is too old instead of crashing on it.
Since this post, the same repository has two more tools, for the upgrade itself:
openemr-rehearse.sh runs your upgrade on a copy of your database, in Docker, before you do it for real. Give it a mysqldump of your site. It reports what the upgrade changed in the database structure and in the data, and whether anything was lost. Your live site isn’t touched.
openemr-upgrade.sh upgrades an install from the release tarball. It backs up the database and sites/, unpacks the new release beside the old one, runs the upgrade, checks the result, and keeps a one-command rollback. It also finds files you changed in OpenEMR itself and carries the changes over where they still fit, instead of silently dropping them.
The rehearsals turned up two things worth knowing if you’re upgrading an older site:
Sites first installed before 6.0.0 still have old utf8 tables, which no upgrade converts. An emoji typed into one is saved as ?. The repository has a converter for them.
If you’re moving to MariaDB 11.4 or newer by dump and restore, create the database with CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci before restoring. Otherwise the tables the upgrade creates end up in a different collation, and some screens and the upgrade itself can fail.
I wonder if it wouldn’t be worth sitting down and working out how to do an anonymous temporary container that could borrow an OpenEMR volume mount long enough to run the doctor against the environment. Or would this be a good place to lean on the new vendor hooks?
The doctor and the pre-flight check run inside the container, with the container’s own PHP. Copy the file in, then run docker compose exec openemr php /tmp/openemr-doctor.php --openemr=/var/www/localhost/htdocs/openemr. The doctor’s tests run it exactly that way against the official 8.4.1 image.
The rehearsal is already Docker-native. Upgrading a Docker install means changing the image tag, and openemr-rehearse.sh does that on a copy of your database dump, with the official image of the target release.
openemr-upgrade.sh is only for tarball installs.
Your temporary-container idea works. I just ran the doctor from a throwaway container of the same image, borrowing the running container’s volumes and network, on a stock 8.4.1 compose stack:
It produced the full report, database included. Using the same image matters, because the PHP and extension checks are about the image’s PHP. It’s also a way to run the doctor when the OpenEMR container won’t stay up, which is when people need it most.
The vendor hooks look like a natural home too. A postupgrade hook that runs the doctor would put its findings in the compose log right after each upgrade. Whether a FAIL should stop the launch is your call, since that lifecycle point isn’t retried. I can write the hook and test it against the official image, either for openemr-devops or in the reference repo, whichever you prefer.
One more fit with what the hooks are for: the upgrade script finds edits to OpenEMR’s own files by comparing them with the release’s git hashes, and saves each edit as a patch. For a Docker install, a prelaunch hook could reapply those patches on every launch. Would that help the people you added the hooks for?
Yes, that’s a good home for most of it, as php bin/console openemr:doctor, like the other commands.
One limit shapes the split: bin/console needs OpenEMR to start (Composer’s autoloader, a PHP that can parse it), and several of the doctor’s checks are for when that fails: a PHP that’s too old or too new, a missing vendor/, files that didn’t finish copying. So the command would cover a working install, and the standalone file would stay as the fallback that runs on any PHP.
It would also tie in with Asher’s hooks: a postupgrade hook could simply run bin/console openemr:doctor.
It should build on src/Health, the checks behind the readyz probe, and that raises a design question for you and Michael: HealthCheckResult is healthy or not, while the doctor also reports warnings and notes, each with a fix. Extend the result, or keep the doctor’s results separate so the probe doesn’t change? I’ll open a GitHub issue with a proposed design, so it can be settled before any code.
It proposes three small PRs, ordered by what each check needs: the checks that only read files first (PHP version, extensions, Composer packages), then the database ones on their own connection, then the ones that need OpenEMR fully started. There are three open questions there, the main one for Michael about the result model. I’ll wait for answers before writing code.
I tried really hard to make this work without writing the doctor script to the drive, but I had the absolute worst luck trying to pipe curl into the container’s PHP and eventually just flat gave up.
With this note, here’s a one-shot script somebody can Just Paste into their compose directory and have it work.
Interrogates docker compose, fetches the network it needs too, grabs the doctor, and hands out the output. As long as the compose is up, it’ll find what it needs.
Thanks, that’s handy. I ran it on a stock 8.4.1 compose stack and hit one snag. Builds get republished under the same tag (the 8.4.1 image I’d pulled was rebuilt on October 13), and once the tag has been pulled again since the container started, docker compose ps shows the image as sha256:… instead of openemr/openemr:…, so the grep finds nothing. On a stack that hasn’t been re-pulled it works as is, and pinning a dated tag such as 8.4.1-2026-10-14 avoids it too, since that tag never moves.
Trying it on older releases turned up one more: the throwaway container only shares volumes, so on a stack without sites/ on a volume it sees the image’s own, never-configured sites/ and skips the database checks.
I’ve added your script to the repository, credited to you, with both handled. It finds the container by the image it was started from and runs that exact image, and when sites/ isn’t on a volume it runs the doctor inside the running container instead. It also works with the older docker-compose. I tested it on 8.4.1 after a re-pull, and on the official 5.0.2 and 7.0.3 images:
Don’t know why you credited me, I don’t think a single line I wrote survived. I had no idea docker inspect was so willing to let you control the output.
Can you do me one favor? Wrap the whole script in a function and then call the function? I want to tell people to do curl <script> | bash and wrapping protects against partial downloads.
Done, it’s in v0.3.4: the whole script is one function, called on the last line, so a download cut short does nothing. This now works from the directory with the docker-compose.yml:
Marvelous, thank you. We might move the script around or do other stuff later, but being able to tell somebody to Just Run This may knock a lot of time off getting support off the ground.
@jesdynf, on “we might move the script around”: if you’d rather it lived in openemr-devops, or beside the image in openemr/openemr, say where and I’ll send it there as a PR. It’s one file, GPL-3.0 like both repos, and the only thing tied to my repository is the address it downloads the doctor from, which is a variable. Until then I’ll keep the curl … | bash address working and keep changes to the script small.
One question while you’re here, since it’s your area: when a site’s code and database are at different patch levels, the doctor tells it to open sql_patch.php. The Docker image removes that file after setup, and Docker Hub says patch upgrades (7.0.3 to 7.0.3.4) aren’t automatic. What should it tell a Docker user instead?
Hello, @anun333, sorry for the delay on this. Between php2shell and the spin-up to the holidays things have been hectic.
I think I’d prefer to see it in the -devops repo because if it lives there, people are always forced to get a new version of it to use it, though I suppose airgapped systems that can’t see the net might need the file copied around. I don’t want to have “old” versions of the doctor running around on old containers, is my point. Anybody asking for help from the help tool should get the most recent model.
As for the patch question, I’m not sure. Recent patch upgrades are automatic, running the new container flavor catches up the existing DB to the current container version, and we’ve had that in place since early 5.0. If the container is healthy enough to bootstrap, it should detect the DB and patch it in place. I’m not sure what the hub notes are saying about this.
and it always downloads the newest doctor from there. For air-gapped systems, a copied doctor says how old it is when it can’t look for a newer one, and online every copy says when there is one. The old address will forward to the new one.
On patches, we tried it on the 8.0.0 image (8.0.0.3): with the database at patch 2, recreating the container left it at patch 2. As far as we can tell, the start runs the upgrade when the image is a newer release, and in 8.5.0 and later images when the database version is behind, which covers patches that change the schema. A patch number on its own isn’t touched, which matches the Docker Hub note. So for now the doctor’s patch advice stays as it is.
A correction to my last post: patches haven’t always raised the database version when they change the database (7.0.1 patch 1 and 7.0.2’s patches added columns without), so the doctor now reads the install’s own sql/patch.sql. If it holds no statements, as with 8.0.0’s three patches, a patch number behind is a note rather than a failure; if it does, the doctor still says to run sql_patch.php (openemr-reference 0.5.3, and the copy in #916).