See the instructions for installing, configuring and testing the Nginx server on CentOS, Fedora, Debian and Ubuntu below.
Install OpenJDK 8, because Apache Maven requires Java 1.7 or greater.
# yum install java-1.8.0-openjdk-devel
![apachemaven1](https://www.layerstack.com/img/docs/resources/apachemaven1.png)
Run the below command to check the version once the installation is completed.
# java -version
![apachemaven2](https://www.layerstack.com/img/docs/resources/apachemaven2.png)
Setup the JAVA_HOME
environment variable with the below commands.
# echo "JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")" | sudo tee -a /etc/profile
# source /etc/profile
![apachemaven3](https://www.layerstack.com/img/docs/resources/apachemaven3.png)
Now proceed with the installation of Apache Maven. First, change the working directory to /opt/
directory and download the latest stable version of Apache Maven from https://maven.apache.org/download.cgi.
# cd /opt/
# wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
![apachemaven4](https://www.layerstack.com/img/docs/resources/apachemaven4.png)
Extract downloaded archive once the downloading is completed.
# tar -zxvf apache-maven-3.6.3-bin.tar.gz
![apachemaven5](https://www.layerstack.com/img/docs/resources/apachemaven5.png)
Now rename the extracted directory to maven
and set the permission as mentioned below.
# mv apache-maven-3.6.3 maven
# chown -R root:root /opt/maven
![apachemaven6](https://www.layerstack.com/img/docs/resources/apachemaven6.png)
Add the path /opt/maven
to the PATH environment variable with the below commands.
# echo 'export PATH=$PATH:/opt/maven/bin' | sudo tee -a /etc/profile
# source /etc/profile
![apachemaven7](https://www.layerstack.com/img/docs/resources/apachemaven7.png)
Now check the version of Apache Maven to verify the installation.
# mvn --version
![apachemaven8](https://www.layerstack.com/img/docs/resources/apachemaven8.png)
Run the below commands to update the system.
# apt update
![apachemaven9](https://www.layerstack.com/img/docs/resources/apachemaven9.png)
Now install Java with the below command.
# apt-get install -y default-jdk
![apachemaven10](https://www.layerstack.com/img/docs/resources/apachemaven10.png)
Verify the Java version with the below command.
# java -version
![apachemaven11](https://www.layerstack.com/img/docs/resources/apachemaven11.png)
Now proceed with the installation of Apache Maven. First, change the working directory to /opt/
directory and download the latest stable version of Apache Maven from (https://maven.apache.org/download.cgi).
# cd /opt/
# wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
![apachemaven12](https://www.layerstack.com/img/docs/resources/apachemaven12.png)
Extract downloaded archive once the downloading is completed.
# tar -xvzf apache-maven-3.6.3-bin.tar.gz
![apachemaven13](https://www.layerstack.com/img/docs/resources/apachemaven13.png)
Now rename the extracted directory to maven
.
# mv apache-maven-3.6.3 maven
![apachemaven14](https://www.layerstack.com/img/docs/resources/apachemaven14.png)
Now set up environment variables such as M2_HOME
, JAVA_HOME
and PATH
. It can do by creating a mavenenv.sh
file inside of the /etc/profile.d/
directory:
# vi /etc/profile.d/mavenenv.sh
![apachemaven15](https://www.layerstack.com/img/docs/resources/apachemaven15.png)
Add the below lines and save then close.
export JAVA_HOME=/usr/lib/jvm/default-java
export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
![apachemaven16](https://www.layerstack.com/img/docs/resources/apachemaven16.png)
Give the executable permission with the below command.
# chmod +x /etc/profile.d/mavenenv.sh
![apachemaven17](https://www.layerstack.com/img/docs/resources/apachemaven17.png)
Now load the environment variables and check the version of Apache Maven to verify the installation.
# source /etc/profile.d/mavenenv.sh
# mvn --version
![apachemaven18](https://www.layerstack.com/img/docs/resources/apachemaven18.png)