Automate certificate renewal on Apache HTTP Server

Apache can renew its own certificates with the mod_md module over ACME. Shorter public certificate lifetimes make that renewal, plus reloads and monitoring, the job that has to run without anyone touching it.

On this page

How Apache can automate certificate renewal and what shorter lifetimes change

Apache HTTP Server can automate both issuance and renewal of certificates through the mod_md module, which talks to a certificate authority over ACME. The module is marked Experimental in the Apache 2.4 documentation, has been available since 2.4.30, and requires mod_watchdog. The default certificate authority is Let's Encrypt. Public certificate lifetimes are now shrinking in steps: 200 days from 15 March 2026, 100 days from 15 March 2027 and 47 days from 15 March 2029, according to the CA/Browser Forum Baseline Requirements. At 47 days, renewal stops being an occasional task and becomes a recurring, unattended job that has to work every time.

The people who need to act are sysadmins running Apache virtual hosts, and anyone whose renewals still depend on someone copying files and reloading the server by hand. For each managed domain, confirm that MDCertificateAgreement has been set to accepted, since mod_md cannot accept the certificate authority's terms on your behalf. Check that the names covered by a managed domain match the ServerName and ServerAlias values you expect, because in the default auto mode the MDomain directive adds those from matching VirtualHosts. Confirm that MDRenewMode is not set to manual, which would prevent renewal from being attempted at all.

Shorter lifetimes change what a failed renewal costs. While no certificate is available for a managed domain, requests for that domain receive 503 Service Unavailable, while other hosts keep working. Renewed certificates are staged in the store directory named by MDStoreDir and only become active after a server restart or reload. The module's job log advises a graceful restart after a successful renewal, so plan that reload into your change process. Set MDMessageCmd to run a script on the expiring and errored events, so a failure reaches someone before the certificate lapses. Let's Encrypt advises monitoring that alerts you when a certificate has not renewed when expected, and does not recommend manual renewal. Review the renewal settings with your certificate authority's current documentation, and confirm the behavior on the Apache version you run.

Which lifetime schedule applies and what each step means for Apache

This table lists each published lifetime step from the CA/Browser Forum and Let's Encrypt, with the date it takes effect and what it means for renewals per year and manual work on an Apache host running mod_md. Read the rows in date order: each step shortens validity and reuse, so the renewal count rises and automation becomes the only practical option.

Schedule stepEffective dateCertificate lifetime and reuseEffect on Apache renewals and manual work
CA/B Forum maximum (first step)15 March 2026200-day maximum validity; domain validation reuse of 200 daysRenewals roughly every 200 days at most. mod_md handles this automatically, but confirm MDCertificateAgreement is accepted and MDRenewMode is not set to manual.
Let's Encrypt tlsserver profile (opt-in)13 May 202645-day certificates, opt-in through the tlsserver ACME profileOnly applies if you select the profile. Confirm with your ACME client whether mod_md can request this profile through its settings before relying on it.
CA/B Forum second step15 March 2027100-day maximum validity; domain validation reuse of 100 daysRenewals roughly every 100 days at most, about twice as many as the 200-day step. Manual renewal becomes impractical, so check that renewal logging and MDMessageCmd alerts reach someone.
Let's Encrypt default classic profile10 February 202764-day certificates; authorization reuse of 10 daysDefault certificates renew about every 64 days or sooner. Hardcoded renewal schedules such as 60-day cron jobs will not match; rely on mod_md's MDRenewWindow and ARI.
Let's Encrypt classic profile at 45 days16 February 202845-day certificates; authorization reuse of 7 hoursRenewals roughly every 45 days. Let's Encrypt says renewing at a hardcoded 60-day interval will no longer be sufficient, so confirm the renewal window and monitoring cover this lifetime.
CA/B Forum final step15 March 202947-day maximum validity; domain validation reuse of 10 daysRenewals roughly every 47 days at most with validation reuse of 10 days. Confirm that mod_md's challenge setup can complete within the reuse period on your hosts.

How mod_md issues certificates and how Apache picks them up

