m1安装 PHP版本7.4
# 搜索php的版本
brew search php
# 下载php
brew install php@7.4
# 加载到 .zshrc
export PATH="/opt/homebrew/opt/php@7.4/bin:$PATH"
export PATH="/opt/homebrew/opt/php@7.4/sbin:$PATH"
# 使之有效
source ~/.zshrc
# 检测是否安装完成
php -v
# 查找ini
php --ini
brew install nginx
# 安装成功后,查看nginx信息
brew info nginx
# 最主要的是查看网站根目录和配置文件目录,默认为8080端口
# nginx 常用命令
brew install mysql@5.7
# 添加mysql到环境变量
echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
# 刷新
source ~/.zshrc
# 查看当前版本
mysql --version
# 没有提示你默认密码是多少 通过下面的命令直接修改密码
mysqladmin -u root password "你的密码"
# 然后重启mysql服务
mysql.server restart
brew install redis
redis-server /opt/homebrew/etc/redis.conf
🍺/opt/homebrew/Cellar/redis/6.2.4: 13 files, 2M
#echo 'export PATH="/opt/homebrew/opt/redis@6.0/bin:$PATH"' >> ~/.zshrc
修改运行方式
安装redis
brew install redis
#vi /opt/homebrew/etc/redis.conf
daemonize no 是非后台运行模式
daemonize yes 是后台运行模式
brew services start redis
brew services stop redis
redis-cli -h 127.0.0.1 -p 6379
redis-server方式启动的关闭方式如下(本机、远程 )
#redis-cli -h 127.0.0.1 -p 6379 shutdown
(中间出现问题。查看下面的)
更新Homebrew
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
#更新Homebrew-core
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
#更新Homebrew-cask(最重要的一步,很多更新完国内源依然卡就是没更新这个)
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/' >> ~/.zshrc
source ~/.zshrc
brew update -v
brew php
开启:brew services start php@7.4
重启:brew services restart php@7.4
停止:brew services stop php@7.4
brew services start nginx
brew services restart nginx
brew services stop nginx
安装:brew install nginx/sudo brew install nginx
启动:brew services start nginx/sudo brew services start nginx
重启:brew services restart nginx/sudo brew services restart nginx
停止:brew services stop nginx/sudo brew services stop nginx
查看:cat usr/local/etc/nginx/nginx.conf
编辑:vi usr/local/etc/nginx/nginx.conf
homebrew 常用的指令:
brew search mysql : 搜索具体的程序包
brew install mysql : 安装具体的程序包
brew info mysql : 查看具体程序的信息
brew uninstall mysql : 卸载具体的应用(这里只是用mysql 作个例子)
Mysql
若不考虑版本直接执行以下命令
brew install mysql
若要选择版本只要加上@版本即可,例如
brew install mysql@5.7
安装完后启动mysql mysql.server start
若服务未启动就会出现以下错误
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
若要关闭mysql
mysql.server stop
看到提示success则表示启动成功
Starting MySQL
. SUCCESS!
现在登录mysql,默认情况下免密登录
mysql -u root
修改root密码,这是8.0的修改方法
alter user 'root'@'localhost' identified with mysql_native_password by 'root';
回车后有提示,则表示修改成功
Query OK, 0 rows affected (0.00 sec)
server{
listen 80;
server_name www.blog.com;
root /var/www/blog/public;
index index.html index.htm index.php;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}