How to Fix Apache 'Invalid command 'Order'' Error: Resolving authz_host Module Not Found in Server Configuration

Apache HTTP Server is one of the most widely used web servers, powering millions of websites globally. However, even seasoned administrators can encounter cryptic errors when configuring or updating Apache. One such common issue is the 'Invalid command 'Order'' error, often accompanied by a message like "Module authz_host is not found" or "Directive not allowed here".

This error typically arises when Apache encounters the Order directive in its configuration but cannot recognize it—usually because the underlying module (mod_authz_host) responsible for processing access control rules is missing or not loaded. This problem is尤为 prevalent during Apache upgrades (e.g., from 2.2 to 2.4), migrations between servers, or when working with outdated configuration files.

In this blog, we’ll break down the root causes of this error, guide you through diagnosing the issue step-by-step, and provide detailed solutions to resolve it—whether by enabling the missing module or updating deprecated directives. By the end, you’ll have the tools to fix the error and ensure your Apache server runs smoothly.

Table of Contents#

  1. Understanding the 'Invalid command 'Order'' Error
    • What Triggers the Error?
    • Typical Error Messages
  2. Why Does This Happen? Common Causes
    • Missing mod_authz_host Module
    • Apache Version Incompatibility (2.2 vs. 2.4)
    • Typos or Misconfigurations
  3. Diagnosing the Issue: Step-by-Step
    • Step 1: Check Apache Version
    • Step 2: Inspect the Error Log
    • Step 3: Verify mod_authz_host is Loaded
    • Step 4: Locate the Offending Configuration
  4. Fixing the Error: Two Scenarios
    • Scenario 1: Enable the mod_authz_host Module
    • Scenario 2: Update Deprecated Order, Allow, Deny Directives (Apache 2.4+)
  5. Common Pitfalls to Avoid
  6. Conclusion
  7. References

Understanding the 'Invalid command 'Order'' Error#

What Triggers the Error?#

The Order directive is part of Apache’s access control system, used to define the processing order of Allow and Deny rules (e.g., Order allow,deny). This directive is not built into Apache core; it is provided by the mod_authz_host module. If Apache cannot find or load mod_authz_host, it will fail to recognize Order and throw an "Invalid command" error.

Typical Error Messages#

When this error occurs, Apache will log messages like:

AH00526: Syntax error on line X of /etc/apache2/sites-available/example.com.conf:  
Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration  

Or, more explicitly:

Module authz_host is not found in the server configuration  

These errors appear in Apache’s error log (e.g., /var/log/apache2/error.log on Debian/Ubuntu or /var/log/httpd/error_log on RHEL/CentOS) and will prevent Apache from starting or reloading its configuration.

Why Does This Happen? Common Causes#

1. Missing mod_authz_host Module#

The most straightforward cause is that the mod_authz_host module is not enabled or installed. Apache requires explicit loading of non-core modules, and if mod_authz_host is missing from the list of loaded modules, the Order directive will be unrecognized.

2. Apache Version Incompatibility (2.2 vs. 2.4)#

Apache 2.4 introduced significant changes to access control directives. While mod_authz_host still exists in 2.4, the Order, Allow, and Deny directives (from Apache 2.2) are deprecated in favor of the Require directive (via mod_authz_core). If you upgraded from Apache 2.2 to 2.4 but retained old configuration files using Order, Apache may either:

  • Fail to load (if mod_authz_host is disabled), or
  • Warn about deprecated directives (if mod_authz_host is enabled but 2.4-style rules are preferred).

3. Typos or Misconfigurations#

Typos in the module name (e.g., auth_host instead of authz_host), incorrect file paths in configuration files, or missing LoadModule directives for mod_authz_host can also trigger this error.

Diagnosing the Issue: Step-by-Step#

Step 1: Check Your Apache Version#

First, confirm which Apache version you’re running, as this dictates whether Order is deprecated or not:

  • Debian/Ubuntu:
    apache2 -v  
  • RHEL/CentOS:
    httpd -v  

Example output for Apache 2.4:

Server version: Apache/2.4.52 (Ubuntu)  

Step 2: Inspect the Error Log#

Locate the exact line number and file causing the error by checking Apache’s error log:

  • Debian/Ubuntu:
    tail -f /var/log/apache2/error.log  
  • RHEL/CentOS:
    tail -f /var/log/httpd/error_log  