mod_md groups the names on your VirtualHosts into managed domains, and each managed domain gets one certificate. An MDomain directive lists DNS names that share a certificate. In the default auto mode, mod_md adds the ServerName and ServerAlias values of matching VirtualHosts to that group, so a new alias on a VirtualHost becomes part of the managed domain without a separate edit to the certificate configuration. Before any of this works, MDCertificateAgreement must be set to accepted, which confirms that you accept the certificate authority's terms of service. The Apache documentation states that mod_md cannot agree on your behalf, so a server without this line will not get a certificate. Confirm the agreement setting first, because the rest of the setup depends on it.

Renewed certificates are written to MDStoreDir, and Apache does not serve them until the next restart or reload. The Apache job log advises a graceful restart after a successful renewal, so the renewal process and the reload process are separate steps you need to plan for. Check that the reload happens on a schedule your team controls, and do not assume a renewal alone changes what clients see. If you run several nodes on a shared file system, MDStoreLocks (available from 2.4.55) locks the store during startup and reload, and a node that cannot obtain the lock may stay on the previous certificate. Test this behavior before you rely on it in a cluster.

In auto mode, mod_md checks at least every 12 hours, and after errors it retries and backs off to a maximum of hourly checks. While no certificate is available for a managed domain, requests for that domain receive 503 Service Unavailable, but other hosts on the same server keep working. Plan for this when you first add a managed domain, because a new name stays unavailable until issuance succeeds. Set MDMessageCmd so that expiring and errored events reach your monitoring, since the module does not alert you on its own. Confirm the exact event names and the MDWarnWindow default in the mod_md documentation for your Apache version.

Which automation options Apache supports and what each needs

The mod_md module manages certificates inside Apache itself. It provisions certificates over the ACME protocol (RFC 8555), with Let's Encrypt as the default certificate authority, and it renews them without any separate client process. The module is marked Experimental in the Apache HTTP Server 2.4 documentation and has been available since 2.4.30. Treat that status as a planning input: confirm it is acceptable for your change control and support model before you depend on it for production names.

  • Required module: mod_md requires mod_watchdog. Confirm both are loaded in the modules your build exposes, since the renewal checks run through the watchdog.
  • Domain grouping: MDomain takes the form MDomain dns-name [other-dns-name...] [auto|manual] and places several names under one managed domain with a single certificate. In the default auto mode it adds the ServerName and ServerAlias values of matching VirtualHosts automatically, which is convenient but means a new alias can change the certificate request.
  • Terms and CA selection: MDCertificateAgreement accepted confirms acceptance of the CA's terms of service, and the documentation states that mod_md cannot agree on your behalf. MDCertificateAuthority defaults to letsencrypt and accepts buypass as a shortcut. Several URLs can be listed, and with several URLs failover happens after MDRetryFailover consecutive errors, which defaults to 13.
  • Wildcards need dns-01: The default challenge order is tls-alpn-01 http-01 dns-01. The dns-01 challenge needs MDChallengeDns01 configured and is the only option for wildcard certificates. The tls-alpn-01 challenge needs Protocols h2 http/1.1 acme-tls/1.
  • Staged renewals: Renewed certificates are staged in MDStoreDir and become active on the next server restart or reload. The documentation advises a graceful restart after a successful renewal, so plan that step into your operations.

Check the mod_md page for the Apache version you run, and confirm the renewal window and event hooks (MDMessageCmd) match the monitoring you already have.

Set up mod_md renewal for Apache virtual hosts in order

