Red-Flag Linux + tomcat6

Source: Internet
Author: User

Red-Flag Linux + tomcat6

1. Environment Software

Red Flag Linux Desktop 6.0

Jdk-1_5_0_15-linux-i586-rpm.bin

Apache-tomcat-6.0.18.tar.gz

Copy the JDK and tomcat installation software to the/Public path.

2. Install JDK

Run the following command:

# Cd/Public
#./Jdk-1_5_0_15-linux-i586-rpm.bin

JDK installation path:/usr/Java/jdk1.5.0 _ 15

Set environment variables, edit the file/etc/profile, and add

------------------------------

Export java_home =/usr/Java/jdk1.5.0 _ 15
Export classpath = $ classpath: $ java_home/lib/tools. jar: $ java_home/lib/dt. jar :.
Export Path = $ path: $ java_home/bin
Export nls_characterset = zhs16gbk

------------------------------

Save the profile file and run the # source/etc/profile command to make the environment variable take effect.

Run the command # echo $ java_home to display the java_home path set in the environment variable:/usr/Java/jdk1.5.0 _ 15.

Test JavaProgram:

Create a helloworld. Java file in/public:

------------------------------

Public class helloworld {
Public static void main (string ARGs []) {
System. Out. println ("Hello, wrold ");
}
}

------------------------------

Then run the following command:

# Cd/tmp/mydwon
# Javac helloworld. Java
# Java helloworld

"Hello, world" indicates that the Java compiling and running environment has been set up.

3. tomcat installation

Run the following command:

# Cd/Public
# Gunzip apache-tomcat-6.0.18.tar.gz
# Tar-XF apache-tomcat-6.0.18.tar

Decompress the package to obtain the Apache-Tomcat-6.0.18 folder.

Copy all files in the Apache-Tomcat-6.0.18 folder to the installation path, such as/tomcat.

Set environment variables, edit the file/etc/profile, and add:

Export tomcat_home =/tomcat
 
Save the profile file and run the # source/etc/profile command to make the environment variable take effect.

Run the command # echo $ tomcat_home to display the tomcat_home path set in the environment variable:/tomcat.

Start Tomcat and run the following command:

# Cd/tomcat/bin
# Sh./startup. Sh

The console displays the following information:

------------------------------

Using catalina_base:/tomcat
Using catalina_home:/tomcat
Using catalina_tmpdir:/tomcat/temp
Using jre_home:/usr/Java/jdk1.5.0 _ 15

------------------------------

Local accessHttp: // 127.0.0.1: 8080You can see the index. jsp of Tomcat.

4. Tomcat Manager

Click Tomcat Manager. The user name and password are required.

Because no user name or password is set in Tomcat, you cannot access Tomcat web application manager.

Stop the Tomcat service and run the following command:

# Cd/tomcat/bin
# Sh./shutdown. Sh

Then edit the/tomcat/CONF/tomcat-users.xml file and add the following information:

------------------------------

<? XML version = '1. 0' encoding = 'utf-8'?>
<Tomcat-users>
<Role rolename = "Tomcat"/>
<Role rolename = "role1"/>
<Role rolename = "manager"/>
<Role rolename = "admin"/>
<User Username = "Tomcat" Password = "Tomcat" roles = "Tomcat"/>
<User Username = "role1" Password = "Tomcat" roles = "role1"/>
<User Username = "both" Password = "Tomcat" roles = "tomcat, role1"/>
<User Username = "admin" Password = "manager" roles = "Admin, Manager"/>
</Tomcat-users>

------------------------------

The specific content of the tomcat-users.xml file can refer to the settings in Tomcat under windows.

After Tomcat is started, accessHttp: // 127.0.0.1: 8080.

Click Tomcat Manager and enter the username admin and Password Manager to enter Tomcat web application manager.

You can manage and publish Web applications in Tomcat web application manager.

5. tomcat6 data source connection pool settings

In Linux, the Tomcat 6 data source connection pool is set in the same way as in windows.

Refer:Http://blog.csdn.net/jrq/archive/2008/07/29/2734957.aspx

Create/tomcat/CONF/Catalina/Path Structure and edit the XML file corresponding to the Web application.

