Why removing OpenEMR setup and admin scripts is the first hardening step
Removing or blocking the setup and admin scripts is the first hardening step on an OpenEMR server because these files are built to change the system, and the Securing OpenEMR guide tells administrators to remove setup.php and other admin scripts after installation. Installer and maintenance pages are meant to run once, under supervision. If they remain reachable from the web, anyone who can request the URL may be able to reach functions that were never intended for ordinary users. This applies to a fresh install you built yourself, and it applies just as much to a server you inherited from a previous administrator, where nobody on your current team may know which scripts were left in place.
Teams usually need this work in four situations: a new installation that went live before hardening began, an inherited server whose history is unclear, a Docker image or container build where setup files were copied into the web root along with the application, and a multisite deployment where each site directory may carry its own copy of the files. Treat each of these as a separate check, because a clean primary site does not prove that every site on the same host is clean. Confirm with your own environment which of these apply before you change anything, and record the web root path and the site directories you find.
OpenEMR is licensed under the GNU GPL v3.0, so your organization can inspect the code that these scripts run and plan changes around it. Recent releases require PHP 8.3 or later, so the PHP version on your server also shapes how you test and where you can safely make changes. Confirm your PHP version and the upgrade path for your release line before you start, because removing scripts from an outdated install can leave you with a server that is both exposed and unsupported. The rest of this topic covers which files to remove, how to block access where removal is not possible, and how to verify the result from outside the server.
Which OpenEMR scripts to remove, block or keep
Installer, upgrade and maintenance scripts in an OpenEMR web root each need one of three treatments: remove after install, block at the web server, or keep because the application still calls them. The exact file list changes between versions, so confirm every entry against your installed release and the Securing OpenEMR guide before you act on this grouping.
Installer scripts to remove
setup.php is the first-run installer that creates the clinical database and the initial administrator. Once the installation is complete, the file has no reason to exist on a production server. Confirm that the setup.php path is absent from the web root after install, and record the removal in your change log so a later redeploy or Docker rebuild does not quietly restore it.
Admin and maintenance scripts to block
admin.php and similar maintenance entry points are used by administrators during setup or repair work. Deleting them can break a support procedure your team still relies on, so the safer default is to deny direct web requests to these paths at the web server while leaving the files in place. Test that a direct request returns a denial and that normal logins and screens still work.
Database upgrade scripts
sql_upgrade.php applies schema changes between releases and must be run during a planned upgrade, not left reachable on a live system. Treat it as a removal or block candidate after each upgrade completes, and confirm the upgrade procedure for your exact target version in the release notes. Keep a dated record of which upgrade was applied and by whom.
Scripts the application needs
Some PHP entry points under the web root are called by normal clinical, portal or API traffic, such as login, the patient portal and FHIR endpoints. Blocking or deleting these breaks the application, so do not add them to a deny list based on their name alone. Build the block list from a traced inventory of your installed version, then confirm each kept file with a functional test of the screens it serves.
Multisite and document directories
In a multisite deployment, each site directory under sites/ can carry its own installer or configuration artifacts, and the documents directory under sites/*/documents must not be served directly. Check every site, not only the default one, and confirm that direct web access to those document paths is denied as the Securing OpenEMR guide advises.
Verifying the final file list
Make verification part of each install, upgrade and container rebuild. Compare the deployed web root against the list you approved for your version, request each blocked path from outside the network and expect a refusal, and keep the result with your change record. Any file that appears after a patch or image update goes back through the same review before it is accepted.
How the install method changes the removal work
On a bare-metal server or virtual machine, OpenEMR is an ordinary tree of files in a web root your team or installer placed there, so setup and admin scripts are plain files you can find and delete. The work is a filesystem inventory plus a check of the web server configuration. Installs that were built by hand or patched over several years often contain copies or leftovers that the default layout does not explain, so start by listing what is actually present rather than assuming the standard set.
- Search the whole deployed tree: look for setup.php, admin.php and sql_upgrade.php in every subdirectory, including copies left by manual edits or old upgrades.
- Confirm the served directory: identify the directory the web server actually serves, and treat any copy inside it as exposed even if a duplicate exists elsewhere.
- Record owner, group and mode: capture file metadata before changes so you can restore it if a dependent process expects the file.
- Review web server rules: look for alias or location blocks that map directories directly, since a configuration change can expose files even after the scripts are gone.
- Archive before deleting: move removed files to a secure location outside the web root so you can roll back and document what was changed.
After removal, request each script path from outside the network and confirm that the web server returns a denial or not-found response.
Packaged installs, including the Ubuntu installer and the AWS packages, place code, configuration and document storage in the layout that the package defines, which may differ from a manual install. The supplied material does not give those paths for each package, so confirm the install location in the package documentation before you move anything. Removing files from a package-managed tree can also conflict with the package manager, which may restore files on update or report them as modified.
- Confirm the documented paths: compare the install locations in the installer or AWS package documentation with what is on disk for your version.
- Check package ownership: determine whether the package manager tracks the scripts, since a later package update may reinstall or flag them.
- Read the upgrade procedure: find out whether the vendor's upgrade steps recreate setup or admin scripts, which would undo a manual removal.
- Look at the image build: if you launch from a prebuilt image, check whether the scripts were removed during the build and whether your image pipeline reapplies them.
- Track instance replacement: a removal applied only to a running instance is lost when the instance is rebuilt, so record it in your build or configuration management process.
Before you rely on a removal, confirm in the package documentation that deleting each script is supported, then verify the result on a freshly built instance from the same image.
In a Docker deployment, the scripts are part of the image, so deleting a file inside a running container is a temporary change. The file returns when a new container is created from the same image. Removal has to happen in the image build, or in the startup logic if the container copies or regenerates files when it starts. The project offers Docker deployment options, so confirm how the image you use is built and what its entrypoint does in the image documentation for your version.
- Treat container deletes as temporary: a removal inside a live container disappears on the next container creation, so it is useful only for testing.
- Change the build instead: remove the scripts in the Dockerfile or a build step after the application code is copied, then rebuild and tag the image.
- Inspect the entrypoint: startup scripts may copy files back into the web root or regenerate setup content, so confirm the entrypoint does not restore removed scripts.
- Check volume mounts: persistent volumes that hold site configuration or documents must not mount an older copy of the scripted paths over the cleaned image.
- Record the image digest: test and verify the final image, including the removed paths, and keep the digest that passed.
Run a request test against a container started from the final image, and confirm each path is blocked there, not only in the source repository.
Multisite installs keep per-site configuration and documents in directories under sites, so each site directory is a separate place where sensitive files can sit. Shared scripts usually live once at the top of the codebase, but site folders can contain their own configuration and document storage. The supplied guidance says to block direct web access to sites/*/documents, and that rule has to be applied to every site, not only the first one. Confirm the multisite layout for your version in its documentation before you change files.
- Enumerate every site directory: list each folder under sites so that no site is skipped when shared scripts are removed.
- Separate shared and per-site items: removing top-level scripts covers the codebase, but per-site configuration and documents need their own review.
- Block documents in every site: apply the rule that blocks direct access to the documents directory to each site path, then test each one.
- Sequence removal after upgrades: if a site has not finished an upgrade, it may still need upgrade scripts, so remove them only after all sites are upgraded.
- Test each hostname: sites on the same server may be reached through different hostnames, so test every site URL on its own.
Record the site list and the test result for each site, and keep that record with your change documentation.
How multisite and upgrades affect script removal
Removing setup and admin scripts is not a one-time step you can forget after go-live, because the upgrade path itself may depend on some of them. Before you delete or block sql_upgrade.php and related scripts, confirm in the release notes for each target version whether the upgrade procedure still calls them, and whether the project has replaced them with a different method. Read the notes for every release between your current version and the target, not just the final one. The OpenEMR releases page is the place to start, and each release's notes should be compared against your own runbook. If an upgrade needs a script, plan to unblock it for the upgrade window only and re-block it afterward, with the change recorded in your change log.
Multisite installs add a second layer. Per-site configuration and documents live under sites/*, so each site directory has its own setup.php and admin scripts to block, and a rule written for one site will not cover the others. Build the blocking rule so it matches every directory under sites/ and test each site by name, including sites that were created and then left unused. Also confirm that any new site you add later inherits the same rule, since the web server configuration is usually written once and new site folders can slip past a rule that was never updated. Confirm the exact layout of your version with the OpenEMR multisite documentation before you write the rule.
Upgrades can also restore files you removed. Re-deploying the application code, replacing a Docker image, or restoring from a file-level backup can bring back scripts and reset web server rules, so treat verification as a recurring task rather than a one-time check. Schedule a re-verification window after every upgrade, and after any restore or rebuild, and run the same requests you used at go-live against each site, expecting a blocked response. Keep the results with the change record. If your upgrade process is handled by a partner or by your own team, confirm in writing who owns re-running these checks and who signs off that the blocking rules are still in place.
How to remove and block OpenEMR admin scripts step by step
This sequence inventories exposed OpenEMR scripts, backs up the server, removes installer scripts, blocks web access to admin and upgrade paths and documents storage, and confirms each change with a request test.
Inventory the web root and site directories
The administrator lists every script and directory under the OpenEMR web root, including the sites directory and each site folder under it. Note which files are installer or maintenance scripts, such as setup.php, admin.php and sql_upgrade.php, and which are required for normal sign-in, the patient portal and API routes. Check the copy you deployed against the file list in the Securing OpenEMR guide and the release notes for your version, since script names can change between releases. Done when you have a written list that separates removable scripts from routes the application needs.
Back up the current server state
Before changing any file, the administrator takes a copy of the code tree, the sites directory with its configuration and documents, and the database, and stores the copy outside the web root. Record the OpenEMR version and the web server configuration file in the same backup set so a rollback is possible. Confirm the backup can be restored by checking that the archive lists the expected files and that the database dump is complete. Done when the backup is stored, its checksum is recorded and someone other than the person making the change can locate it.
Remove installer and setup scripts
The administrator deletes or moves setup.php and other installer scripts out of the web root, after confirming the installation is complete and no upgrade is in progress. Keep a copy in the backup rather than leaving it in place with restricted access. If a future upgrade needs one of these scripts, restore it from the release package for that version at that time. Done when a directory listing of the web root no longer shows the removed files and the application still loads its sign-in page.
Block direct web access to admin and upgrade scripts
The administrator adds deny rules at the web server, such as location or file match blocks, for the remaining admin and upgrade script paths, returning a 403 or 404 response. Rules should match the script paths on the server and should not block the routes the sign-in flow, portal or API depend on. Confirm the exact configuration keys and syntax against your web server documentation and test the configuration before reloading. Done when the configuration test passes and the server has reloaded without errors.
Block web access to the documents directory
The administrator adds a rule that denies direct HTTP requests to sites/*/documents so that stored patient files can be reached only through the application. Patient documents should not be fetchable by guessing a path. The control is complete when a request for a known document path returns a denied or not-found response and the application still serves documents to authorized users. Encryption and key handling for these files are covered in a separate topic.
Verify each blocked path from outside the network
Using an unauthenticated client from outside the internal network, the administrator requests each removed or blocked script path and the sites/*/documents path, and records the status code and response size for each. Expect a denied, forbidden or not-found response for every blocked path. Then request the sign-in page, a normal application route and an API route to confirm they still respond as expected. Done when the recorded results match the expected list for every path and the test is saved with the change record.
Re-verify after each change and before upgrades
Repeat the request tests after every configuration change, web server update, OpenEMR upgrade or restore from backup, because a reinstalled file or a new release can recreate an exposed script. Add the same checks to the upgrade runbook so that the upgrade process does not leave installer scripts in place. Store the results with the change ticket so a reviewer can see the state over time. Done when the post-upgrade test run matches the baseline and any new script found in the web root is added to the list from the first step.
How a request to an admin script should be stopped
The diagram starts with a browser request crossing the public network and reaching the TLS listener on port 443, which is the only port the Securing OpenEMR guide suggests opening. The web server rule set then decides the path: a clinical route such as the login or patient pages passes to the OpenEMR application, while a request for setup.php, admin.php or sql_upgrade.php should be denied before PHP runs. Check that the denial happens at the web server, not only inside the application, and test it from outside the trust boundary.
Clinical routes reach the application while installer and admin paths are denied at the web server.
Removal, blocking and monitoring options compared
This table compares four ways to close off setup.php, admin.php, sql_upgrade.php and similar scripts: deleting them, denying their paths in the web server, restricting them by source network, and detecting re-creation with file integrity checks. Read each row for when the option fits, what it breaks if misapplied, and what to confirm before relying on it. Most servers need more than one of these, and the main takeaway is that deletion is the strongest control but must be paired with a plan for upgrades and multisite.
| Option | When it fits | What it breaks if misapplied | What to confirm |
|---|---|---|---|
| Delete setup and admin scripts | After a fresh install is complete and the site is stable, as the Securing OpenEMR guide advises for setup.php and other admin scripts | Upgrade or multisite steps that call a script, or a later procedure that expects it to exist, fail until the file is restored from the matching release | Which scripts your exact version ships and which ones your upgrade path or multisite tooling calls, confirmed against the release notes for your version |
| Deny paths in the web server configuration | When scripts must stay on disk for upgrades or a maintenance window, or as a second layer after deletion | Admin workflows that depend on those paths, and any rule that is too broad and blocks legitimate application pages | Exact path patterns, whether rules apply per site directory in a multisite install, and a test of every blocked path with the expected HTTP response |
| Restrict by source network or admin host | When an administrator must reach a script occasionally from a fixed management network or jump host | Remote or temporary administrators, VPN users and load balancer health checks if the source address is not what you expected behind a proxy | Whether the web server sees the real client address through your proxy setup, and who approves the allowed networks and how changes are logged |
| Detect re-creation with file integrity checks | To catch a script being restored after an upgrade, a restore from backup, or an unauthorized change | Alert fatigue if every upgrade triggers changes, and missed events if the monitor only covers the web root and not every site directory | Which paths the monitor watches, who receives alerts, and whether your upgrade runbook includes an expected-change review step |
How to verify the scripts are actually blocked
Removing a script from the file system is not the same as blocking it. Verification means testing the URLs an outsider can reach, testing what the application host itself exposes, and repeating the same checks for every site, after every upgrade and rebuild. Keep the results as dated evidence, because the assessment will ask for it.
External checks from outside the network
Request each script path, including setup.php, admin.php and sql_upgrade.php, from a host outside your network, over HTTPS, using the same hostname patients and staff use. Record the HTTP status, response size and any redirect to a login page. A 404 or a block from your web application firewall is a pass. A 200 response, even one that shows only a login form, is a finding. Run the same requests after any change to the load balancer, CDN or proxy rules, since those layers can expose paths the web server would have blocked.
Internal checks from the application host
Run the same requests from the application host or a machine on the same subnet as the web server, so you can see whether a path is reachable from inside your network. Confirm the script files are absent with a directory listing of the web root, and confirm that the web server configuration denies the paths even if a file is restored. Check the web server error log after each request to confirm the request was rejected rather than handled.
Testing each site in multisite installs
In a multisite deployment, each site directory can carry its own setup and admin state, so a check against the default site does not prove the others are closed. Build a list of every site identifier under the sites directory and request the script paths against each hostname that maps to it. Confirm that the site-specific configuration files are not reachable by the web server either. Keep the list current when sites are added or retired.
Checking after upgrades and image rebuilds
Upgrades and container image rebuilds can copy the setup and upgrade scripts back into the web root, and an upgrade may reset a web server rule you added by hand. Put the same external and internal checks into the upgrade runbook, and run them before the change is closed. If you deploy with Docker, check the image you actually run, not only the source tree, and confirm the rule survives a fresh container start. Repeat the checks after each patch release from the project.
Recording evidence for an assessment
Store each check as a dated record: the URL tested, the source host, the command or tool used, the response status, the configuration version and the person who ran it. Keep the web server configuration that blocks the paths under version control so you can show when it changed. This evidence supports your own risk assessment. DeployOpen prepares systems and evidence for compliance assessments, but it does not issue audit reports or attestations. Independent auditors and certification bodies make those determinations, and verification remains your control to run and own.
Securing OpenEMR guideQuestions teams ask before removing OpenEMR setup scripts
How much effort does removing setup scripts from a single-site OpenEMR take?
For a single site on one host, the removal itself is a small change: delete or block setup.php and the other admin scripts, then confirm they return a refusal. The effort is in the surrounding work: confirming the install is finished, checking which scripts exist in your version, updating the web server rules, and testing. No public source gives a duration for this, so ask a partner or your own engineers to estimate it from a written inventory of your server. The effort grows with each factor below, so the quote should name them explicitly.
What makes the removal work take longer on a real deployment?
Four factors change the effort most:
- Multisite: each site has its own
sites/directory and its own setup context, so every site must be checked separately. - Docker: scripts live inside the container image, so the fix is applied in the image, the web server configuration or the orchestration layer, not by deleting files on a host.
- Custom modules: custom code may call admin or upgrade scripts, so removing them can break a workflow that nobody documented.
- Upgrade schedule: each new release can reintroduce or rename scripts, so the block must be reapplied and retested after every upgrade.
Can our own team remove OpenEMR setup scripts without a partner?
Yes, if your team has Linux administration and web server experience and can make the change in a controlled way. The Securing OpenEMR guide lists removing setup.php and other admin scripts after installation as a baseline step, so the task is well documented. A partner adds value when you run multisite, Docker or custom modules, need evidence for an assessment, or lack a test instance. Whichever route you choose, keep a written list of the files removed and the tests run.
What do we need to provide before the work starts?
Plan for four inputs:
- Administrative access to the web server, OpenEMR files or Docker image, and any orchestration layer, with the rights to change configuration.
- A change window agreed with clinical and operations leads, since a misconfigured rule can block users or break a page.
- A test instance built from the same OpenEMR version and configuration as production, so changes can be checked without touching patient data.
- A current list of installed modules, sites and deployment method.
Ask for these inputs in the written scope so both sides know what is needed before the start date.
How often do we need to verify that setup scripts are still blocked?
Verify after every change that could affect the web server or files: each OpenEMR upgrade, each Docker image rebuild, each web server or PHP update, and each time a site is added in a multisite setup. The guide's baseline is to remove the scripts after installation, but upgrades and rebuilds can restore them. Many teams also add a periodic check, for example during monitoring reviews or after security advisories. Set the interval in your change policy rather than relying on memory.
How do we confirm the scripts are blocked and not just hidden?
Request each script by its full URL from a browser and from an unauthenticated client, and confirm the server returns a refusal or a not-found response rather than a page that runs. Check that the file is absent or unreachable on disk, and that the same test passes on every site and on the container image. Record the date, the tester, the OpenEMR version and the URLs tested. A written test record is what most assessors will ask to see.
Does removing setup scripts satisfy HIPAA or other compliance requirements by itself?
No. Removing setup scripts is one technical control among many. The HIPAA Security Rule (45 CFR Part 164 Subpart C) requires covered entities and business associates to implement safeguards for ePHI, and the risk analysis determines which controls you need. There is no HIPAA certification, so no one can certify that this change alone makes you compliant. Independent auditors and certification bodies issue reports, not DeployOpen, and DeployOpen prepares the controls and evidence for those reviews.
Official OpenEMR sources for script removal
The first place to check before deleting anything is the Securing OpenEMR guide. It is the project's own statement of the hardening baseline, and it directly calls for removing setup.php and the other admin scripts once installation is finished, alongside allowing only HTTPS, considering exposure of port 443 alone, and blocking direct web access to sites/*/documents. Read it as the reference for what should be closed. It does not give you a full file list for every release, so treat it as the starting point for your own inventory of the web root rather than a complete checklist.
The second source is the OpenEMR releases page, which records what changed in each version and where security fixes landed. Before you remove or move any script, read the release notes for the version you are running and the version you plan to upgrade to. Script names, upgrade entry points and multisite behavior can differ between releases, and a file you delete on one version may be needed for a migration step on another. Confirm the exact script list for your version in the release notes and in your own test environment, since the guide and release notes are the authoritative sources for the file set, not this page.
Do not change files on a production server until you have checked the version-specific notes against your own deployment, including whether you use Docker, the Ubuntu installer or multisite. Record which files you removed, keep a copy of the original tree, and note which upgrade steps depend on them so the next patch window does not surprise your team. Once the change is made, confirm each removed path returns an error or is blocked from the web, rather than assuming the deletion was enough.
How DeployOpen scopes and verifies OpenEMR hardening
DeployOpen approaches removing OpenEMR setup and admin scripts as a bounded piece of hardening inside the client's own infrastructure. We agree the exposed files, the verification method and the evidence in writing before work starts, then test the result from outside the server and hand over a record the client's own team can repeat after every upgrade.
How we scope
- Inventory every setup, admin and upgrade script on the web root, including copies in multisite site directories.
- Confirm the OpenEMR version, PHP version, Docker or bare-metal layout and where the web server is configured.
- Agree in writing which scripts are removed, which are blocked, and who owns the change window.
How we build
- Remove setup.php, admin.php and sql_upgrade.php where the installation no longer needs them, and record the file hashes before and after.
- Block direct web requests to these paths at the web server, and confirm the rule holds when the same files appear in a site directory.
- Test each block from an unauthenticated client and from a logged-in user to confirm the response and the access log entry.
How we hand over
- Deliver a written configuration record showing each removed file, each block rule and the verification results.
- Document the steps to reinstate a script safely during a future upgrade, then remove it again afterwards.
- Walk your operations and security staff through the check so they can repeat it after every OpenEMR release.
How we support
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
- Ongoing support, upgrades and continuous testing are available as retainers.
- Ask for a quote based on the written scope, including who retests the block rules after each upgrade and security release.

