osx snow leopard - OSX: Installing Custom PHP Binaries
2014-03
I've been doing alot of research and trying to figure out why I have this "older" version of PHP on my Mac (Snow Leopard). I tried MAMP, and it's cool if you just want a *AMP stack and not much leverage over what you want in regards of configuration means (especially coming from a Unix SysAdmin). I tried XAMPP, which works, but is in the same boat as MAMP. I also went the MacPorts route, which was fine, but I recently uninstalled MacPorts and left it for my new love, HomeBrew.
So, I've installed a custom version of PHP using HomeBrew and it installed the binaries in /usr/local/bin.
After a bit of research it has just come to my attention that Apache (httpd) and PHP are installed by default in Snow Leopard. I've seen different sources say its okay to remove it and others that say just leave it. Coming from a Linux/Unix background, I understand that an easy solution would be to symlink /usr/bin/php
to /usr/local/bin/php
(and renaming /usr/bin/php
(binary) to something else such as /usr/bin/php_5.3.4
. To me this is overkill and could possibly break some internal OSX stuff, since enabling the built-in apache is merely just turning on Web Sharing under "Sharing".
So, I don't want to remove the pre-installed PHP binaries.
With that being said, what are the recommendations for this type of setup? I'm basically going to use homebrew to set up a MAMP stack, that way I have complete control over my setup, and I can always run bleeding-edge and/or have multiple versions of PHP, MySQL, and/or apache/nginx.
My thoughts are to just update the environmental variables and add /usr/local/bin
to the beginning of the PATH string (launchctl getenv PATH
). For example, here's my PATH is /usr/bin:/bin:/usr/sbin:/sbin
. I could possibly run the following:
launchctl setenv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
In the end, I would then end up adding the following to my .bash_profile
file:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
launchctl setenv PATH $PATH
Doing so, should let me use the binaries in /usr/local
first for custom stuff such as git, mysql, apache, php, etc. Not sure if this is the way to go or not. Leaving it up to you guys to point me into the right direction on this one.
I am installing a few Homebrew packages on a brand new Mac. However, there are some errors while linking:
ln: ./libsvn_wc-1.dylib: Permission denied
Error: The linking step did not complete successfully
The package built, but is not symlinked into /usr/local
You can try again using `brew link subversion'
Error: Could not create symlink /usr/local/lib/libsvn_wc-1.dylib.
Check that you have permssions on /usr/local/lib
==> Summary
/usr/local/Cellar/subversion/1.6.15: 88 files, 6.0M, built in 38 seconds
So SVN isn't really installed correctly, as we can see here:
charon:~ werner$ which svn
/usr/bin/svn
Same error for Git:
charon:~ werner$ brew link git
Error: Permission denied - /usr/local/lib/python2.6
However, this one's installed correctly:
charon:~ werner$ which git
/usr/local/bin/git
Should I just chmod
the lib
directory or is there anything else I should preferably do?
charon:~ werner$ ls -l /usr/local/
total 8
drwxr-xr-x 7 werner staff 238 Mar 8 15:58 Cellar
drwxr-xr-x 6 werner staff 204 Mar 8 14:21 Library
-rw-r--r-- 1 werner staff 1614 Mar 8 14:21 README.md
drwxr-xr-x 56 werner staff 1904 Mar 8 15:59 bin
drwxr-xr-x 4 werner staff 136 Mar 8 15:46 etc
drwxr-xr-x 3 werner staff 102 Mar 8 15:59 include
drwxr-xr-x 3 root wheel 102 Apr 17 2010 lib
drwxr-xr-x 12 werner staff 408 Mar 8 15:57 share
drwxr-xr-x 4 root wheel 136 Mar 8 14:43 texlive
As of writing, Homebrew requires the contents of /usr/local to be chown'd to your username. This doesn't seem like a great solution, but it works, and is evidently the recommended use. See: https://github.com/mxcl/homebrew/issues/9953#issuecomment-3800557
You can do:
sudo chown -R `whoami` /usr/local