Mac OSX PHP 和 XAMPP 路径问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27011941/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:08:22  来源:igfitidea点击:

Mac OSX PHP and XAMPP path issue

phpmacosxampp

提问by ssdesign

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

我已经在运行 Yosemite 的 Mac OSX 上安装了 XAMPP 我已经创建了这样的 .bash_profile 文件:

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

当我在终端中输入 echo $PATH 时,我得到了正确的 XAMPP 路径但是当我输入“which php”时,它会显示 /usr/bin/php

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

如何让我的 XAMPP 使用正确的 php 而不是 mac 附带的默认 php?

回答by BlueC

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

默认情况下,要使用 /Applications/XAMPP/bin/ 中的 XAMPP PHP 和其他二进制文件,这是 ~/.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):

使用此加载更改(下次打开 shell 会话时不需要):

source ~/.bash_profile

Confirm:

确认:

$ which php
/Applications/XAMPP/bin/php

回答by Daniel Barde

In My case I did the following

在我的情况下,我做了以下

I created my bash profile.

我创建了我的 bash 配置文件。

sudo nano ~/.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_profileOr if that doesn't work you can close the terminal completely and start a new session.

然后刷新我的路径 source ~/.bash_profile或者如果这不起作用,您可以完全关闭终端并开始新的会话。

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

Enterwhich php你会看到你的新 php 路径,在我的情况下/Applications/XAMPP/xamppfiles/bin如果你知道你安装的是什么 php 版本,你也可以通过php -v在我的情况下输入来检查它输出以下内容。

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.

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.

回答by Bala Murugan

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

最后我解决了这个问题。我在“~/.bash_profile”中设置了以下配置

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

如果您有 bash_profile,您需要编辑其他方式创建 bash_profile。然后添加这些行 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)

以上是Xampp路径。Next 添加 Composer 路径(如果你添加了 Composer 路径第 1 条就行不通了)

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

Finally Working Fine for Me.

终于为我工作了。

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

回答by ssdesign

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

我设法解决了这个问题。在 Mac 上,XAMPP bin 文件夹和 php 文件的权限错误,因此无法正常工作。其次,我还必须分析完整路径

/bin/php-5.5.15:${PATH}

Thanks

谢谢