I have written a mini web-server which needs to serve up a few static html files in addition to performing its own custom processing. Could you suggest a reasonable location on the file system where I should store these files, for both Linux and Mac OSX (they need a dedicated directory that I can chroot to).
Why not make it a configurable parameter?
Most (end yes, even homebrew) web-servers support some kind of document-root or static-root.
If you make it configurable you avoid recompilation if you later change your mind.
Some popular places for web-content are:
- /var/www/ -- (used by most servers as document-root)
- $HOME/public_html -- (used to server user specific content)
While these are common they may also rise the risk of collisions with other web-servers on your system. This is another point which adds to "make it a configurable parameter".
I'd put it in ~/yourapp
to avoid collisions with other stuff, and to allow non-admin users to still install it using the defaults.
On OS X, /Library/Application Support/your.app.domain or ~/Library/Application Support/your.app.domain are the "native" location for app controlled files. If the user will be also controlling the contents, you should make the directory configurable so the the user can fit things in with their existing structure.
Of course, OS X is Unix, so you can use /var. Avoid /sw and /opt as they are often controlled by Fink and MacPorts, the two popular unix package managers on OS X.
As long as they're static, you can put them inside your own bundle on OS X.