How to install Apache Maven on CentOS 8
Installation
Start by running CentOS updates
Yum update- Confirm the download with '
Y'. - Wait until the update is finished.
Install required packages Maven 3.3+ require JDK 1.7 or above to execute. At the time of writing, Maven 3.6.3 is the latest version.
Yum install java-11-openjdk-devel- Confirm the download with '
Y'. - Check if the installation succeeded with:
java -version
Install Maven Now we are ready to install Maven.
- Download the Maven files with:
wget https://mirror.novg.net/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz - Extract the files to
/optwith:tar xf apache-maven-3.6.3-bin.tar.gz -C /opt - Create a Symbolic Link so that it is easier to update Maven in the future:
ln -s /opt/apache-maven-3.6.3 /opt/maven
Configuration Configuration of Maven
- Create the file named
maven.shinto/etc/profile.d/with:nano /etc/profile.d/maven.sh - Fill the file with the following code:
export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
- Save and exit the file.
- Make the file executable:
chmod +x /etc/profile.d/maven.sh - Now load the file with:
source /etc/profile.d/maven.sh
To check if Maven is installed correctly use the following command: mvn -version
Maven is now installed onto your VPS.
Related Tutorials
Installing LAMP (Linux Apache MySQL and PHP) Stack on CentOS 7 64bitInstalling LAMP (Linux, Apache, MySql & Php) Stack on Debian 8 Server
Install LAMP (Linux Apache, Mysql Server and Php) on an Ubuntu 14.04 64bit VPS Server
CentOS compiler installed under the Apache, PHP, MySQL
Installing ServerPilot and Creating an App on Ubuntu 14.04 LTS 64bit