How to find the Apache Web Server version

How to find the Apache Web Server version

Whenever I’m troubleshooting a compatibility issue, planning an upgrade, or just curious about what I’m working with, the first thing I check is the exact version of Apache running on the server. Different versions of Apache support different modules, directives, and security features, so knowing the version number is often the starting point for solving a much bigger problem. In this guide, I’ll walk through every method I use to find the Apache version, both from the command line and remotely over HTTP.

Why the Apache Version Matters

Apache has gone through several major version lines over the years — 2.2.x, 2.4.x, and the ongoing updates within 2.4.x itself. Each version brings changes to:

  • Available modules and directives.
  • Default security behavior.
  • Performance characteristics (especially around MPMs).
  • Compatibility with PHP, Python, and other language runtimes.

Knowing the version helps me determine which documentation applies, whether a particular module is supported, and whether the server needs a security update.

Prerequisites

  • SSH or terminal access to the server (for local checks).
  • Optionally, just a browser or curl if you’re checking a remote server’s version from outside.

Method 1: Using the apache2 -v Command

On Debian-based systems like Ubuntu, I run:

apache2 -v

This returns output like:

Server version: Apache/2.4.52 (Ubuntu)
Server built:   2024-01-15T12:00:00

On CentOS/RHEL-based systems, the binary is usually called httpd:

httpd -v

Method 2: Using apachectl

Another reliable way to check the version is through apachectl, which is a wrapper script provided with Apache:

apachectl -v

This produces the same kind of version output and works consistently whether Apache is running or not, since it just queries the binary directly rather than the running process.

Method 3: Using dpkg (Ubuntu/Debian)

Since Apache is installed via the package manager on Ubuntu, I can also check the installed package version directly:

dpkg -s apache2 | grep Version

or more simply:

apt list --installed | grep apache2

This is useful when I want to confirm the exact package version as tracked by APT, which can sometimes differ slightly in formatting from the apache2 -v output.

Method 4: Using rpm (CentOS/RHEL/Fedora)

On RPM-based distributions, I check the installed package version with:

rpm -qi httpd

or:

yum list installed httpd

Method 5: Checking the Version via systemctl

While systemctl status doesn’t show the version number directly in older setups, many modern configurations display it as part of the status output:

sudo systemctl status apache2

Look for a line referencing the Apache binary or description that may include version details, though I generally rely on apache2 -v for accuracy here.

Method 6: Checking the Version Remotely via HTTP Headers

If I don’t have server access but want to check the Apache version of a website, I can inspect the HTTP response headers:

curl -I http://example.com

This might return:

HTTP/1.1 200 OK
Server: Apache/2.4.52 (Ubuntu)

However, this only works if the server hasn’t been configured to hide version information. Many well-secured servers intentionally suppress this detail, which I’ll explain further in the security section below.

Method 7: Checking via a Browser’s Developer Tools

For a quick, non-technical check, I open the browser’s developer tools (usually F12), go to the Network tab, reload the page, and inspect the response headers of the main document request. The Server header, if not suppressed, will show the Apache version in the same format as the curl method above.

Common Mistakes When Checking the Apache Version

  • Confusing the OS package version with the Apache version. Sometimes the packaging system version string looks different from the internal Apache version reported by apache2 -v. I always trust the direct binary output over indirect package metadata when precision matters.
  • Assuming the remote HTTP header is always accurate or even present. Many production servers deliberately hide this information for security reasons, which means curl -I might return nothing useful.
  • Forgetting that different distributions patch Apache differently. A Debian/Ubuntu build might include backported security patches even though the version number looks the same as a vanilla release, so relying solely on version numbers for security assessments isn’t always sufficient.

Security Considerations Around Version Disclosure

Displaying the Apache version publicly (through HTTP headers) can be a minor security risk, since it gives potential attackers information about which known vulnerabilities might apply to your server. Because of this, I usually configure Apache to hide this information on production servers.

I edit /etc/apache2/conf-available/security.conf and set:

ServerTokens Prod
ServerSignature Off
  • ServerTokens Prod reduces the Server header to just Apache, without any version or OS details.
  • ServerSignature Off removes the version information from server-generated error pages (like 404 pages).

After making this change, I always reload Apache:

sudo systemctl reload apache2

Why Keeping Track of Your Apache Version Matters for Security

Older Apache versions can have known, publicly documented vulnerabilities. I make it a habit to:

  • Regularly run sudo apt update && sudo apt upgrade to stay on the latest patched version within my distribution’s supported release.
  • Subscribe to Apache’s official security announcements or check the Apache HTTP Server security page periodically.
  • Cross-reference my installed version against CVE databases when investigating a specific vulnerability report.

Performance Considerations

Newer Apache versions generally include performance improvements, particularly around HTTP/2 support and more efficient MPMs. If I find I’m running a very old version, that’s often a strong signal it’s time to plan an upgrade, both for security and performance reasons.

Troubleshooting: Version Command Not Found

If apache2 -v or httpd -v returns a “command not found” error, it usually means:

  1. Apache isn’t installed at all — verify with dpkg -l | grep apache2 or rpm -qa | grep httpd.
  2. The binary isn’t in your PATH — try the full path directly, such as /usr/sbin/apache2 -v.
  3. You’re running a custom-compiled Apache installation in a non-standard location — check the directory where you compiled it, often under /usr/local/apache2/bin/httpd.

Frequently Asked Questions

How do I check the Apache version without server access? Use curl -I http://example.com and look at the Server header, though this may be hidden on well-secured servers.

Why does my Apache version show as “Apache” with no number? This means ServerTokens has been set to Prod or Major, intentionally hiding the detailed version for security reasons.

Is it safe to display the Apache version publicly? It’s generally considered best practice to hide it, since it reduces the information available to potential attackers scanning for known vulnerabilities.

How often should I update Apache? Whenever your distribution releases a security update, which is typically handled automatically through regular apt update && apt upgrade cycles on Ubuntu.

Summary and Key Takeaways

Finding the Apache version is usually as simple as running apache2 -v or httpd -v directly on the server, with package manager commands like dpkg or rpm offering a secondary confirmation. For remote checks, HTTP headers can reveal the version, though many production servers intentionally hide this detail for security. Regardless of the method, keeping track of your Apache version is an important part of maintaining a secure, well-performing server.

References

Total
1
Shares

Leave a Reply

Previous Post
How to Create a Bash File Filtering Tool

How to Create a Bash File Filtering Tool

Next Post
How to configure Apache Web Server for the first time

How to Configure Apache Web Server for the First Time

Related Posts