brew,php,thinkphp,nginx安装记录流水账(自己备用)

989 阅读1分钟

1. 安装homebrew  /bin/bash -c "$(curl -fsSL raw.githubusercontent.com/Homebrew/in…)"

这个步骤需要设置shell 代理, 不让不成功

2. 设置代理

export http_proxy=http://127.0.0.1:58591

export https_proxy=http://127.0.0.1:58591

取消代理:

unset http_proxy

unset https_proxy

###OK brew 安装完毕

3. 安装PHP brew search php

php@7.4 has been disabled because it is a versioned formula!

解决办法

sudo vim /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/php@7.4.rb

# disable! date: "2022-11-28", because: :versioned_formula

# thinkphp环境需要安装Composer

一、切换 Homebrew 镜像源为中科大镜像源

1、替换源

以中科大镜像为例

# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin 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
 
# 替换homebrew-cask.git: ### 这个不存在无需操作###
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
 
# 应用生效
brew update
# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

2. 查看镜像源信息

brew config

Error: Formula `php@7.4` has not implemented #plist, #service or installed a locatable service file

# 草!说明以上安装PHP7.4方法不对

//将第三方仓库加入brew
brew tap shivammathur/php
//安装PHP
brew install shivammathur/php/php@7.4

brew uninstall shivammathur/php/php@7.4

brew install shivammathur/php/php@7.3

----

安装路径:

/usr/local/Cellar/php@7.3

ln -s /usr/local/Cellar/php@7.3/7.3.33_4/bin/php /usr/local/bin/php

3. 安装nginx:

brew install nginx

brew info nginx

启动nginx服务,如下命令:

brew services start nginx // 重启的命令是: brew services restart nginx

4.安装 mysql@5.6

brew install mysql@5.6

Error: mysql@5.6 has been disabled because it is not supported upstream!

改成

brew install mysql@5.7

==> Successfully started `mysql@5.7` (label: homebrew.mxcl.mysql@5.7)

----

PHP7.3+Nginx1.23.3+mysql5.7 大功告成!

5. 安装 composer

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

----------修改mysql root密码----------

a、进入安全模式

./mysqld_safe --skip-grant-tables &

 b、重新打开一个终端 ,

进入mysql mysql

c、进入mysql中的mysql库 use mysql;

 d、刷新MySQL系统权限 flush privileges;

e、修改root密码: alter user 'root'@'localhost' identified by '你的新密码';

----------

------卸载mysql@5.7----

brew remove mysql
brew cleanup
#launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
rm ~/Library/LaunchAgents/com.mysql.mysqld.plist
sudo rm -rf /usr/local/var/mysql

brew uninstall mysql@5.7
rm -rf /usr/local/var/mysql
rm /usr/local/etc/my.cnf

--- 然后安装

brew install mysql@5.7  // 安装
brew link --force mysql@5.7 // 链接
brew services start mysql@5.7 // 启动服务
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc // 输出到环境变量

-- 设置密码
进入mysql中的mysql库 use mysql;
刷新MySQL系统权限 flush privileges; 修改root密码: alter user 'root'@'localhost' identified by '你的新密码';