This sequence enables mod_md so Apache requests, stores and renews ACME certificates for its virtual hosts without manual steps. Each step adds one setting or check, so the result is a configuration that renews on schedule and reports failures. The steps assume Apache 2.4.30 or later, and mod_md is marked Experimental in the Apache documentation.

  1. Load mod_watchdog and mod_md

    Add LoadModule lines for mod_watchdog and mod_md to the main Apache configuration or the included module files, since mod_md requires mod_watchdog to run its renewal checks. Confirm the module paths match your installation, because the file names vary by distribution and build. Then run apachectl configtest and confirm it reports Syntax OK. This step is done when the configuration test passes and both modules appear in the loaded module list, which you can check with apachectl -M.

  2. Accept the certificate authority terms

    Set MDCertificateAgreement to accepted in the server configuration. This confirms you accept the terms of service of the certificate authority, which defaults to Let's Encrypt. mod_md cannot accept those terms on your behalf, so the server operator must make this choice deliberately. Confirm the terms that apply to your chosen authority before you set this value. The step is done when the configuration test passes with the setting in place.

  3. Define the managed domains

    Add an MDomain directive that lists the DNS names for each certificate. In the default auto mode, mod_md adds the ServerName and ServerAlias values of matching VirtualHosts, so the directive can stay short. Use manual mode when you need to list names explicitly. Each MDomain groups names into one managed domain with a single certificate, so decide up front which hostnames share a certificate. The step is done when each managed domain appears in the mod_md status output or the server log after a reload.

  4. Set protocols for tls-alpn-01 validation

    If you use the tls-alpn-01 challenge, add h2, http/1.1 and acme-tls/1 to the Protocols setting for the relevant virtual hosts. The default challenge order tries tls-alpn-01 first, so this setting matters even when you plan to use http-01. Check that the virtual host can serve these protocols before relying on the challenge. The step is done when the configuration test passes and the virtual host lists acme-tls/1 among its enabled protocols.

  5. Configure dns-01 challenges for wildcards

    If you need a wildcard certificate, or you validate with dns-01, set MDChallengeDns01 to the module that handles DNS records for your domain. The dns-01 challenge is the only option the documentation lists for wildcard certificates, so this setting is required for wildcards. Confirm which DNS provider module your environment uses and check its documentation for the exact setup. The step is done when a test issuance for a wildcard name reaches the challenge-setup event without errors.

  6. Set the certificate store location

    Set MDStoreDir to a directory that Apache can write to and that persists across restarts. Renewed certificates are staged here and become active on the next server restart or reload, so the location needs to be stable and backed up. On clusters that share a file system, review MDStoreLocks, which is available from 2.4.55. The step is done when the directory exists, has correct ownership for the Apache user, and receives certificate files after the first issuance.

  7. Adjust the renewal window or ARI handling

    Review MDRenewWindow, which defaults to 33 percent of remaining validity, and MDRenewViaARI, which defaults to on and implements ACME Renewal Information (RFC 9773). Leave the defaults unless you have a reason to change them, and note that ARI triggers renewals in addition to the window. Let's Encrypt recommends ARI for clients, so keeping it enabled is the usual choice. The step is done when the effective values appear in your configuration and match what your monitoring expects.

  8. Route alerts with MDMessageCmd

    Set MDMessageCmd to a script that receives the event name and managed domain name. Events include renewed, installed, expiring, errored, renewing and challenge-setup. The expiring event fires at MDWarnWindow, which defaults to 10 percent, and errored is reported at most once per hour. Test the script by forcing an event in a non-production environment, and confirm the alert reaches the team that owns the certificate. The step is done when a test event produces the expected notification.

  9. Restart or reload and check the job log

    Run a graceful reload with apachectl graceful so renewed certificates become active. The mod_md job log advises a graceful restart after a successful renewal, so make this part of the renewal routine. Then check the job log and the server error log for renewed or errored events. While no certificate is available, requests for a managed domain receive 503 Service Unavailable, so verify each domain serves a valid certificate. The step is done when the job log shows a successful status for every managed domain and each domain presents a valid certificate.

What must be in place before mod_md can renew certificates

mod_md renews certificates on its own schedule, but only when the server, the module and the network path to the challenge are all ready. Confirm each prerequisite below before you rely on automated renewal, because a missing piece can leave a managed domain without a valid certificate.

Apache 2.4.30 or later with mod_watchdog

mod_md has been available since Apache HTTP Server 2.4.30 and requires mod_watchdog to run its periodic checks. Confirm the version your build reports and that mod_watchdog is loaded before you configure any managed domain. Because version support depends on how Apache was packaged, check the version and module list against your own build rather than assuming them from the distribution name.

mod_md docs

mod_md marked experimental

The Apache documentation marks mod_md as Experimental. Treat it as a module whose behavior may change between releases, and test your renewal path in a staging environment before you rely on it in production. Record the Apache version you tested so you can repeat the test after an upgrade.

mod_md docs

Reachability for the chosen challenge

The challenge you choose sets what the network must allow. tls-alpn-01 is the default order's first option and needs port 443 reachable from the CA, with Protocols set to h2 http/1.1 acme-tls/1. http-01 needs the CA to reach port 80. dns-01, set through MDChallengeDns01, needs DNS write access and is the only option for wildcard certificates. Confirm the challenge path from outside your network, not only from inside it.