Look for lines containing "Invalid command 'Order'" to identify the problematic configuration file (e.g., a virtual host file or .htaccess).

Step 3: Verify mod_authz_host is Loaded#

Check if mod_authz_host is currently loaded by listing all enabled modules:

  • Debian/Ubuntu:
    apache2ctl -M | grep authz_host  
  • RHEL/CentOS:
    httpd -M | grep authz_host  

If mod_authz_host is loaded, you’ll see output like:

 authz_host_module (shared)  

If no output appears, the module is not loaded.

Step 4: Locate the Offending Configuration#

Use the error log to find the file and line number with the Order directive. For example, if the error points to /etc/apache2/sites-available/example.com.conf:10, open that file and check line 10:

nano /etc/apache2/sites-available/example.com.conf  

Fixing the Error: Two Scenarios#

Scenario 1: Enable the mod_authz_host Module (For Apache 2.2 or 2.4 with Legacy Rules)#

If you’re using Apache 2.2, or need to retain Order/Allow/Deny rules in Apache 2.4, enable mod_authz_host:

On Debian/Ubuntu#

Debian-based systems use a2enmod (Apache 2 Enable Module) to manage modules:

sudo a2enmod authz_host  

This creates a symlink from /etc/apache2/mods-available/authz_host.load to /etc/apache2/mods-enabled/.

Restart Apache to apply changes:

sudo systemctl restart apache2  

On RHEL/CentOS#

RHEL-based systems require manually editing the Apache configuration to load mod_authz_host. Open the main Apache config file:

sudo nano /etc/httpd/conf/httpd.conf  

Add or uncomment the following line (usually near other LoadModule directives):

LoadModule authz_host_module modules/mod_authz_host.so  

Save the file and restart Apache:

sudo systemctl restart httpd  

Scenario 2: Update Deprecated Directives (Apache 2.4+)#

Apache 2.4 recommends using the Require directive (via mod_authz_core) instead of Order, Allow, and Deny. If you’re on Apache 2.4+, update your configuration to use modern syntax.

Key Differences Between Apache 2.2 and 2.4#

Apache 2.2 (Legacy)Apache 2.4 (Modern)
Order allow,denyRequire all granted (allow all)
Order deny,allowRequire all denied (deny all)
Allow from 192.168.1.0/24Require ip 192.168.1.0/24
Deny from all + Allow from .example.comRequire host example.com

Example: Convert Legacy Rules to 2.4 Syntax#

Old (Apache 2.2):

<Directory /var/www/example.com>  
  Order allow,deny  
  Allow from all  
</Directory>  

New (Apache 2.4):

<Directory /var/www/example.com>  
  Require all granted  
</Directory>  

Another Example: Allow Specific IPs
Old:

Order deny,allow  
Deny from all  
Allow from 192.168.1.100  
Allow from 10.0.0.0/8  

New:

<RequireAny>  
  Require ip 192.168.1.100  
  Require ip 10.0.0.0/8  
</RequireAny>  

For more complex rules, refer to Apache’s upgrade guide.

Common Pitfalls to Avoid#

1. Mixing Old and New Directives#

Never mix Order/Allow/Deny with Require in the same configuration block. This causes conflicts and may break access control.

2. Forgetting to Restart Apache#

After enabling modules or editing configurations, always restart Apache to apply changes. Failing to do so will leave the error unresolved.

3. Typos in Module Names#

Ensure the module is spelled authz_host (with a z), not auth_host or authz_hst.

4. Ignoring .htaccess Files#

The Order directive may be in a .htaccess file (in your website’s root directory) rather than the main Apache config. Check .htaccess if the error persists after fixing server-wide configs.

5. Control Panel Interference#

If using cPanel, Plesk, or another control panel, avoid manually editing config files—use the panel’s interface to manage access rules, as it may override manual changes.

Conclusion#

The "Invalid command 'Order'" error in Apache is typically caused by a missing mod_authz_host module or outdated configuration directives. To resolve it:

  1. Enable mod_authz_host if you need to retain legacy Order/Allow/Deny rules (common in Apache 2.2 or migrated setups).
  2. Update to Require directives if using Apache 2.4+ for modern, supported access control.

By following the diagnostic steps and fixes outlined above, you can quickly resolve this error and ensure your Apache server runs smoothly.

References#