It is roughly as follows:

------------------------------



auth =" Container "
type =" javax. SQL. datasource "
driverclassname =" oracle. JDBC. driver. oracledriver "
url =" JDBC: oracle: thin: @ 192.168.100.66: 1521: orcl "
username =" test "
Password =" test "
maxactive =" 50 "
maxidle =" 10 "
maxwait =" 5000 "/>

------------------------------

6. Set the Tomcat 6 service to start automatically

When Linux is started, programs in the/etc/rc. d directory are automatically executed.

You can set a script to start the Tomcat service.

Specific operations:

Edit the file tomcat in/etc/rc. d/init. d/as root. The format and content are as follows:

------------------------------

#! /Bin/bash
# Chkconfig: 2345 98 5
# Description: script to start/stop Tomcat
Case $1 in
Start)
Export java_home =/usr/Java/jdk1.5.0 _ 15
CD/tomcat/bin/
Sh./startup. Sh
;;
Stop)
Export java_home =/usr/Java/jdk1.5.0 _ 15
CD/tomcat/bin/
Sh./shutdown. Sh
;;
*)
Echo "Usage: $0 (START | stop )"
Exit 1
;;
Esac
Exit 0

------------------------------

Then change the permission: # chmod 775 Tomcat

Add to the auto start list: # chkconfig-add Tomcat

View Automatic startup settings: # chkconfig-list Tomcat

Run the following command to start and stop the service:

Start: # service Tomcat start
Or: #/etc/rc. d/init. d/tomcat start

Stop: # service Tomcat stop
Or: #/etc/rc. d/init. d/tomcat stop

In this case, you can view the service status in Control Panel-service of red-flag Linux.
Or you can use ntsysv to view the set service.

Note: The file format. The comments at the beginning of the file cannot be omitted.

#! /Bin/bash
# Chkconfig: 2345 98 5 -- The 2345 parameter of this row indicates the running level of the startup sequence number (s98) and the k5)
# Description: script to start/stop Tomcat -- this behavior is required and the service description information

If the description at the beginning of the file is lost, an error message is displayed when the # chkconfig command is executed: the service does not support chkconfig.

 

7. Set the JVM virtual memory of Tomcat 6 to optimize the service.

Open the % atat_home %/bin/Catalina. Sh file and find the following content:

------------------------------

If [$ have_tty-EQ 1]; then
echo "using catalina_base: $ catalina_base "
echo" using catalina_home: $ catalina_home "
echo" using catalina_tmpdir: $ catalina_tmpdir "
If [" $1 "=" debug "-o" $1 "=" javac "]; then
echo" using java_home: $ java_home "
else
echo" using jre_home: $ jre_home "
fi

------------------------------

Add the following content:

------------------------------
Catalina_opts = "$ catalina_opts-xms256m-xmx1024m $ jpda_opts"
Java_opts = "$ java_opts-djava. AWT. Headless = true"
Echo "using catalina_opts: $ catalina_opts"
Echo "using java_opts: $ java_opts"

------------------------------

Catalina_opts sets a minimum memory usage of 256 MB and a maximum of 1024 MB.

Set the startup parameter in java_opts: java_opts = "$ java_opts-djava. AWT. Headless = true". This parameter is mainly used to process images, such as images that cannot be displayed and thumbnails generated.

Save it as follows:

------------------------------
If [$ have_tty-EQ 1]; then
Echo "using catalina_base: $ catalina_base"
Echo "using catalina_home: $ catalina_home"
Echo "using catalina_tmpdir: $ catalina_tmpdir"
If ["$1" = "debug"-o "$1" = "javac"]; then
Echo "using java_home: $ java_home"
Else
Echo "using jre_home: $ jre_home"
Fi
Catalina_opts = "$ catalina_opts-xms256m-xmx1024m $ jpda_opts"
Java_opts = "$ java_opts-djava. AWT. Headless = true"
Echo "using catalina_opts: $ catalina_opts"
Echo "using java_opts: $ java_opts"
Fi
------------------------------

Restart tomcat.

 

[-- End --]

By jrq
 
2009/01/16 in Beijing

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.