mac環境管理筆記

mac環境管理筆記:

一、安裝brew 系統指令工具

  1. 使用國內源進行操作,國外源被牆了,特別是兩會期間更是抓到就是封。具體國內源如下:

/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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章