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

rhimbo

macrumors member
Original poster
Jun 21, 2009
60
4
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
/opt
/usr/local
/Applications
/Library

is appreciated.

Many thanks...
 

I'm a ROb

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

Code:
/

    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.


/bin


    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



/dev

    devices - i.e., drivers. In Unix they are setup to look and act as if they were files


/etc

    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


/opt

    Application packages added on. Used, for example, by MacPorts


/sbin


    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



/tmp

    temporary files. These are deleted when the system reboots. /var/tmp is an alternative that doesn't.


/usr

    Non root hierarchy. Static, i.e. shouldn't need to change unless an admin installs something.


/usr/bin

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


/usr/include

    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.


/usr/lib

    These are dynamic libraries used by packages and programs. Normally created as a side effect of installations.


/usr/local


    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


/usr/share

    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


/var

    Variable data. The opposite of static, i.e. users (or the system) change them all the time


/var/lib

    This is non-shareable state information for apps. Users shouldn't need to touch this


/var/log

    Log files, for example from your Apache web server


/var/run

    These are files related to a currently running instance of a program or package. Typically process id (.pid) files and such.


/var/spool

    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


/var/tmp

    This is temporary data, but unlike /tmp it is preserved between system reboots
Although apache is installed in /etc and postgresql in /Library
 

itsmrjon

macrumors regular
Jun 11, 2011
122
0
Chicago
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
 

Cromulent

macrumors 603
Oct 2, 2006
6,039
36
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.
 

rhimbo

macrumors member
Original poster
Jun 21, 2009
60
4
/Library, /opt and /usr/local and permissions to install

I was wondering about this lately as well.
I found this list (from: http://gotofritz.net/blog/tutorials/unix-osx-folder-hierarchy/)
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....

----------

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.
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.
 
Last edited:

Mac_Max

macrumors 6502
Mar 8, 2004
404
1
...

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

Similar threads

Register on MacRumors! This sidebar will go away, and you'll see fewer ads.