Apache 2.4 - 'Invalid Command Order' Error

I was working from home yesterday and had to take my car in to the garage to get the brakes fixed, so I took my laptop down with me and walked to Costa Coffee to start work on a project. I couldn't wait to get started on this project, lots of real time socket.io goodness involved, then I found the problem.

Strangely Apache was loading, but I wasn't able to connect to localhost or even my VirtualHosts, this was a problem as I needed it for my work. Running sudo apachectl start wasn't bringing back any errors, just the usual org.apache.httpd: Already loaded which didn't make sense.

It turns out Apache 2.4 has changed the syntax for what you'd usually use as Order allow,deny or Order deny,allow:

Starting httpd: AH00526: Syntax error on line 104 of /usr/local/apache2/conf/httpd.conf:
Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration

Since my laptop wasn't connecting to the network at Costa, I thought something else was in play here - perhaps even strangely; a module loaded from online. I set up my phone as a hotspot, connected, but nope, nothing still.

Later I learnt that Apache 2.4 has removed the Order command and has subsequently been replaced with Require. In your httpd.conf file you just need to replace your Order line with the following:

Require all denied # = Order deny,allow

Or

Require all allowed # = Order allow,deny

Then you need to load in the new modules.

LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_host_module modules/mod_authz_host.so

Who knew there would be so many configuration-breaking changes huh?


comments powered by Disqus