Bruno is right on track. I've done extensive research and if you want to set variables that are available in all GUI applications, your only option is /etc/launchd.conf
.
Please note that environment.plist does not work for applications launched via Spotlight. This is documented by Steve Sexton here.
Open a terminal prompt
Type sudo vi /etc/launchd.conf
(note: this file might not yet exist)
Put contents like the following into the file
# Set environment variables here so they are available globally to all apps
# (and Terminal), including those launched via Spotlight.
#
# After editing this file run the following command from the terminal to update
# environment variables globally without needing to reboot.
# NOTE: You will still need to restart the relevant application (including
# Terminal) to pick up the changes!
# grep -E "^setenv" /etc/launchd.conf | xargs -t -L 1 launchctl
#
# See http://www.digitaledgesw.com/node/31
# and http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x/
#
# Note that you must hardcode the paths below, don't use environment variables.
# You also need to surround multiple values in quotes, see MAVEN_OPTS example below.
#
setenv JAVA_VERSION 1.6
setenv JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
setenv GROOVY_HOME /Applications/Dev/groovy
setenv GRAILS_HOME /Applications/Dev/grails
setenv NEXUS_HOME /Applications/Dev/nexus/nexus-webapp
setenv JRUBY_HOME /Applications/Dev/jruby
setenv ANT_HOME /Applications/Dev/apache-ant
setenv ANT_OPTS -Xmx512M
setenv MAVEN_OPTS "-Xmx1024M -XX:MaxPermSize=512m"
setenv M2_HOME /Applications/Dev/apache-maven
setenv JMETER_HOME /Applications/Dev/jakarta-jmeter
Save your changes in vi and reboot your Mac. Or use the grep
/xargs
command which is shown in the code comment above.
Prove that your variables are working by opening a Terminal window and typing export
and you should see your new variables. These will also be available in IntelliJ IDEA and other GUI applications you launch via Spotlight.
Open a good text editor (I'd recommend TextMate, but the free TextWrangler or vi or nano will do too), and open:
/etc/apache2/httpd.conf
Find the line:
"#LoadModule php5_module libexec/apache2/libphp5.so"
And uncomment it (remove the #).
Download and install the latest MySQL version from mysql.com. Choose the x86_64 version for Intel (unless your Intel Mac is the original Macbook Pro or Macbook, which are not 64 bit chips. In those cases, use the 32 bit x86 version).
Install all the MySQL components. Using the pref pane, start MySQL.
In the Sharing System Pref, turn on (or if it was already on, turn off/on) Web Sharing.
You should now have Apache/PHP/MySQL running.
In 10.4 and 10.5 it was necessary to modify the php.ini file to point to the correct location of mysql.sock. There are reports that this is fixed in 10.6, but that doesn't appear to be the case for all of us, given some of the comments below.
Best Answer
.profile
works withsh
orbash
. However.bash_profile
is bash-specific and will override.profile
if present.