Mac nginx&php&mysql 环境搭建

  • 样式需优化,内容需要调整 更加严谨 2021-05-21 14:04:14 *

安装 nginx
查找可安装版本 brew search nginx
安装 brew install nginx

文件路径 /usr/local/var/www
配置路径 /usr/local/etc/nginx/nginx.conf
程序目录 /usr/local/Cellar/nginx/1.19.10
查看配置是否正常 sudo nginx -t
启动 sudo nginx
重启 sudo nginx -s reload

启动命令 brew services start nginx
开机启动 sudo brew services start nginx

安装php
查找可安装版本 brew search php
安装 brew install php@7.4

sudo vim /private/etc/php-fpm.conf
更改错误日志 error_log = /usr/local/var/log/php/php-fpm.log

sudo cp www.conf www.conf.bak

现在使用这条命令进行的启动,需更改 sudo brew services start php@7.4

写入环境变量
echo 'export PATH="/usr/local/opt/php@7.4/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.4/sbin:$PATH"' >> ~/.zshrc

不需要执行 source ~/.zshrc

/usr/local/etc/php/7.4/

export LDFLAGS="-L/usr/local/opt/php@7.4/lib"
export CPPFLAGS="-I/usr/local/opt/php@7.4/include"

启动 sudo brew services start php@7.4

查看安装好的php路径
brew --prefix php@7.4

安装mysql
查找可安装版本 brew search mysql
安装 brew install mysql@5.7
启动数据库 brew services start mysql@5.7
进行配置 mysql_secure_installation
设置密码

echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"
export PKG_CONFIG_PATH="/usr/local/opt/mysql@5.7/lib/pkgconfig"

登陆 mysql -u root -p

参考:
https://ismdeep.com/posts/2020-04-22-install-nginx-mysql-php-on-macos.html
https://juejin.cn/post/6844903802361888782
https://www.cnblogs.com/benbenhan/p/12421070.html

posted @ 2021-05-21 14:04  蓝晓焰  阅读(234)  评论(0编辑  收藏  举报