Call: (480) 382-8464

How to Test Apache2 Config for Errors with apache2ctl

If you are making changes to apache, you should check the syntax before reloading the configs. Here is how to apache2ctl:

apache2ctl -t

To test your syntax use apache2ctl -t


james@someserver:/var$ apache2ctl -t
/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
[Fri Mar 06 11:18:33 2015] [warn] VirtualHost somesite:80 overlaps with VirtualHost somesite:80, 
the first has precedence, perhaps you need a NameVirtualHost directive
[Fri Mar 06 11:18:33 2015] [warn] NameVirtualHost *:443 has no VirtualHosts

It should say “Syntax OK”, but it shows some errors in this example that we need to fix or else service restart apache2 might choke.

apache2ctl -S

To get more verbose/detailed output about your config files:


jfraze@someserver:/var$ apache2ctl -S
/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
[Fri Mar 06 11:17:32 2015] [warn] VirtualHost somesite:80 overlaps with VirtualHost somesite:80, 
the first has precedence, perhaps you need a NameVirtualHost directive
[Fri Mar 06 11:17:32 2015] [warn] NameVirtualHost *:443 has no VirtualHosts
VirtualHost configuration:
10.10.10.80:80      someserver.your.net (/etc/apache2/sites-enabled/ssl:3)
wildcard NameVirtualHosts and _default_ servers:
*:443                  is a NameVirtualHost
         default server someserver.your.net (/etc/apache2/sites-enabled/ssl:43)
         port 443 namevhost someserver.your.net (/etc/apache2/sites-enabled/ssl:43)
         port 443 namevhost someserver.your.net (/etc/apache2/sites-enabled/ssl.drew:32)
Syntax OK

This tells us which files we need to look in to find the error at least.

Grepping for Errors

If you happen to have a ton of sites and need to find something in particular, you can’t pipe apache2ctl, but you can redirect the output:


apache2ctl -S 2>&1 | grep something

Happy digging!

Leave a Reply

Your email address will not be published. Required fields are marked *

Main Offers/Services

Hosting and website related services offered by Digital Crunch:



Managed VPS Hosting

Server Updates, Module/Software Installs, Firewall, Security, Hosting Management, Wordpress - let us manage it for you

Hosted Email

Setup and Maintain Business Class, Secure Email Hosting including spam protection and 25GB of storage space

Linux Consulting

Server Updates, Module/Software Installs, Firewall, Security, Hosting, Wordpress and Apps, anything related to Linux

Email Marketing Services

We broadcast your content to your list, capture leads for you, follow up on schedules, make more sales for you

Website Maintenance

Content updates, menu changes, graphics changes, adding content, getting links, building traffic, building sales funnels

Hosting Tutorials

Tutorials we've written for other customers that like to get their hands dirty and learn about hosting