Write access to MDStoreDir

mod_md stages renewed certificates in MDStoreDir, and they become active only after the next server restart or reload. The Apache user must be able to write to this directory, and the directory should be backed up and monitored, because a failed write leaves the old certificate in place. Confirm the directory's owner and permissions match the user Apache runs as.

Activates new certificates
Restart or reload

MDStoreLocks for shared file systems

Clusters that share a file system for the certificate store need MDStoreLocks, which is available from Apache 2.4.55. It locks the store during startup and reload, with a default lock timeout of 5 seconds. If a node cannot obtain the lock, it may keep using its previous certificate, so check the Apache version on every node and confirm the lock behavior in your own test cluster.

Confirm versions against your build

The version and feature details above come from the Apache documentation, which can change between releases. Before you plan a rollout, run your own Apache build and confirm which version, modules and configuration directives it actually provides. Keep that record with your change tickets so the next upgrade can be checked against it.

mod_md docs

How to confirm Apache renewals keep happening

A renewal setup that worked at go-live can stop working without anyone noticing, so the goal is to confirm renewals are happening on a schedule and to alert when they are not. mod_md can report its progress through MDMessageCmd, a directive that runs a command with the event name and the managed domain name as arguments. The documented events are renewed, installed, expiring, errored, renewing, challenge-setup, ocsp-renewed and ocsp-errored. The expiring event fires at MDWarnWindow, which defaults to 10%, and errored is reported at most once per hour. Point the command at your alerting system so that errored and an absence of renewed events for a domain reach a person. Confirm the exact arguments your command receives against the Apache mod_md documentation for your version, since the event list may change between releases.

The job log is the second place to check. The Apache mod_md documentation describes it as the record of each renewal attempt and its outcome, and it advises a graceful server restart after a successful renewal, because the new certificate is staged in MDStoreDir and becomes active only on restart or reload. A renewal that succeeds but is never reloaded still leaves the old certificate in service, so monitor for the renewed event and for a restart or reload that follows it. Let's Encrypt recommends monitoring that alerts you when certificates are not renewed when expected, and does not recommend renewing by hand, because shorter lifetimes would require manual renewal far more often. Build the alert from the expected renewal window, not from the time of the last manual check.

Auditors and customers may ask you to show that certificates are renewed automatically and that failures are caught. Keep the evidence they are likely to request: the job log for each managed domain, the MDMessageCmd event records that your alerting system received, the certificate issuance and renewal history from the CA, and the records of the reload or restart that activated each certificate. Keep these for the period your own policy and any contract requires, and confirm that retention period with your compliance owner rather than assuming it. Where a renewal failed and was fixed, keep the record of the failure and the fix alongside the successful renewal, so the history is complete. If you cannot reproduce a renewal history from your logs for a given domain, treat that as a gap to close before an assessment, not after one.

Questions people ask about automating Apache certificates

Does Apache HTTP Server support ACME for certificate issuance?

Yes, through the mod_md module, but the Apache HTTP Server 2.4 documentation marks mod_md as Experimental. It has been available since version 2.4.30 and requires mod_watchdog. mod_md provisions certificates over ACME as defined in RFC 8555, with Let's Encrypt as the default certificate authority. Because the module is marked experimental, confirm its behavior against the mod_md documentation for the exact Apache version you run before relying on it in production, and plan a fallback such as a standalone ACME client if your standards require a non-experimental component.

Should I use mod_md or Certbot's Apache plugin to automate renewal?

The choice depends on whether you want Apache to manage certificates itself or prefer an external client. mod_md runs inside Apache, groups names into managed domains with the MDomain directive, and handles renewal and reload timing in the server. Certbot's Apache plugin is enabled with --apache and both obtains and installs certificates on Debian, Fedora, SUSE, Gentoo, CentOS and Darwin based systems. Certbot is widely used and well documented, while mod_md keeps everything in Apache configuration. Compare the two against your operating system, your monitoring setup and your team's experience before deciding.

How often does Apache renew certificates under mod_md?

