Mac 安装PHP运行环境
2019-12-21 本文已影响0人
Mookeen
1、安装homebrew
ruby -e "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/master/install](https://raw.githubusercontent.com/Homebrew/install/master/install))”
brew常用命令
brew update #更新brew可安装包,建议每次执行一下
brew search php55 #搜索php5.5
brew tap josegonzalez/php #安装扩展<gihhub_user/repo>
brew tap #查看安装的扩展列表
brew install php55 #安装php5.5
brew remove php55 #卸载php5.5
brew upgrade php55 #升级php5.5
brew options php55 #查看php5.5安装选项
brew info php55 #查看php5.5相关信息
brew home php55 #访问php5.5官方网站
更换科大源「国外源慢可以更换」
替换brew.git:
cd "$(brew --repo)"
git remote set-url origin [https://mirrors.ustc.edu.cn/brew.git](https://mirrors.ustc.edu.cn/brew.git)
//替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin [https://mirrors.ustc.edu.cn/homebrew-core.git](https://mirrors.ustc.edu.cn/homebrew-core.git)
1.重置源
cd "$(brew --repo)"
git remote set-url origin [https://github.com/Homebrew/brew.git](https://github.com/Homebrew/brew.git)
//重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin [https://github.com/Homebrew/homebrew-core.git](https://github.com/Homebrew/homebrew-core.git)
安装完成后查看brew help看到已安装完成
2、安装Nginx
//查看版本已有版本
brew search Nginx
//『在此安装的nginx1.17.6版本』
brew install nginx
安装完成后如下代码
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
To have launchd start nginx now and restart at login:
brew services start nginx
Or, if you dont want/need a background service you can just run:
nginx
文件目录:/usr/local/var/www
配置文件:/usr/local/etc/nginx/nginx.conf
虚拟配置:/usr/local/etc/servers/
后台启动:brew services start nginx
验证nginx启动成功:http://localhost:8080(8080端口不需要sudo即可)
3、安装MySQL
brew search mysql
安装MySQL5.7
brew install mysql@5.7
We've installed your MySQL database without a root password. To secure it run:
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
mysql@5.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have mysql@5.7 first in your PATH run:
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile
For compilers to find mysql@5.7 you may need to set:
export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"
To have launchd start mysql@5.7 now and restart at login:
brew services start mysql@5.7
Or, if you don't want/need a background service you can just run:
/usr/local/opt/mysql@5.7/bin/mysql.server start
==>Summary🍺 /usr/local/Cellar/mysql@5.7/5.7.28: 318 files, 232.5MB, built in 17 minutes 31 seconds