Installing Java 1.8 and Tomcat 8 in Centos 7

I have been setting up our servers in Amazon AWS and found that installing JDK is not as straightforward as I thought it would be ūüôā

I had to do some googling before I could settle down on a method to setup and run tomcat 8 using jdk 1.8 in centos. Putting the steps below for reference to anyone who is trying to achieve the same in AWS:

Setting up Java 8

  1. Login into server
  2. Execute cd /opt
  3. Install wget using  yum install wget 
  4. wget¬†–no-cookies¬†–no-check-certificate¬†–header¬†“Cookie:¬†gpw_e24=http%3A%2F%2Fwww.oracle.com%2F;¬†oraclelicense=accept-securebackup-cookie”¬†http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm 

    NOTE : Please change the version if using a different version
    Reference:
    http://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/
     

  5. Run the command :
    rpm¬†‚Äďivh¬†jdk-8u45-linux-x64.rpm
  6. Check the java version using
    java¬†‚Äďversion
  7. Set the global environments
    export JAVA_HOME=/usr/java/jdk1.8.0_45/
    export PATH=$PATH:$JAVA_HOME
  8. Add to the startup profile
    vi /etc/profile.d/java.sh
  9. Put the following content in the file

    #!/bin/bash
    JAVA_HOME=/usr/java/jdk1.8.0_45/
    PATH=$JAVA_HOME/bin:$PATH
    export PATH JAVA_HOME
    export CLASSPATH=.

  10. Change the permission from all
    chmod +x /etc/profile.d/java.sh

  11. Set the environment variables permanently
    source /etc/profile.d/java.sh

Reference
http://www.unixmen.com/install-oracle-java-jdk-8-centos-76-56-4/

 

Setting up Apache Tomcat 8

Setting up of tomcat is pretty straightforward. We just need to have the latest version downloaded and extracted to /opt

  1. Login into the server
  2. cd /opt
  3. wget http://mirrors.advancedhosters.com/apache/tomcat/tomcat-8/v8.0.22/bin/apache-tomcat-8.0.22.tar.gzNote: Replace the link with the latest version 
  4. Extract the tar file
    tar xzf apache-tomcat-8.0.21.tar.gz
  1. Setup the environment variable for the catalina home
    echo¬†“export¬†CATALINA_HOME=\”/opt/apache-tomcat-8.0.22\””¬†>>¬†~/.bashrc
    source ~/.bashrc
  1. Start the tomcat from bin folder

Reference :
http://tecadmin.net/install-tomcat-8-on-centos-rhel-and-ubuntu/

 

Advertisements

One thought on “Installing Java 1.8 and Tomcat 8 in Centos 7

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s