Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install Maven with Yum on Amazon Linux
sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
sudo sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
sudo yum install -y apache-maven
mvn --version
@jamesontriplett

This comment has been minimized.

jamesontriplett commented Nov 20, 2014

This is awesome. Thanks, exactly what I wanted

@zeitos

This comment has been minimized.

zeitos commented Dec 17, 2014

Thanks!

@adriaanm

This comment has been minimized.

adriaanm commented Jan 27, 2015

@cupdike

This comment has been minimized.

cupdike commented Mar 9, 2015

Seems like this repo is not working at the moment. I get:
http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-6Server/x86_64/repodata/194b1dce25e9483ae3ce34f3e4f807770dd77705-primary.sqlite.bz2: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"

If you look in https://repos.fedorapeople.org/repos/dchen/apache-maven/epel-6Server/x86_64/repodata/repomd.xml, that file, 194b..., is listed for "primary_db" but is not served under ./repodata (I assume that is how it is supposed to work). Perhaps something is out of sink at the moment. BTW, I tried all manner of yum clean metadata; yum clean all; beforehand.

@IvanFernandez

This comment has been minimized.

IvanFernandez commented Mar 10, 2015

still down :(

@zoltan-fedor

This comment has been minimized.

zoltan-fedor commented Mar 10, 2015

Yes, unfortunately it is still down...

@zoltan-fedor

This comment has been minimized.

zoltan-fedor commented Mar 11, 2015

Yeay, it is back now.

@mlindhout

This comment has been minimized.

mlindhout commented Apr 9, 2015

thanx!

@cbibbs

This comment has been minimized.

cbibbs commented May 10, 2015

Thanks for the assistance

@williansmartins

This comment has been minimized.

williansmartins commented May 28, 2015

Valeu!!!!!!

@anshuiisc

This comment has been minimized.

anshuiisc commented Jun 20, 2015

ohhhh.. its so easy ... thanks alot

@juanino

This comment has been minimized.

juanino commented Jul 6, 2015

thanks. perfect.

@dimerman

This comment has been minimized.

dimerman commented Jul 8, 2015

๐Ÿ‘

@sprzedwojski

This comment has been minimized.

sprzedwojski commented Jul 10, 2015

Perfect, thanks

@avnarun

This comment has been minimized.

avnarun commented Jul 20, 2015

This worked for me ... thanks a ton !!

@javadba

This comment has been minimized.

javadba commented Jul 25, 2015

Worked on amazon linux.

@DreamFlasher

This comment has been minimized.

DreamFlasher commented Jul 28, 2015

Thank you!

@afsbd

This comment has been minimized.

afsbd commented Jul 29, 2015

this is fantastic, thank you.

@tomkast

This comment has been minimized.

tomkast commented Aug 9, 2015

thanks

@pkshultz

This comment has been minimized.

pkshultz commented Sep 1, 2015

If only there were more scripts like this floating around the Internet---thank you!

@flnj

This comment has been minimized.

flnj commented Sep 10, 2015

Thank you!

@freaksterz

This comment has been minimized.

freaksterz commented Sep 18, 2015

this is real handy ..saved my time. Thanks

@plashkary

This comment has been minimized.

plashkary commented Sep 23, 2015

Thank u for precise steps.

@freaksterz

This comment has been minimized.

freaksterz commented Sep 28, 2015

thanks for sharing. works like charm

@jgwerner

This comment has been minimized.

jgwerner commented Oct 21, 2015

thanks for the gist, works great.

@dipurane

This comment has been minimized.

dipurane commented Nov 27, 2015

Worked like charm ... Thanks a lot for sharing this.

@andersoncarubelli

This comment has been minimized.

andersoncarubelli commented Dec 2, 2015

Thank you!

@wsh

This comment has been minimized.

wsh commented Dec 21, 2015

THANK YOU!

@cjhope

This comment has been minimized.

cjhope commented Jan 21, 2016

Very nice - thanks

@dyerrington

This comment has been minimized.

dyerrington commented Jan 21, 2016

Awesome! Thank you!

@Yaswanthgandra

This comment has been minimized.

Yaswanthgandra commented Feb 5, 2016

Thanks!

@collinkrawll

This comment has been minimized.

collinkrawll commented Feb 7, 2016

This worked great but set maven (and my default java) to use Java 1.7. If you want to use Java 1.8, follow the above gist and then do:

yum search java | grep openjdk
yum install java-1.8.<revision number from yum search>-openjdk-headless.x86_64
yum install java-1.8.<revision number from yum search>-openjdk-devel.x86_64
update-alternatives --config java #pick java 1.8
update-alternatives --config javac #pick java 1.8
@naveenwashere

This comment has been minimized.

naveenwashere commented Apr 1, 2016

@collinkrawll: Thanks for the command to switch to jdk8

@nexus49

This comment has been minimized.

nexus49 commented Apr 19, 2016

thanks!

@jfairchild

This comment has been minimized.

jfairchild commented Apr 25, 2016

Still works! ๐Ÿ‘

@kaiprt

This comment has been minimized.

kaiprt commented Apr 28, 2016

Thank you!

@kbens

This comment has been minimized.

kbens commented May 5, 2016

Very nice. ๐Ÿ‘

@alexruzenhack

This comment has been minimized.

alexruzenhack commented May 5, 2016

Thank you! ๐Ÿ†—

@arti-bol

This comment has been minimized.

arti-bol commented May 7, 2016

Exactly what I wanted. Just needed to so sudo su

@sabs47

This comment has been minimized.

sabs47 commented May 7, 2016

thx this is exactly what im lookig for

@YutaroSoejima

This comment has been minimized.

YutaroSoejima commented May 12, 2016

thx!

@ghost

This comment has been minimized.

ghost commented May 13, 2016

@collinkrawll: thanks for the switch

@ramx

This comment has been minimized.

ramx commented Jun 14, 2016

Thanks!

@ulymarins

This comment has been minimized.

ulymarins commented Jun 29, 2016

๐Ÿ‘

@ImHimanShoe

This comment has been minimized.

ImHimanShoe commented Jun 30, 2016

Thanks!

@paulograbin

This comment has been minimized.

paulograbin commented Jul 28, 2016

Awesome!

@tribbloid

This comment has been minimized.

tribbloid commented Aug 4, 2016

All hail @sebsto!

@markchou

This comment has been minimized.

markchou commented Aug 25, 2016

thx this is exactly what im lookig for!!!

@garyden

This comment has been minimized.

garyden commented Sep 18, 2016

Cool!

@githoov

This comment has been minimized.

githoov commented Sep 21, 2016

hero

@timle

This comment has been minimized.

timle commented Nov 3, 2016

Thank you! Worked for me on the following docker image: sequenceiq/hadoop-docker:2.7.1
which is running CentOS release 6.6
(but did install wget first, 'yum install wget')

@ThaddeusAid

This comment has been minimized.

ThaddeusAid commented Nov 6, 2016

perfect thanks!

@anherrera

This comment has been minimized.

anherrera commented Nov 29, 2016

Thanks!

@calebbarr

This comment has been minimized.

calebbarr commented Dec 1, 2016

Seriously great.

@chisni

This comment has been minimized.

chisni commented Dec 10, 2016

Thanks for the article.To make maven point to java8 instead of java7,did the following instead.

Create a new file ~/.mavenrc with the following content
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-1.b15.25.amzn1.x86_64

@stevelinnovations

This comment has been minimized.

stevelinnovations commented Jan 6, 2017

Worked for me, many thanks!

@manojpardeshi

This comment has been minimized.

manojpardeshi commented Jan 11, 2017

very nice!!!!

@isshwar

This comment has been minimized.

isshwar commented Feb 25, 2017

sudo sed -i s/$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo

can someone please explain what this command will do? and the path where maven actually gets installed after the above command?

@hoangngo237

This comment has been minimized.

hoangngo237 commented Feb 27, 2017

Thanks

@Henry31

This comment has been minimized.

Henry31 commented Mar 2, 2017

@collinkrawll: Thanks for that. I need to change maven also to jdk 1.8.

But how could I provide this in ansible? Because with your command, there is always a prompt, where I must select the right version.

@sptkrishnan

This comment has been minimized.

sptkrishnan commented Mar 7, 2017

@isshwar 'sed' is a unix/linux utility and stands for "stream editor". It takes an input file and rewrites some parts of it using REGEX. In this case, it is replacing "$releasever" with "6". The reason being $releasever makes sense in fedora OS and not in Amazon Linux. Do a "man sed" on a linux system for more details. Hope this helps.

@nancydwong

This comment has been minimized.

nancydwong commented Mar 10, 2017

Thanks for the time save!

@alanwds

This comment has been minimized.

alanwds commented Mar 18, 2017

Work like a charm! Tks!

@JayasreeJayachandran

This comment has been minimized.

JayasreeJayachandran commented Mar 30, 2017

it shows network is unreachable in centos6.8(acadgild vm)

@wh211212

This comment has been minimized.

wh211212 commented Apr 7, 2017

it's good.

@xuexb

This comment has been minimized.

xuexb commented May 2, 2017

๐Ÿ‘

@mohanreddy-mca

This comment has been minimized.

mohanreddy-mca commented May 14, 2017

Very Nice... Awesome....:-)

