分享

CentOS  jdk mysql tomcat install

 鹰皇软件 2014-01-14

This tutorial will walk you through installing Tomcat 6 on CentOS 5. This installation assumes you have walked through the CentOS - Setup article.

Contents

Acquiring JRE/JDK

First we need to download JDK and JRE 6 for CentOS. Download the following files to your root directory (~) with 'wget'. Note that you may need to change the file names as they may have some URL variables added to the name. Be sure to *not* download the RPM files.

JDK Download

JRE Download

Installing

Now that we have the files downloaded we need to create an installation directory for Java.

sudo mkdir /usr/java
cd /usr/java

Now we need to execute the installation for Java Development Kit (JDK). In our example we will use specific file names. Keep in mind that your file names may vary.

sudo sh ~/jdk-6u14-ea-bin-b03-linux-amd64-10_mar_2009.bin

Press <space> to advance through the license agreement and type 'yes' to accept. Press <enter> to finish the installation.

Now we need to install the Java Runtime Edition (JRE). In our example we will use specific file names. Keep in mind that your file names may vary.

sudo sh ~/jre-6u14-ea-bin-b03-linux-amd64-10_mar_2009.bin

Press <space> to advance through the license agreement and type 'yes' to accept.

Verify the installation by typing ls. You should see two directories: jdk1.6.0_14 and jre1.6.0_14. Keep in mind that your version numbers may differ slightly.

Installing Ant and Tomcat

Next we will need to download and extract Apache Ant. Ant is an installation utility used by several Apache products.

To download Apache Ant you will need to visit the following website to download the installation file: http://ant./bindownload.cgi. Scroll down the page and find the .tar.gz under Current Release of Ant. Copy the URL and use wget to download the file to the /usr/share directory. Your version number may differ.

cd /usr/share
sudo wget http://mirror./pub/apache/ant/binaries/apache-ant-1.7.1-bin.tar.gz

Next we need to unpack that file so we can install it. Note that your version number may be different.

sudo tar -xzf apache-ant-1.7.1-bin.tar.gz

Now we need to download Tomcat 6 to the /usr/share directory. Go to http://tomcat./download-60.cgi and download the latest Core version. This will be located under the 'Binary Distributions' portion. Be sure to download the tar.gz package. Note that the version numbers may vary.

cd /usr/share
sudo wget http://apache./tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz

Now we need to unpack that archive. Note that your version number may be different.

sudo tar -xzf apache-tomcat-6.0.18.tar.gz

We need to create a symbolic link for Ant so other applications can easily find it. Be sure to select the correct version when you create your link.

sudo ln -s /usr/share/apache-ant-1.7.1/bin/ant /usr/bin

Set JAVA_HOME

We need to setup the JAVA_HOME environment variable so Tomcat can find Java. Be sure to change the directory name according to your version of Tomcat.

cd /usr/share/apache-tomcat-6.0.18/bin
sudo vi catalina.sh

This will bring up the vi window. After the first line (that reads #!/bin/sh) you need to add a new line. To insert a new line press the i key to enter insert mode. Enter the following:

JAVA_HOME=/usr/java/jdk1.6.0_14

** Be sure to adjust the directory name according to your JDK version **

Save the file by pressing the colon (:) key, typing wq, and then pressing <enter>.

Now it is time to test your Tomcat installation. Be sure to note the version number in your path.

cd /usr/share/apache-tomcat-6.0.18/bin
sudo ./startup.sh

If it successfully starts you should see something similar to this:

Using CATALINA_BASE:   /usr/share/apache-tomcat-6.0.18
Using CATALINA_HOME:   /usr/share/apache-tomcat-6.0.18
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-6.0.18/temp
Using JRE_HOME:       /usr/java/jdk1.6.0_14

If you want to check for errors you can run the following command:

less /usr/share/apache-tomcat-6.0.18/logs/catalina.out

To verify your Tomcat installation is working go to http://12.34.56.78:8080 in your web browser. Be sure to change 12.34.56.78 to your server's IP address.

Automating Startup

Right now Tomcat will not start up on it's own so we need to create a startup script for this. To do this:

cd /etc/init.d
sudo vi tomcat

Press i to enter insert mode and paste in the following:

    #!/bin/bash
    # chkconfig: 234 20 80
    # description: Tomcat Server basic start/shutdown script
    # processname: tomcat
    JAVA_HOME=/usr/java/jdk1.6.0_14
    export JAVA_HOME
    TOMCAT_HOME=/usr/share/apache-tomcat-6.0.18/bin
    START_TOMCAT=/usr/share/apache-tomcat-6.0.18/bin/startup.sh
    STOP_TOMCAT=/usr/share/apache-tomcat-6.0.18/bin/shutdown.sh
    start() {
    echo -n "Starting tomcat: "
    cd $TOMCAT_HOME
    ${START_TOMCAT}
    echo "done."
    }
    stop() {
    echo -n "Shutting down tomcat: "
    
    cd $TOMCAT_HOME
    ${STOP_TOMCAT}
    echo "done."
    }
    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    stop
    sleep 10
    start
    ;;
    *)
    echo "Usage: $0 {start|stop|restart}"
    esac
    exit 0
Be sure to change the following items in the above file:
* JAVA_HOME path
* TOMCAT_HOME path
* START_TOMCAT path
* STOP_TOMCAT path

Once you have those changes made, save the file and quit.

Now we need to change the permissions on the file.

sudo chmod 755 tomcat

We need to set the script to start with other system services and set the runlevels.

sudo /sbin/chkconfig --add tomcat
sudo /sbin/chkconfig --level 234 tomcat on

You can verify that it is listed by typing /sbin/chkconfig --list tomcat.

tomcat         	0:off	1:off	2:on	3:on	4:on	5:off	6:off

Test your shutdown and startup script.

sudo /sbin/service tomcat stop
sudo /sbin/service tomcat start

Tomcat 6 should now be installed under CentOS.

--Kelly Koehn 11:48, 25 March 2009 (CDT)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多