Every time I've ever run a production installation of Apache, it's been deployed in the standard configuration implied by the httpd documentation:
PREFIX/bin
/conf
/logs
/htdocs
...
Normally, that dir structure is owned by root, and I'd go off and create a similar directory structure somewhere like:
/app_partition/apache/current/bin
/conf
/logs
/htdocs
...
The scripts in my bin
dir then call through to those in PREFIX/bin
, passing it the -f
option to point it at the conf files on /app_partition
. Thus, I can run several instances of apache on the same server (useful for e.g. having dev and UAT environments on the same box), always referring to a pristine copy of binaries that the application account can't modify. If I need to listen on port 80, a one-time configuration by root
sets up iptables
rules that forward port 80 to whatever port the relevant apache instance is listening on.
For bonus points, current
in the above path is a symlink, as is htdocs
when required, and the whole lot - start scripts, config and all - is built out of source control and deployed with scripts.
So, now I find myself with a CentOS VPS account with Apache pre-installed. It's been done through yum, and the apache files are all over the place; code in /usr/sbin/
, config in /etc/httpd
, the doc base in /var/www/
; all owned by root, all offering (in my mind) very little flexibility.
I'm en route to getting everything up in the manner that I'm used to (without compiling from source, since I quite like the idea of being able to apply security updates with a single yum
command) , but I have a couple of questions:
- Why do distros (all the others I've looked at seem to do the same) insist on spewing the various bits of httpd all over the place - why not just install under
/opt/apache/
or similar? How do other people make this work? Are people (who aren't hosting companies) really out there running Apache out of
/usr/sbin
? Specifically:- How do you get around
/var/www
being owned byroot
? Symlinks? - How do you control Apache upgrades? (Clarifying a bit: There's only one copy of the httpd binary on the sytem, so when you upgrade, you're essentially saying to all users/apps on the system "Congrats, you've been upgraded!", shortly followed by "What do you mean, your config doesn't work any more?")
- How do you roll back Apache upgrades, if it all goes wrong? In the past, I've struggled to make
yum
downgrade stuff. (Thankfully that netbook came with a restore disk.) - How do you version your Apache config?
- What's this
/etc/httpd/conf.d
dir?
-bash-3.2# cat /etc/httpd/conf.d/README
This directory holds Apache 2.0 module-specific configuration files; any files in this directory which have the ".conf" extension will be processed as Apache configuration files.
Files are processed in alphabetical order, so if using configuration directives which depend on, say, mod_perl being loaded, ensure that these are placed in a filename later in the sort order than "perl.conf".
That's some sort of bad practical joke on unsuspecting noobs, right?
- How do you get around