@altrofimov

This comment has been minimized.

altrofimov commented Jun 13, 2017

Thank you!

@rishabkdoshi

This comment has been minimized.

rishabkdoshi commented Jun 16, 2017

This worked like a charm, Thank you!

@nduka145

This comment has been minimized.

nduka145 commented Jun 28, 2017

I used this,

sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
sudo sed -i s/$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
sudo yum install -y apache-maven
mvn --version;

and here is my output;
bash: /opt/apache-maven-3.5.0/bin/mvn: No such file or directory

How can i fix this. Thanks

@fookingthg

This comment has been minimized.

fookingthg commented Jul 3, 2017

Thank you. worked like a charm ๐Ÿ‘

@Japster24

This comment has been minimized.

Japster24 commented Jul 5, 2017

Resolving Dependencies
--> Running transaction check
---> Package apache-maven.noarch 0:3.3.9-3.el7 will be installed
--> Processing Dependency: plexus-sec-dispatcher for package: apache-maven-3.3.9-3.el7.noarch
--> Processing Dependency: aether-util for package: apache-maven-3.3.9-3.el7.noarch
--> Processing Dependency: aether-spi for package: apache-maven-3.3.9-3.el7.noarch
--> Processing Dependency: aether-impl for package: apache-maven-3.3.9-3.el7.noarch
--> Processing Dependency: aether-api for package: apache-maven-3.3.9-3.el7.noarch
--> Finished Dependency Resolution
Error: Package: apache-maven-3.3.9-3.el7.noarch (epel-apache-maven)
Requires: aether-impl
Error: Package: apache-maven-3.3.9-3.el7.noarch (epel-apache-maven)
Requires: plexus-sec-dispatcher
Error: Package: apache-maven-3.3.9-3.el7.noarch (epel-apache-maven)
Requires: aether-util
Error: Package: apache-maven-3.3.9-3.el7.noarch (epel-apache-maven)
Requires: aether-spi
Error: Package: apache-maven-3.3.9-3.el7.noarch (epel-apache-maven)
Requires: aether-api
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

