Mac OSX PHP and XAMPP path issue

只愿长相守 提交于 2019-11-27 01:03:07

问题


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:


To use the XAMPP PHP and other binaries found in /Applications/XAMPP/bin/ by default this is the correct entry for ~/.bash_profile

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

Load the changes with this (won't be needed next time you open a shell session):

source ~/.bash_profile

Confirm:

$ which php
/Applications/XAMPP/bin/php



回答2:


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.




回答3:


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



回答4:


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



来源:https://stackoverflow.com/questions/27011941/mac-osx-php-and-xampp-path-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!