One minute
Mac下使用Brew部署php开发环境
安装Nginx
brew install nginx
目录
# www目录
/usr/local/var/www
# 配置目录
/usr/local/etc/nginx
启动服务
brew services start nginx
安装php7.2
brew install php@7.2
环境变量
echo 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.2/sbin:$PATH"' >> ~/.zshrc
php.ini
/usr/local/etc/php/7.2/php.ini
启动服务
brew services start php@7.2
安装mysql5.7
brew install mysql@5.7
本地调试可设置弱密码(可选)
mysql -uroot
# 登录后输入:
set global validate_password_policy=0;
exit
初始化, 设置root密码等
/usr/local/opt/mysql@5.7/bin/mysql_secure_installation
加环境变量
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
路径
# 数据库路径
/usr/local/var/mysql
# my.cnf
/usr/local/etc/my.cnf
启动服务
brew services start mysql@5.7
注: 如需要修改数据库路径 请编辑服务plist
(修改 /usr/local/etc/my.cnf 修改 datadir 参数没作用)
vim /usr/local/opt/mysql@5.7/homebrew.mxcl.mysql@5.7.plist
# 修改里面的 --data-dir=新的路径
搭建完成, 查看服务
brew services
安装memcached
brew info memcached
brew install memcached
启动
brew services start memcached
别名操作
vim ~/.zshrc
加入:
alias mysql.start="brew services stop mysql@5.7"
alias mysql.stop="brew services stop mysql@5.7"
alias mysql.restart='brew services restart mysql@5.7'
alias mysql.conf='vim /usr/local/etc/my.cnf'
alias mysql.info='mysqld --help --verbose'
alias nginx.start="brew services stop nginx"
alias nginx.stop="brew services stop nginx"
alias nginx.restart='brew services restart nginx'
alias nginx.conf='vim /usr/local/etc/nginx/nginx.conf'
alias nginx.dir='cd /usr/local/etc/nginx/'
alias php.start="brew services stop php@7.2"
alias php.stop="brew services stop php@7.2"
alias php.restart='brew services restart php@7.2'
alias php.conf='vim /usr/local/etc/php/7.2/php.ini'
source ~/.zshrc
就可以使用别名进行维护了
mysql.restart
nginx.restart
php.restart
其他
brew如果速度慢 可以设置代理
export http_proxy="http://127.0.0.1:1080"
export https_proxy="http://127.0.0.1:1080"