macos php安装
shivammathur/php
将第三方php仓库加入brew,貌似由于homebrew放弃了php的旧版本,所以使用第三方库来加入php的更多版本
shell
brew tap shivammathur/php然后搜索php,就可以看到多出的php版本
shell
brew search php安装php
选择要安装的php版本
shell
brew install shivammathur/php/php@8.2设置php版本
shell
brew link --overwrite --force php@8.2这时候已经自动将php的路径添加到了zsh的环境变量中了,可以查看到版本
shell
php -v切换版本
安装版本切换工具
shell
brew install brew-php-switcher切换版本
shell
brew-php-switcher 8.x切换完可能要按照提示添加相关环境变量。重启terminal
phpini 文件在哪里?
shell
php --ini或者
shell
php -i | grep 'php.ini'怎么重启php?
restart start stop
shell
brew services restart php@8.2顺便记录一下brew安装nginx
shell
# 安装nginx
brew install nginx
# 查看nginx信息(后续着重讲解)
brew info nginx
# 启动
brew services start nginx
# 修改配置后重启
brew services restart nginx
# 停止
brew services stop nginx
# 查看nginx是否启动,存在nginx:master即是启动中的nginx进程号
ps -ef|grep nginxmacos自带apache 需要关掉 不然端口被占
shell
sudo apachectl stop