1. 解压缩
tar -zxvf apache-maven-3.6.1-bin.tar.gz
创建目录
mkdir -p /usr/local/maven
移动安装包
mv apache-maven-3.6.1/ /usr/local/maven/
2. 配置环境变量
vim /etc/profile
添加如下语句
if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
export MAVEN_HOME=/usr/local/maven/apache-maven-3.6.1
export PATH=$MAVEN_HOME/bin:$PATH:$HOME/bin
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
使用户环境变量生效
source /etc/profile