views:

55

answers:

5

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).

A: 

I think that Apache on Ubuntu defaults to /var/www/.

mvanbem
Thanks, but I would like to keep these files separate from those served up by other apps - maybe I should create my own sub-directory under /var?
codebox_rob
+2  A: 

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".

Shirkrin
Thanks - I already allow the user to override the default via an environment variable, but I need to pick a default that most people will be ok with
codebox_rob
+1  A: 

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.

ceejayoz
Best answer. +1
Tim Post
Not the best answer on OS X.
Barry Wark
The best answer for OSX won't be the best answer for Linux, but this at least *works* and is *reasonable* in both. As the user stated it should be OK for both, I think this is the best compromise.
ceejayoz
+1  A: 

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.

Barry Wark
+1  A: 

As long as they're static, you can put them inside your own bundle on OS X.

Azeem.Butt