@dukeForsyth

This comment has been minimized.

dukeForsyth commented Sep 16, 2017

Pretty late but thanks this helped me a lot!

@kirkryan

This comment has been minimized.

kirkryan commented Oct 10, 2017

Thanks for this!

@nikhilvs

This comment has been minimized.

nikhilvs commented Oct 17, 2017

๐Ÿ‘

@senisas

This comment has been minimized.

senisas commented Nov 4, 2017

Thanks ๐Ÿ‘

@sdeepaks

This comment has been minimized.

sdeepaks commented Nov 8, 2017

Thanks (Y)

@7--

This comment has been minimized.

7-- commented Jan 11, 2018

This is useless without being able to specify where it installs and persisting the env variables.
This is the proper way to do it. Installing in your current directory.

wget http://apache.mirrors.lucidnetworks.net/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz
tar xzvf apache-maven-3.5.2-bin.tar.gz

Add these lines to the ~/.bashrc file

PATH="$PATH:<DIR WHERE YOU RAN ABOVE COMMANDS>/apache-maven-3.5.2/bin"
M2_HOME=<DIR WHERE YOU RAN ABOVE COMMANDS>/apache-maven-3.5.2

Logout and back in. Now mvn -v will work for this user even if you logout and back in!

@haldhafari82

This comment has been minimized.

haldhafari82 commented Jan 29, 2018

Thanks!!
I wish it was as simple as "yum install maven"

@josh-padnick

This comment has been minimized.

josh-padnick commented Mar 28, 2018

You can automatically install OpenJDK 8 with:

sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
# Note I've replaced the "6" with "7" here.
sudo sed -i s/\$releasever/7/g /etc/yum.repos.d/epel-apache-maven.repo
sudo yum install -y apache-maven
mvn --version

Of course, in my case, I actually prefer Oracle JDK.

@sdindiver

This comment has been minimized.

sdindiver commented Apr 6, 2018

thank you

@pacomedomagni

This comment has been minimized.

pacomedomagni commented Apr 16, 2018

thank you man

@easikoglu

This comment has been minimized.

easikoglu commented Apr 26, 2018

I suggest you first download jdk from oracle website via wget, then install 1.8, after that set up environment variable in bash profile, as :
export JAVA_HOME=/usr/java/jdk1.8.0_171-amd64/
export JRE_HOME=//usr/java/jdk1.8.0_171-amd64/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

Then you do not need to deal with java version after executed in the upper gist.

@Server4001

This comment has been minimized.

Server4001 commented Jun 3, 2018

Very helpful, thank you.

@Amitsharma045

This comment has been minimized.

Amitsharma045 commented Jun 21, 2018

Thank you, very helpful

@connectometeam

This comment has been minimized.

connectometeam commented Jul 19, 2018

Brilliant, thanks for this!

@raghava118mf

This comment has been minimized.

raghava118mf commented Jul 22, 2018

Thank you very much.....:)

@jeffdiederiks-pyramid

This comment has been minimized.

jeffdiederiks-pyramid commented Aug 20, 2018

Beautiful. Thanks man.

@arunodayraja

This comment has been minimized.

arunodayraja commented Aug 26, 2018

Thanks Mister

@sandeeppagatur

This comment has been minimized.

sandeeppagatur commented Nov 21, 2018

great thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment