Skip to content

Instantly share code, notes, and snippets.

@oxUnd
Last active October 6, 2022 12:24
Show Gist options
  • Save oxUnd/9359739 to your computer and use it in GitHub Desktop.
Save oxUnd/9359739 to your computer and use it in GitHub Desktop.
Mac下安装php-cgi

Mac下安装php-cgi

mac下安装php-cgi有多种方法,这里只介绍比较简单的两个方法;

  • 用brew安装
  • 直接下载安装XAMPP

用brew安装

如果安装了xcode,那么推荐使用brew来安装php。详细使用方法见官网,这里只说明如何装php-cgi;

$ brew install php55 --with-cgi

如果安装提示没有php55,请用 brew tap homebrew/homebrew-php 后再安装

如上,方法很简单,等安装成功后即可使用;

直接下载安装XAMPP

XAMPP官网下载Mac版本,双击安装;等安装成功后需要把XAMPP的bin目录设置到 环境变量里面;

  • 使用zsh

    $ echo 'export PATH=/Applications/XAMPP/bin:$PATH' >> ~/.zshrc
    $ source ~/.zshrc
  • 使用bash

    $ echo 'export PATH=/Applications/XAMPP/bin:$PATH' >> ~/.bashrc
    $ source ~/.bashrc
@oxUnd
Copy link
Author

oxUnd commented May 16, 2014

@nwind 已更新

@channely
Copy link

source ~/.bashrc
这条指令不会在启动shell时执行 还必须自己创建一个~/。bash—profile
是这样吗 刚开始用mac 不太懂

@vichajser
Copy link

@gqlxj1987 这种偷懒的方式挺好,解决问题啊。

@taidypanda
Copy link

现在/usr/bin路径已经不能写了,这个方法不行了

@alanhg
Copy link

alanhg commented Oct 3, 2017

方法1没成功

@airrons
Copy link

airrons commented Feb 8, 2018

@nwind 正解

@dilyar85
Copy link

感谢 @gqlxj1987 用了你的方法已成功解决问题

@LeuisKen
Copy link

方法一可以更新成直接使用:brew install php56 --with-cgi

@Leaf217
Copy link

Leaf217 commented Jun 19, 2018

@LeuisKen 正解

@moonshineBoy
Copy link

如何启动呢?

@hitao123
Copy link

hitao123 commented Aug 7, 2019

@LeuisKen mojava Error: invalid option: --with-cgi

@zsnmwy
Copy link

zsnmwy commented Apr 21, 2020

现在这个安装方法已经不行了。

参考

https://medium.com/@romaninsh/install-php-7-2-xdebug-on-macos-high-sierra-with-homebrew-july-2018-d7968fe7e8b8

macOS Catalina currently bundles PHP 7.3 which is officially supported by the PHP community.

https://medium.com/@romaninsh/macos-high-sierra-with-built-in-php-52bcb5c2398c

@tjcchen
Copy link

tjcchen commented Mar 1, 2021

附上一个XAMPP installer的方式安装,希望有帮助。

链接: https://sourceforge.net/projects/xampp/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment