把执行文件添加到系统 path的好处是,你可以随时在 terminal 中直接执行 XAMPP 里面的文件和指令,而不需要再去相应的文件夹中才能操作。
编辑 ~/.bash_profile
文件,添加如下内容:
export PATH=/Applications/XAMPP/xamppfiles/bin:/Applications/XAMPP/xamppfiles:$PATH
添加完成之后,执行下面指令使其生效,不需要重启
source ~/.bash_profile
然后就可以直接用 xampp start
来启动 xampp 了
XAMPP
和 XAMPP-VM
有什么区别XAMPP
是本地应用,直接把 apache php 和其它应用安装到系统的 /Application/XAMPP
文件夹中
XAMPP-VM
是个模拟应用,并没有在系统中安装 apache
等应用,而是运行在这个模拟的程序中
PHP
路径到新安装的 XAMPP
英文说明参阅: https://gist.github.com/irazasyed/5987693
首先查看当前系统的php
是哪一个
which php
结果会显示下面的内容,因为它是系统自带的php
的路径
/usr/bin/php
vi ~/.bash_profile
编辑当前用户的终端配置文件i
进入输入状态,然后在末尾添加下面内容export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH
ESC
输入 :wq
然后按 回车source ~/.bash_profile
which php
可以看到php
已经指定到xampp
的路径了/Application/XAMPP/etc/httpd.conf
修改 DocumentRoot
到你的网站主目录,如我的是在 /Users/Kyle/Documents/website
DocumentRoot "/Users/Kyle/Documents/website"
Apache
的用户和群组还是改上面提到的那个配置文件 httpd.conf
改成指定目录的用户和群组就好。如我的是用户名是Kyle
群组是staff
# User daemon
# Group daemon
# 上面两个是默认值
User Kyle
Group staff
修改mysql 密码
mysqladmin --user=root password 需要设置的密码
需要先安装 brew 查看官网 https://brew.sh/
注意:执行这个命令需要用外网,不然会出错
如果有 socks,把终端的代理临时设置成 socks5,这个只是临时用,在关闭窗口后就失效
export ALL_PROXY=socks5://127.0.0.1:1080
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装后成功的提示是这样的:
[外链图片转存失败(img-NbpFFglI-1564537462541)(media/15477239929666/Screen%20Shot%202019-01-17%20at%2020.07.52.png)]
[外链图片转存失败(img-t8HBB0Pr-1564537462545)(media/15477239929666/Screen%20Shot%202019-01-17%20at%2020.10.30.png)]
安装 autoconf
kyle-mbp:xdebug-2.6.1 Kyle$ brew install autoconf
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.mojave.bottle.4.tar.gz
######################################################################## 100.0%
==> Pouring autoconf-2.69.mojave.bottle.4.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
/usr/local/share/emacs/site-lisp/autoconf
==> Summary
? /usr/local/Cellar/autoconf/2.69: 71 files, 3.0MB
安装 automake
kyle-mbp:xdebug-2.6.1 Kyle$ brew install automake
==> Downloading https://homebrew.bintray.com/bottles/automake-1.16.1_1.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring automake-1.16.1_1.mojave.bottle.tar.gz
? /usr/local/Cellar/automake/1.16.1_1: 131 files, 3.4MB