Main Content

Separating 'per instance' data from binaries and web sites

Archive - Originally posted on "The Horse's Mouth" - 2005-10-16 21:13:45 - Graham Ellis

When you install Apache httpd or Apache Tomcat, everything goes into a single directory tree. That's the most natural way for the servers to ship as it means that they can be installed, tested, and then removed again easily if you wish without any complex procedure being involved.

But for a live environment, chances are you'll want to split the data into a separate directory area (that way, you can upgrade the server but retain the web site later) and you might even want to place the read-only files such as the executable binaries on a shared resource, but leave the configuration files and log files in a separate (third) area. Here are some tips / summary schemes for setting these up

Apache httpd

1. Split out the log and conf directories to the new RW area
2. Change the DocumentRoot directive in the configuration file, and also the Directory permissions directive that relates to it.
3. Create the new document root directory
4. Change /etc/init.d to start up using the -d and -f options to apachectl in the start section
5. Ensure that ServerRoot is COMMENTED OUT httpd.conf
6. Restart the Apache httpd server

Note - you can then use an environment variable input to the /etc/init.d/httpd script to control where the various parts are located

Apache Tomcat

1. Stop the Tomcat Server
2. Move the webapps directory to the new data (website) area and change the server.xml to reflect the change - alter the value for the appBase property in the Host tag
3. Create a new directory for the Read/Write area and move the conf and log subdirectories there
4. Set the CATALINA_BASE environment variable to point to the read/write area
5. Restart Tomcat using ./bin/catalina.sh start