Apache configuration best practice

I recently had to troubleshoot an Apache server. Twice.

After almost an hour of doing some research, I realized that someone had put application specific configuration in httpd.conf – This is a bad practice, when you have many virtual hosts in the same server.

You should follow this pattern:

  1. Place all the VirtualHosts configurations in /etc/httpd/conf.d/ as .conf files (eg. www.example.com.conf)
  2. Place general Apache configuration in /etc/httpd/conf/httpd.conf

Advantages:

  1. It makes it easier when trying to solve problems with your Apache server. If it is a general configuration problem, look for the problem in httpd.conf. If it is an application level problem, look for the problem in the conf.d directory.
  2. It makes it easier to comment out application configuration. Just rename www.example.com.conf to www.example.com.conf.bck and that’s it.
  3. It is better for organizing the configuration.

I thought this ‘best practice‘ was already accepted and used on a general basis. Apparently not.

This entry was posted in linux/unix world, web programming and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam protection by WP Captcha-Free