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:
- Place all the VirtualHosts configurations in /etc/httpd/conf.d/ as .conf files (eg. www.example.com.conf)
- Place general Apache configuration in /etc/httpd/conf/httpd.conf
Advantages:
- 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.
- 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.
- It is better for organizing the configuration.
I thought this ‘best practice‘ was already accepted and used on a general basis. Apparently not.
