{"id":5696,"date":"2016-04-25T01:48:49","date_gmt":"2016-04-24T17:48:49","guid":{"rendered":"http:\/\/rmohan.com\/?p=5696"},"modified":"2016-04-25T01:48:49","modified_gmt":"2016-04-24T17:48:49","slug":"tomcat-8-centos-6-7","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=5696","title":{"rendered":"tomcat 8 centos 6.7"},"content":{"rendered":"<pre>## screen -U -S tomcat8-screen\r\n## yum update<\/pre>\n<h3><b>INSTALL JAVA 8<\/b><\/h3>\n<p>Download the latest JAVA 8 from <a title=\"Java Downloads\" href=\"http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/index.html\" target=\"_blank\">here<\/a> or use the following command to download JAVA JDK 8u5:<\/p>\n<p>for 32bit systems use:<\/p>\n<pre>## wget --no-cookies \\\r\n--no-check-certificate \\\r\n--header \"Cookie: oraclelicense=accept-securebackup-cookie\" \\\r\n\"http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u5-b13\/jdk-8u5-linux-i586.rpm\" \\\r\n-O \/opt\/jdk-8-linux-i586.rpm<\/pre>\n<p>for 64bit systems use:<\/p>\n<pre>## wget --no-cookies \\\r\n--no-check-certificate \\\r\n--header \"Cookie: oraclelicense=accept-securebackup-cookie\" \\\r\n\"http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u5-b13\/jdk-8u5-linux-x64.rpm\" \\\r\n-O \/opt\/jdk-8-linux-x64.rpm<\/pre>\n<p>once the JAVA package has been downloaded, install it using <code>rpm<\/code> as follows:<\/p>\n<p>for 32bit systems use:<\/p>\n<pre>## rpm -Uvh \/opt\/jdk-8-linux-i586.rpm<\/pre>\n<p>for 64bit systems use:<\/p>\n<pre>## rpm -Uvh \/opt\/jdk-8-linux-x64.rpm<\/pre>\n<h3><b>CONFIGURE JAVA<\/b><\/h3>\n<p>configure the newly installed JAVA package using <code>alternatives<\/code> as in:<\/p>\n<pre>## alternatives --install \/usr\/bin\/java java \/usr\/java\/jdk1.8.0_05\/jre\/bin\/java 20000\r\n## alternatives --install \/usr\/bin\/jar jar \/usr\/java\/jdk1.8.0_05\/bin\/jar 20000\r\n## alternatives --install \/usr\/bin\/javac javac \/usr\/java\/jdk1.8.0_05\/bin\/javac 20000\r\n## alternatives --install \/usr\/bin\/javaws javaws \/usr\/java\/jdk1.8.0_05\/jre\/bin\/javaws 20000\r\n## alternatives --set java \/usr\/java\/jdk1.8.0_05\/jre\/bin\/java\r\n## alternatives --set javaws \/usr\/java\/jdk1.8.0_05\/jre\/bin\/javaws\r\n## alternatives --set javac \/usr\/java\/jdk1.8.0_05\/bin\/javac\r\n## alternatives --set jar \/usr\/java\/jdk1.8.0_05\/bin\/jar<\/pre>\n<p>check the JAVA version running on your system:<\/p>\n<pre>## java -version<\/pre>\n<h3><b>INSTALL TOMCAT 8<\/b><\/h3>\n<p>Create a separate user which will run the Tomcat server:<\/p>\n<pre>## useradd -r tomcat8 --shell \/bin\/false<\/pre>\n<p>Download the latest Tomcat 8 version from <a title=\"Tomcat Downloads\" href=\"http:\/\/tomcat.apache.org\/download-80.cgi\" target=\"_blank\">here<\/a> or use the following command to download Tomcat 8.0.5<\/p>\n<pre>## wget http:\/\/mirrors.koehn.com\/apache\/tomcat\/tomcat-8\/v8.0.5\/bin\/apache-tomcat-8.0.5.tar.gz -P \/tmp<\/pre>\n<p>Extract the contents of the Tomcat archive to <code>\/opt<\/code> using the following command:<\/p>\n<pre>## tar -zxf \/tmp\/apache-tomcat-8.0.5.tar.gz -C \/opt<\/pre>\n<pre>## ln -s \/opt\/apache-tomcat-8.0.5 \/opt\/tomcat-latest\r\n## chown -hR tomcat8: \/opt\/tomcat-latest \/opt\/apache-tomcat-8.0.5<\/pre>\n<h3><b>START THE TOMCAT 8 SERVICE<\/b><\/h3>\n<p>Create the following init script in <code>\/etc\/init.d\/tomcat8<\/code><\/p>\n<pre>#!\/bin\/bash\r\n#\r\n# tomcat8\r\n#\r\n# chkconfig: - 80 20\r\n#\r\n### BEGIN INIT INFO\r\n# Provides: tomcat8\r\n# Required-Start: $network $syslog\r\n# Required-Stop: $network $syslog\r\n# Default-Start:\r\n# Default-Stop:\r\n# Description: Tomcat 8\r\n# Short-Description: start and stop tomcat\r\n### END INIT INFO\r\n\r\n## Source function library.\r\n#. \/etc\/rc.d\/init.d\/functions\r\nexport JAVA_HOME=\/usr\/java\/default\r\nexport JAVA_OPTS=\"-Dfile.encoding=UTF-8 \\\r\n  -Dnet.sf.ehcache.skipUpdateCheck=true \\\r\n  -XX:+UseConcMarkSweepGC \\\r\n  -XX:+CMSClassUnloadingEnabled \\\r\n  -XX:+UseParNewGC \\\r\n  -XX:MaxPermSize=128m \\\r\n  -Xms512m -Xmx512m\"\r\nexport PATH=$JAVA_HOME\/bin:$PATH\r\nTOMCAT_HOME=\/opt\/tomcat-latest\r\nTOMCAT_USER=tomcat8\r\nSHUTDOWN_WAIT=20\r\n\r\ntomcat_pid() {\r\n  echo `ps aux | grep org.apache.catalina.startup.Bootstrap | grep -v grep | awk '{ print $2 }'`\r\n}\r\n\r\nstart() {\r\n  pid=$(tomcat_pid)\r\n  if [ -n \"$pid\" ] \r\n  then\r\n    echo \"Tomcat is already running (pid: $pid)\"\r\n  else\r\n    # Start tomcat\r\n    echo \"Starting tomcat\"\r\n    ulimit -n 100000\r\n    umask 007\r\n    \/bin\/su -p -s \/bin\/sh $TOMCAT_USER $TOMCAT_HOME\/bin\/startup.sh\r\n  fi\r\n\r\n\r\n  return 0\r\n}\r\n\r\nstop() {\r\n  pid=$(tomcat_pid)\r\n  if [ -n \"$pid\" ]\r\n  then\r\n    echo \"Stoping Tomcat\"\r\n    \/bin\/su -p -s \/bin\/sh $TOMCAT_USER $TOMCAT_HOME\/bin\/shutdown.sh\r\n\r\n    let kwait=$SHUTDOWN_WAIT\r\n    count=0;\r\n    until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]\r\n    do\r\n      echo -n -e \"\\nwaiting for processes to exit\";\r\n      sleep 1\r\n      let count=$count+1;\r\n    done\r\n\r\n    if [ $count -gt $kwait ]; then\r\n      echo -n -e \"\\nkilling processes which didn't stop after $SHUTDOWN_WAIT seconds\"\r\n      kill -9 $pid\r\n    fi\r\n  else\r\n    echo \"Tomcat is not running\"\r\n  fi\r\n \r\n  return 0\r\n}\r\n\r\ncase $1 in\r\nstart)\r\n  start\r\n;; \r\nstop)   \r\n  stop\r\n;; \r\nrestart)\r\n  stop\r\n  start\r\n;;\r\nstatus)\r\n  pid=$(tomcat_pid)\r\n  if [ -n \"$pid\" ]\r\n  then\r\n    echo \"Tomcat is running with pid: $pid\"\r\n  else\r\n    echo \"Tomcat is not running\"\r\n  fi\r\n;; \r\nesac    \r\nexit 0<\/pre>\n<p>make the script executable using <code>chmod<\/code><\/p>\n<pre>## chmod +x \/etc\/init.d\/tomcat8<\/pre>\n<p>Start the Tomcat 8 server using:<\/p>\n<pre>## service tomcat8 start<\/pre>\n<p>Add the Tomcat 8 service to system startup:<\/p>\n<pre>## chkconfig tomcat8 on<\/pre>\n<p>Access your newly installed Tomcat at http:\/\/YOUR_IP:8080<\/p>\n","protected":false},"excerpt":{"rendered":"<p>## screen -U -S tomcat8-screen ## yum update INSTALL JAVA 8 <\/p>\n<p>Download the latest JAVA 8 from here or use the following command to download JAVA JDK 8u5:<\/p>\n<p>for 32bit systems use:<\/p>\n<p> ## wget &#8211;no-cookies \\ &#8211;no-check-certificate \\ &#8211;header &#8220;Cookie: oraclelicense=accept-securebackup-cookie&#8221; \\ &#8220;http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u5-b13\/jdk-8u5-linux-i586.rpm&#8221; \\ -O \/opt\/jdk-8-linux-i586.rpm <\/p>\n<p>for 64bit systems use:<\/p>\n<p> ## wget &#8211;no-cookies \\ &#8211;no-check-certificate [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5696"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5696"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5696\/revisions"}],"predecessor-version":[{"id":5697,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5696\/revisions\/5697"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}