mod_md renews a certificate when its remaining validity falls below the MDRenewWindow setting, which defaults to 33 percent of the lifetime. The window also accepts an absolute duration such as 21d. The documentation says this is about 30 days before expiry for 90-day certificates. Renewal is also triggered by ACME Renewal Information when MDRenewViaARI is on, which is the default. In auto mode, mod_md checks at least every 12 hours. Because the public lifetime is shortening, confirm the current defaults in the mod_md documentation for your version and check how renewals behave as certificate lifetimes change.

What happens when a certificate renewal fails in Apache?

mod_md retries after errors, starting with a delay of some seconds and backing off until checks run at most hourly. If MDCertificateAuthority lists several URLs, mod_md fails over to the next authority after MDRetryFailover consecutive errors, which defaults to 13. While no valid certificate is available, requests for a managed domain receive 503 Service Unavailable, but other hosts keep working. The MDMessageCmd directive can run a command for events such as errored, which is reported at most once per hour, and expiring, which fires at the MDWarnWindow default of 10 percent. Set up alerts on these events so a failed renewal is noticed before expiry.

Can Apache automate wildcard certificates?

Only through the dns-01 challenge. The default challenge order in mod_md is tls-alpn-01, http-01 and dns-01, and dns-01 is the only option for wildcard certificates. dns-01 requires the MDChallengeDns01 directive, which tells mod_md how to publish the challenge record. Your DNS provider and access method determine how practical this is. Confirm the DNS setup and credentials handling against the mod_md documentation before you configure a wildcard managed domain.

Does a new certificate take effect immediately after renewal in Apache?

No. mod_md stages renewed certificates in the directory set by MDStoreDir, and they become active on the next server restart or reload. The mod_md job log advises that a graceful server restart is recommended after a successful renewal. Plan your reload process so that renewed certificates are picked up without an outage, and check that your monitoring confirms the served certificate matches the renewed one. For clusters on shared file systems, MDStoreLocks is available from version 2.4.55 and can lock the store during startup and reload.

Should I hire outside help to automate Apache certificates?

Outside help makes sense when the work spans many virtual hosts, shared clusters, or environments where failed renewals would cause outages. DeployOpen implements and operates self-hosted platforms inside a client's own infrastructure, and scopes that work in writing before it starts. The scope typically covers inventory of managed domains, the mod_md or Certbot configuration, reload handling, and the monitoring that alerts on failed renewals. If your team has the time and the monitoring is already in place, you may handle it internally. Ask any provider to describe the scope and deliverables in writing before agreeing on the work.

How Apache mod_md renews a certificate from check to reload

The cycle starts with mod_watchdog triggering a periodic check. mod_md then decides whether renewal is due by evaluating MDRenewWindow and, when MDRenewViaARI is on, the ARI suggestion from the CA. If renewal is due, the ACME client requests a certificate, and validation runs through the challenge types set in MDCAChallenges. The new certificate is staged in MDStoreDir and becomes active after a graceful restart or reload. MDMessageCmd reports each event along the way. Check that mod_watchdog is loaded, that the store is writable, and that the message command is wired to your alerting.

The renewal path from the scheduled check through staging to activation.

How DeployOpen helps with Apache certificate automation

DeployOpen starts by mapping which Apache virtual hosts and managed domains need certificates, and which ones use static files that mod_md will not renew. We then configure, test and document automated renewal on your Apache HTTP Server, so renewals keep working as public lifetimes move toward 47 days.

How we scope

  • We inventory your VirtualHosts, ServerName and ServerAlias values, and which domains need MDomain groupings.
  • We confirm your Apache version, mod_watchdog availability and whether mod_md can run in your environment.
  • We agree the written scope, deliverables and timeline with you before any work starts, as fixed-scope engagements.

How we build

  • We configure mod_md with your certificate authority, challenge order and renewal settings, then test issuance and renewal.
  • We set MDStoreDir, MDMessageCmd and monitoring so expiring and errored events reach your team.
  • We verify that renewed certificates become active after a graceful restart or reload on your servers.

How we hand over

  • We document the Apache configuration, renewal flow, restart behavior and how to read mod_md job logs.
  • We walk your platform and security engineers through the setup and the steps to follow when a renewal fails.
  • We provide a runbook covering failover settings, challenge requirements and what to confirm after each change.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • We can review renewal behavior as your certificate authority's lifetimes change, so you can plan ahead.
  • We help you confirm that mod_md is still the right fit for your Apache version, since it is marked Experimental.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.