I am not new to Apache but nor am I an expert (by any means). I've run sveral versions of WAMP and XAMP server set-ups. Most of my Apache configurations are simple. I usually run a default master configuration file (
apache.conf) and one or two includes (with a different port, for example) and some site-specific virtual host files.
Recently, I set up a server to use HTTPS. I bought certificate and set it up. It wasn't too bad, but it got me thinking. Each Apache configuration I set up seems to be a bit different. I don't apply any best practices; just bits and pieces built up from a default installation using only those changes to make my application run.
This is now bothering me. I run Apache 2.2 currently and I would like to adopt a convention for myself with which I can keep consistent, one that I could more easily deploy to more servers in a quicker fashion.
So my question is, what files should I use and how should they interact? For example, I think most people agree that loading up your main Apache configuration with tweaks is a bad idea. So should you strip it down to the bare minimum and implement multiple includes? How do you properly set up the
sites-available directory (
sites-enabled filled with symlinks)? Because there are many ways to do things and since Apache allows for directives to be used in multiple places with the same affect, I find that bits and pieces get spread out over all these files, including using something like
mod_rewrite in an
.htaccess file (which I'm starting to believe is a bad idea unless you are on shared hosting where that's the only way).
For SSL, do you set up a
default-ssl file or
project-ssl. How many virtual hosts do I run on one server?
I understand that my question is somewhat subjective. There is probably not an objective answer. But my my goal is to get as close to an objective answer as possible.
Then there is WSGI. If you deploy Django sites, this further complicates things. Should I use
/var/www/project/index.wsgi? How do these files interact with the Apache configuration?
Here is a list of files that I'm concerned with:
/etc/apache2/apache.conf /etc/apache2/httpd.conf /etc/apache2/ports.conf /etc/apache2/envvars (mostly self explanatory) /etc/apache2/conf.d/project.conf /etc/apache2/conf.d/security /etc/apache2/sites-available/default /etc/apache2/sites-available/default-ssl /etc/apache2/sites-available/project /etc/apache2/sites-available/project-ssl
Why do some Apache installations have an Apache main configuration with modules included and others have
Like I said above, there seems to be a lot of overlap so I'm not surprised that this is a tricky topic to master.
Alternatively, if anyone knows a good reference that steps through this, I'd be interested in seeing it. I have a couple older Apache books and they just don't break it down. They assume you are complete beginner and that you leave the default alone. The Apache docs are pretty good and I go to them often, but a comprehensive source for what I'm looking for doesn't seem to exist (or, I haven't found the best search terms to find it).