Mac 的m1开发前基础设置,homebrew,oh-my-zsh,maven,mysql,jdk,tomcat,idea

Mac 的m1开发前基础设置,homebrew,oh-my-zsh,maven,mysql,jdk,tomcat,idea

我的系统配置:

terminal是zsh的,一般新电脑都是默认的zsh:

1、安装 ARM 版 Homebrew

1)、首先创建安装目录

sudo mkdir -p /opt/homebrew

2)、将目录属主修改为当前用户,方便以后用当前用户直接brew install软件

sudo chown -R $(whoami) /opt/homebrew

3)、进入 /opt 文件夹

cd /opt

4)、直接下载homebrew tar包并解压

curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

或者使用我提供的脚本安装,好处是安装脚本可稳定访问,安装默认使用中科大镜像:

设置homebrew-core镜像

HOMEBREW_CORE_GIT_REMOTE=https://mirrors.ustc.edu.cn/homebrew-core.git
​
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"

5)、将路径增加到PATH环境变量中

然后还需要设置下环境变量,在~/.zshrc或者~/.bashrc文件末尾追加下面代码。

export PATH=/opt/homebrew/bin:$PATH

注意:如果你确定使用的终端是zsh,那请编辑.zshrc文件,否则请操作.bashrc文件。

以.zrc为例,在终端执行下面代码可以直接追加内容并让文件生效:

echo export PATH=/opt/homebrew/bin:$PATH >> ~/.zshrc 
source ~/.zshrc

6)、验证是否安装成功

brew

执行完显示下图就表示安装成功:

2、安装oh-my-zsh

1)、安装

git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh

2)、导入模版配置

cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
vi ~/.zshrc #看看是否已经拷贝进去
source ~/.zshrc #更新zsh 看是不是已经生效

3、通过homebrew安装maven

1)、下载Maven

brew install maven will install Maven 3.6.3  #版本可以不加,默认下载最新的
如果安装失败,可以多次执行安装命令,本人就是安装三次才安装成功的

2)、配置环境变量

在Terminal中输入以下命令

vi ~/.zshrc

3)、按i 进入编辑模式

#maven
    export M2_HOME=/usr/local/Cellar/maven/3.6.3/libexec(此处为自己的libexec的绝对路径)
    export PATH=$PATH:$M2_HOME/bin 
  esc退出,使用:wq 退出保存。

4)、刷新配置文件

source ~/.zsrc

5)、测试安装结果

mvn -v

显示一下结果,表示安装成功:

4、通过homebrew安装mysql

1)、安装

brew install mysql
#想要安装指定版本的mysql
brew install mysql@5.7(5.7为指定版本号)

2)、配置环境变量

# 终端
echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
/opt/homebrew/opt/mysql@5.7/bin是bin在mysql里的指定目录
# 刷新 ~/.zshrc
source ~/.zshrc

3)、查看版本

nichengjing@nichengjingdeMacBook-Air ~ % mysql --version
mysql  Ver 14.14 Distrib 5.7.34, for osx10.16 (x86_64) using  EditLine wrapper

4)、启动

mysql.server start  # 启动mysql
mysql.server stop # 停止mysql
mysql.server restart # 重启mysql

5)、初始化

任意路径执行命令:mysql_secure_installation,交互过程中不断输入y或者n,可以修改密码。

Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: n    // 这个选yes的话密码长度就必须要设置为8位以上,但我只想要6位的
Please set the password for root here.
New password:
Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y          // 移除不用密码的那个账户
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n      //不接受root远程登录账号
... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y     //删除text数据库
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately. 
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!

安装完成

5、通过homebrew下载tomcat

1)、安装tomcat

brew install tomcat

2)、检查是否安装成功:

catalina -h

3)、运行tomcat:

catalina run

4)、运行成功后

Tomcat的默认端口是8080,如果运行成功可通过[http://localhost:8080](https://link.jianshu.com/?t=http%3A%2F%2Flocalhost%3A8080)访问

5)、关闭tomcat

catalina stop

6、下载JDK

基于ARM的zulu:8.52.0.23下载快快,官网就是下载的时候有点慢
下载地址:azul.com

7、下载idea安装包

直接到官网上下载

M1的话一定要记得选择这个版本的IDEA。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值