I have XAMPP installed in OSX, and by default it prepends the path to its own bin
directory (full of various utilities) to my $PATH
variable:
# Add path to XAMPP PHP version
export XAMPP_PHP=/Applications/XAMPP/xamppfiles/bin
export PATH="$XAMPP_PHP:$PATH"
Rather unfortunately, one of its utilities is called HEAD
, which thanks to OSX's case-insensitive filesystem, collides with the Unix head
command. XAMPP's HEAD
is completely unrelated to head
(I think it issues an HTTP HEAD request).
Of course, I want to use both head
and XAMPP, so I simply changed the path variable order:
export PATH="$PATH:$XAMPP_PHP"
This lets me use head
, but now there is a collision between XAMPP's version of PHP (for example, 5.5), and the preinstalled version of PHP that comes with OSX (5.3). Since the path to 5.3 comes first, it ends up taking precedence.
My plan for a hackish solution was to prepend the full file path+name just XAMPP's version of PHP, then append the rest of the path after $PATH
:
export PATH="/Applications/XAMPP/xamppfiles/bin/php:$PATH:$XAMPP_PHP"
This does not seem to work. When I restart bash and check php -v
, it's still on PHP 5.3 - the built-in version. Is it even possible to add a specific file path to $PATH
at all?
$PATH
may consist only of directories. You could simply symlink the particular executable you want into an existing directory in your$PATH
. – larsks Apr 15 '16 at 00:59