步驟1:在home目錄下解壓apache-maven-3.5.0-bin.tar.gz安裝包java
[root@model ~]# tar -zxvf apache-maven-3.5.0-bin.tar.gz
步驟2:建立/maven目錄並將解壓後的文件夾移至該目錄下linux
[root@model ~]# mkdir /maven [root@model ~]# [root@model ~]# [root@model ~]# mv ~/apache-maven-3.5.0 /maven [root@model ~]#
步驟3:配置環境變量文件(加入紅色部分)shell
[root@model etc]# vi /etc/profile # /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates. pathmunge () { case ":${PATH}:" in *:"$1":*) ;; *) if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi esac } if [ -x /usr/bin/id ]; then if [ -z "$EUID" ]; then # ksh workaround EUID=`id -u` UID=`id -ru` fi USER="`id -un`" LOGNAME=$USER MAIL="/var/spool/mail/$USER" fi # Path manipulation if [ "$EUID" = "0" ]; then pathmunge /usr/sbin pathmunge /usr/local/sbin else pathmunge /usr/local/sbin after pathmunge /usr/sbin after fi HOSTNAME=`/usr/bin/hostname 2>/dev/null` HISTSIZE=1000 if [ "$HISTCONTROL" = "ignorespace" ] ; then export HISTCONTROL=ignoreboth else export HISTCONTROL=ignoredups fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL # By default, we want umask to get set. This sets it for login shell # Current threshold for system reserved uid/gids is 200 # You could check uidgid reservation validity in # /usr/share/doc/setup-*/uidgid file if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then umask 002 else umask 022 fi for i in /etc/profile.d/*.sh ; do if [ -r "$i" ]; then if [ "${-#*i}" != "$-" ]; then . "$i" else . "$i" >/dev/null fi fi done unset i unset -f pathmunge JAVA_HOME=/java/jdk1.8.0_141/ CLASSPATH=$JAVA_HOME/lib/ PATH=$PATH:$JAVA_HOME/bin export PATH JAVA_HOME CLASSPATH export MAVEN_HOME=/maven/apache-maven-3.5.0 export PATH=$PATH:$MAVEN_HOME/bin "profile" 85L, 1945C written [root@model etc]# [root@model etc]#
步驟4:使使修改後的/etc/profile文件生效apache
[root@model etc]# source /etc/profile
步驟5:驗證maven是否安裝成功bash
[root@model etc]# mvn -v Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00) Maven home: /maven/apache-maven-3.5.0 Java version: 1.8.0_141, vendor: Oracle Corporation Java home: /java/jdk1.8.0_141/jre Default locale: zh_CN, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-327.el7.x86_64", arch: "amd64", family: "unix" [root@model etc]#
至此,maven安裝完成~less