30

I have installed XAMPP on Mac OSX running Yosemite I have created the .bash_profile file like this:

export XAMPP_HOME=/Applications/XAMPP/xamppfiles export PATH=${XAMPP_HOME}/bin/php:${PATH} export PATH 

When I type echo $PATH in terminal, I get correct XAMPP path But when I type "which php" it shows /usr/bin/php

How can I make my XAMPP use the correct php instead of default php that came with mac?

1
  • I think your XAMPP_HOME path is wrong, try removing /xamppfiles Commented Nov 19, 2014 at 8:19

5 Answers 5

106

To use the XAMPP PHP and other binaries found in /Applications/XAMPP/bin/ add the following to the appropriate ~/.zshrc or ~/.bash_profile file depending on your default shell (see note below).

export XAMPP_HOME=/Applications/XAMPP export PATH=${XAMPP_HOME}/bin:${PATH} export PATH 

Reload the current login shell to apply the changes (won't be needed next time you open a shell session):

$ exec $SHELL -l; 

Confirm:

$ which php /Applications/XAMPP/bin/php 

Note: zsh vs bash

Since MacOS Catalina (v10.15, released 2019), the default shell is zsh rather than bash. To find your current shell, open Terminal and type:

$ echo $SHELL 

The output will most likely be either /bin/zsh or /bin/bash unless you changed to another shell at some time.

Follow the instructions above and if using zsh then add the required lines to ~/.zshrc and if using bash then add them to ~/.bash_profile

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks, solved my problem...!! earlier i was not loading bash_profile using 'source ~/.bash_profile'
What's the correct path to XAMPP's php in the latest version (7)? It is quite different
launching next terminal, which php return old path
Do you found any solution for this issue that lunching next terminal return old path?? @rfan-ul-haq
I have installed xampp 8.0 in macbook. It was installed at "/Users/kamlesh/.bitnami/stackman/machines/xampp/volumes/root/htdocs/". It is working in the browser. xampp 8.0 has php 8 and I want to set its path in bash_profile file so that when i use php -v command in terminal then it should show php 8.0 version. I have set strings in bash_profile as, but not working yet, any suggestion: export XAMPP_HOME=/Users/kamlesh/.bitnami/stackman/machines/xampp/volumes/root export PATH=${XAMPP_HOME}/bin:${PATH} export PATH
|
17

In My case I did the following

I created my bash profile.

sudo nano ~/.bash_profile

And then added the following to it

export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH export PATH 

And then refreshed my path source ~/.bash_profile Or if that doesn't work you can close the terminal completely and start a new session.

Enter which php And you would see your new php path, in my case /Applications/XAMPP/xamppfiles/bin If you know what php version you installed, you can also check by entering php -v in my case it output the following.

PHP 5.6.14 (cli) (built: Nov 19 2015 20:37:15) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies.

1 Comment

any suggestion for xampp 8.0 in mac? Thank you.
10

Finally I Solve the Problem. I set the Following Config in my "~/.bash_profile"

If u have a bash_profile U need to Edit otherWise create bash_profile. Then Add these lines 1st

export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH export PATH 

Above is the Xampp path. Next Add The Composer Path(IF U ADD THE COMPOSER PATH 1st IT WON'T WORK)

export PATH="~/.composer/vendor/bin:$PATH" 

Finally Working Fine for Me.

which php /Applications/XAMPP/xamppfiles/bin/php 

2 Comments

I have installed xampp 8.0 version in mac but there no Xampp directory in Applications directory. Kindly suggest how can we set php path for Xampp 8.0 version in Mac. Thanks a lot.
it works but after restart again shows older version
-1

I managed to solve the problem. On the Mac, the XAMPP bin folder and the php file had the wrong permission, hence it was not working. Secondly, I also had to profile the full path

/bin/php-5.5.15:${PATH} 

Thanks

1 Comment

If this solved your problem and you are happy with the answer, please accept this answer (so it does not appear in the unanswered questions list)
-1

1.Open terminal

2.Run:

echo "$SHELL" 

3.if result is "/bin/zsh", Run:

sudo nano ~/.zshrc 

else Run:

sudo nano ~/.bash_profile 

and enter your devices password

4.add theese lines to the end of the file:

export XAMPP_HOME=/Applications/XAMPP/xamppfiles export PATH=${XAMPP_HOME}/bin/php:${PATH} export PATH 

5.then control+X and enter twice

6.restart

1 Comment

Please explain the value that your advice adds to this page. As a reader who is not an expert in this subject matter, it would help me to decide if I should use your advice if you explain how it differs from earlier answers.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.