mac环境管理笔记:
一、安装brew 系统指令工具
- 使用国内源进行操作,国外源被墙了,特别是两会期间更是抓到就是封。具体国内源如下:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
使用过程中会有相关提示说明,具体如下所示。
(具体大牛链接https://zhuanlan.zhihu.com/p/111014448)
二、使用brew安装python3环境
brew install python3
三、安装MySql
brew install [email protected]
安装完成后将会提示如下内容:
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
[email protected] is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have [email protected] first in your PATH run:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
For compilers to find [email protected] you may need to set:
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
To have launchd start [email protected] now and restart at login:
brew services start [email protected]
Or, if you don't want/need a background service you can just run:
/usr/local/opt/[email protected]/bin/mysql.server start
根据需求进行使用。
四、安装Reids
Brew install [email protected]
安装完成后brew将提示如下内容:
If you need to have [email protected] first in your PATH run:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
To have launchd start [email protected] now and restart at login:
brew services start [email protected]
Or, if you don't want/need a background service you can just run:
/usr/local/opt/[email protected]/bin/redis-server /usr/local/etc/redis.conf
在命令行中配置如下输入如下命令,添加环境变量:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
添加完成后需要将环境生效,具体使用sorce ~/.zshrc
然后就可以使用redis-cli
进行使用
其他的根据需求自行测试
五、 安装MongoDB
mongodb资源已经从brew资源中移除,需要进行额外的设置,具体步骤如下所示。
brew tap mongodb/brew
然后,输入如下指令进行安装
brew install mongodb-community
可以查看代码如下所示:
`==> Caveats
To have launchd start mongodb/brew/mongodb-community now and restart at login:
brew services start mongodb/brew/mongodb-community
Or, if you don’t want/need a background service you can just run:
mongod --config /usr/local/etc/mongod.conf
==> Summary
🍺/usr/local/Cellar/mongodb-community/4.2.6: 21 files, 306.2MB, built in 4 seconds`
六、 配置python虚拟环境virtualenv
sudo pip3 install virtualenv
sudo pip3 install virtualenvwrapper
向.zshrc中添加如下代码
virtualenv
if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
fi
使用source ~.zshrc
进行系统环境生效
七、配置nginx代理
安装指令:
Brew install nginx
brew提示内容:
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
To have launchd start nginx now and restart at login:
brew services start nginx
Or, if you don't want/need a background service you can just run:
nginx
==> Summary
🍺 /usr/local/Cellar/nginx/1.17.10: 25 files, 2.1MB
==> Caveats
==> nginx
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
To have launchd start nginx now and restart at login:
brew services start nginx
Or, if you don't want/need a background service you can just run:
nginx