This question relates to use of a Lion Server only for testing and prototyping, so I don't need multiple sites hosting separate domains. All of my projects have directories in the root directory, not in separate "Sites" sub-directories.

In Lion Server, Apple has dropped the previous directory arrangement of:

/Library/WebServer/CGI-Executables [aliased as cgi-bin]

/Library/WebServer/Documents [aliased as root directory]

Now, the web server is simply:


After I installed Lion Server, Apache was still configured with cgi-bin aliased to /Library/WebServer/CGI-Executables and root directory to /Library/WebServer/Documents. I changed the latter in the Web section of Lion's Server.app to /Library/Server/Web/Data/Sites/Default.

I'd like to ditch /Library/Webserver. I can't find any reference to a preferred/recommended directory for my executables. I'm thinking: /Library/Server/Web/Data/Exec [aliased in Apache config as cgi-bin or whatever]

I'm used to having all my executables in one place, and they usually share lots of modules in common, so I'm not inclined to put a cgi directory in each project's own directory.

Suggestions? Current best practices?


  • Why ditch the default location of /Library/Webserver ? As I get grayer, I resist changing anything unless the reason is solid and totally clear why the new is better.
    – bmike
    Commented Aug 9, 2011 at 22:05
  • 1
    I'm accustomed to accepting the directory structure presented to me. In the same spirit I slid into using /Library/Webserver/Documents and/Library/Webserver/CGI-Executables on my own machines back when OS X first came out. Those seemed to have been left in /Library when I installed Lion Server. Hoped I'd find some enlightenment about why no separate dir now for CGIs, and implicitly the good question you raise -- why was it it changed? Commented Aug 12, 2011 at 3:57

3 Answers 3


OS X being an unix-based system, you may use the standard unix file structure for that.

Generally speaking, most unix/linux distros use /var/www/ for web server storage, you could imagine something like /var/www/html for pages and media and /var/www/cgi-bin for cgi executables.

There are others locations available (/srv for example), see this list on wikipedia for an explanation on the directory structure (if needed)

  • I appreciate the answer - but macs technically lack all standard directory structure since everything lives in /private and sum links exist for "compatibility" - The convention is to not put anything in var other than temporary files on the mac, which is why we all look for convention to find the "next best place" to let these files live.
    – bmike
    Commented Aug 15, 2011 at 15:27
  • 1
    I never heard of that convention (only tmp files in /var), sorry.But then, why don't you use the same structure as the one you had in SL ? Commented Aug 15, 2011 at 15:38
  • Given that there are only three symlinks to /private, I find the comment 'macs technically lack all standard directory structure' to be a bit overstated (yes, I'm being polite). OS X isn't just unix-based, it is a POSIX-compliant Unix operating system. The fact that it uses a few symlinks doesn't detract from that at all. I think Benjamin's comment is a good one although I wouldn't use /var. My own rules (about 30 years old now - thanks Melinda) are to never mix my stuff with the vendors stuff.
    – zzz
    Commented Aug 18, 2011 at 14:58
  • I guess I had hoped people would explain why they felt a specific location was preferred. Your concept of not mixing server or user data with vendor documents is great! The question isn't so much where you may store things, but where and why one location might be preferred over another. I'll try to edit my answer to better address why I feel it's superior to the alternatives. It's not about polite - i'd rather I hear how and why I'm wrong and be convinced or at least understand why /var or /srv or /Library/WebServer/CGI-Executables is preferred.
    – bmike
    Commented Aug 18, 2011 at 21:23
  • 2
    The thing is : there is no objective reason to prefer a location over another. As long as your installation is well documented, secured and fits your needs, why should you care ? you can use /srv, /opt, /var, /srv, /usr/local or an OSX-specific location... Just take care of updates to avoid problems. Commented Aug 18, 2011 at 21:33

My preference would be to place system wide common CGI executables in /Library/Server/Web/Data/Exec

A few concepts came to mind to me thinking about what folder might be best:

  1. Avoid storing my CGI among the Apple delivered system CGI.
  2. Avoid storing my CGI in a folder where Server Admin and Finder have hidden by default.

    Of lesser importance are the actions taken by Apple to no longer ship with or continue to hide some folders from view (I'm happy to break from the vendor lead - but generally need a good reason to do so)

  3. Don't change from Snow Leopard's location of /Library/WebServer/CGI-Executables (the lazy sysadmin principle - why change anything you don't have to)

  4. Least effort - if I have to chance something - less change is better.

It seems clear that /Library/Server/Web/Data/Sites would contain data that the web server would serve up differentially based on the needs of each site. So if my Orange site had CGI that were only meant for that one site, I might store them in /Library/Server/Web/Data/Sites/Orange/Exec rather than in the "default" location.

I don't see a good reason to keep /Library/WebServer around since I'll be editing my Apache configuration file to add my sites - and I'm guessing that we'll see it change in a point release and won't have to guess.

I would dismiss any folder that was hidden by default in Finder and Server Manager - so for me /private would be out. I'm not saying it's wrong for anyone to store things there - especially if saves you work or brainpower by re-useing code structure from another UNIX OS that doesn't employ Mac OS X's unique /System and /Library directory structure.


Answering my own question in case the conclusion wasn't clear. No one has clarified why Apple changed the directory structure for the web server in OS X Lion (& Mountain Lion) Server. However, for me the salient question was whether there was a "best practices" location for web executables - or a "preferred" location as @bmike put it. My conclusion from the several useful comments and from my own testing is that the choice of location is arbitrary, and therefore what counts as best practice is to locate your web executables where they best serve your site, following the criteria and suggestions mentioned by the commenters.

For me, my own server is just a step on the way to the final location of my stuff on someone else's server or at some ISP. So each build creates two distinct configs: one for my (now Mountain Lion) test server's directory structure and the other for the directory structure where the app will be deployed. Everything else is the same.

So I set up a directory structure for my web server that makes it easy to keep track of my projects, and recorded its paths in my build system. That and Apache-style aliasing (i.e. using 'cgi-bin' as an alias for the executables directory) mean I won't really look back now that my own directory structure is in place. I just build the app and it lands in the right place to run on my server. So that's the answer for me.

In a production server, the best practice would probably incorporate the commenters' suggestions of minimal change, minimal surprise to a later maintainer, and persistence through system upgrades. Thanks all.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .