Where is the right place to install software on Mac OS X?

Discussion in 'Mac Programming' started by rhimbo, Oct 3, 2012.

  1. rhimbo macrumors member


    Jun 21, 2009
    Hi folks,

    I hope this is the correct forum for my question. Please redirect me if not...

    Where is the "right" place to install software on Mac OS X that one might consider optional? For example, I want to install Apache Tomcat.

    Should I install it in /Library or in /Applications?

    Looking at the contents of /Library it seems that this directory is reserved for libraries or config files for installed software.

    What about /opt, the directory where "optional" software was usually installed in the "good ol'" Unix systems (instead of /usr/local or /usrbin).

    I'm still getting used to Mac OS X and some of the differences between it and Unix (Solaris, etc.). Any enlightening explanations regarding the intended use of

    is appreciated.

    Many thanks...
  2. robvas macrumors 68020

    Mar 29, 2009
  3. I'm a ROb macrumors member

    Aug 14, 2007
    I was wondering about this lately as well.
    I found this list (from: http://gotofritz.net/blog/tutorials/unix-osx-folder-hierarchy/)

        This should contain the minimum needed to boot, restore and repair the filesystem. The idea is to be able to ahve all the core files on small portable storage device.
        binaries used by admins and normal users. This is not the complete set of all the commands available on the system - just the minimum needed for booting and restoring (the rest are in separate places, see below). For example, in OS X 10.6 these are:
        [ bash cat chmod cp csh date dd df domainname echo ed expr hostname kill ksh launchctl link ln ls mkdir mv pax ps pwd rcp rm rmdir sh sleep stty sync tcsh test unlink unrar wait4path zsh
        devices - i.e., drivers. In Unix they are setup to look and act as if they were files
        system configurations, specific for a machine. These are static, i.e. only changeable by admins, and are not executable binaries. Classic examples /etc/hosts, /etc/group, /etc/passwd
        Application packages added on. Used, for example, by MacPorts
        system binaries. These are only used by root or the system. This is the minimum set needed for booting / restoring the system. The other system binaries are in /usr/sbin and /usr/local/sbin
        Typical examples include mount, reboot, fsck
        temporary files. These are deleted when the system reboots. /var/tmp is an alternative that doesn't.
        Non root hierarchy. Static, i.e. shouldn't need to change unless an admin installs something.
        This is where most commands available to all users are. There's loads and loads of them, from python to who to calendar to ssh...
        These are include libraries used by C programs. Of no interest to most users. C libraries get special treatment because at the time Unix was created C was 'the' programming language - indeed, early implementation of Unix were written in C, as opposed to assembly as it was then the norm.
        These are dynamic libraries used by packages and programs. Normally created as a side effect of installations.
        This is where software for a specific machine should go. For example mysql, php5, etc. Within this folder the same hierarchy as root holds:
        /usr/local/bin for binaries,
        /usr/local/etc for config files,
        /usr/local/include for C libraries,
        /usr/local/lib for shared binaries that are not exectuded directly,
        /usr/local/sbin for system libraries run locally
        /usr/local/share for read only libraries
        Read only files, like man pages. If you install a geo-location library like GeoIP, its data could go here
    /usr/X11 and /usr/X11R6
        This is used by the X11 - a full on Unix windows system available on your Mac. You may have come across it if using Gimp, the free Photoshop alternative. X11R6 is a symbolic link to X11
        Variable data. The opposite of static, i.e. users (or the system) change them all the time
        This is non-shareable state information for apps. Users shouldn't need to touch this
        Log files, for example from your Apache web server
        These are files related to a currently running instance of a program or package. Typically process id (.pid) files and such.
        This holds queues of data that need to be dealt with at some stage by an admin or a package. It will be typically deleted after processsing. /var/spool/mqueue holds the outgoing mail queue, for example
        This is temporary data, but unlike /tmp it is preserved between system reboots
    Although apache is installed in /etc and postgresql in /Library
  4. itsmrjon macrumors regular

    Jun 11, 2011
    i typically install additional command line software in /usr/local/NAME
    where NAME is a discernable name of the package i am installing.

    Many of the people i work with tend to place software in /opt/local/NAME
  5. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    Generally speaking I try and keep any additional software I install out of global folders instead preferring to install it into a sub-directory of my home folder.

    Thus I can simply add $HOME/open-source/bin to the PATH and away I go. Likewise if it is a library I just include the relevant paths to compiler.

    I find keeping the system level folders clean beneficial in the long run.
  6. rhimbo, Oct 5, 2012
    Last edited: Oct 5, 2012

    rhimbo thread starter macrumors member


    Jun 21, 2009
    /Library, /opt and /usr/local and permissions to install

    Good reference; thank you. So it seems that OS X follows the Unix traditions pretty closely. I wasn't sure about /Library.

    Right now I'm trying to install MySQL and Apache Tomcat. There are two parts to MySQL:

    1. The MySQL application itself.
    2. The MySQL connector (JDBC driver).

    Question 1: Should the JDBC driver go in /Library or /usr/lib? By the way, I'm not sure of the meaning of that article's description of /Library as a place for "frameworks" (as opposed to "libraries").

    As for the MySQL application itself as well as Tomcat, should the installation go in:
    1. /usr/local (not present on my MacBook Pro actually)
    2. /opt (traditionally "optional" software in SunOS and Solaris for example)

    Not sure why Apache would be installed in /etc....

    Thanks again....


    OK, this is a good point. I actually get nervous each time I have to "sudo" to install something. I guess the purist in me thinks I should try to place the software or library in the "right" place, but it's also more risky if something goes wrong (even such as providing an incorrect path to an installer.

    And, as you said, there is no harm in putting it elsewhere. I can create "lib" and "opt" directories under my home folder and install software there.

    Later this week I will have to install this stuff on a server. Then I'll probably have to do it the more traditional way, at least it seems that would be better.
  7. Mac_Max macrumors 6502

    Mar 8, 2004
    Some installers I've used (can't think of any of the top of my head) give the option of a local only or global install of *nix style command line apps. Local only doesn't need a password of course. If I had to include any libraries with an install and I wanted to place them in a "common" area of some kind, I would do that.

    Also, if you're including something that is to only be used by your app, or you don't mind possibly duplicating a library or command line app that you need, you could always include them in your app's bundle. Its a bit more work to use them/package them, and you should check their licenses to make sure its ok... but the upside is deleting your app will remove all dependencies as well.

Share This Page