Linux installation JDK and Tomcat

Source: Internet
Author: User

First, install the JDK

1, upload the installation file (example:jdk-6u21-linux-i586.bin) to the directory you want to install, installed here in


2. Installation:

#chmod a+x Jdk6u21-linux-i586.bin ← Enable the current user to have Execute permission (first to the current directory, then to execute both lines of command)

#./jdk6u21-linux-i586.bin

Modify the JDK folder name after installation

MV jdk1.6.0_21/jdk1.6.0 #改为jdk1.6.0

3. Configuration Environment Change

# vi/etc/profile

Add the following to the third line of the countdown, which must be above the last two lines.

Export Java_home =/usr/java/jdk1.6.0

Export CLASSPATH = .: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Export PATH = $PATH: $JAVA _home/bin

The following is to verify that the variable setting is in effect ( logout before verification , then re-login);

[email protected] rpm]#Echo $JAVA _home
/usr/java/j2sdk1.4.2_06/
[email protected] rpm]#Echo $CLASSPATH
/usr/java/j2sdk1.4.2_06/lib/dt.jar:/usr/java/j2sdk1.4.2_06/lib/tools.jar
[email protected] rpm]#Echo $PATH
/usr/java/j2sdk1.4.2_06/bin/:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/ Bin:/usr/sbin:/usr/bin:/usr/x11r6/bin:/root/bin
[email protected] rpm]#JAVA-version
JAVAVersion "1.4.2_06"
JAVA(TM) 2 Runtime environment, Standard Edition (build 1.4.2_06-b03)
JAVAHotSpot (TM) Client VM (build 1.4.2_06-b03, Mixed mode)

Environment settings OK, to see if the JDK works, let's write a test file Test.java

[email protected] rpm]#VI Test.java
class Test
{
Public static void Main (string[] args)
       {
System.out.println ("Hello world!");
       }
}


Save exit, below to compile, execute;

[[email protected] text]#  ]
[[email protected]  text]# 


Ok, it works fine.


Ii. installation of Tomcat


Description

Multiple tomcat words need to be modified in Tomcat/conf/server.xml to make the following changes

<server port= " 2 8005 "shutdown=" Shutdown ">

<connector port= " 2 8080 "maxhttpheadersize=" 8192 "usebodyencodingforuri=" true "

<connector port= " 2 8009 "maxthreads=" "minsparethreads=" "maxsparethreads="

more than 5 Tomcat, 6th has a problem, the maximum number of ports: 65535


\tomcat\bin\catalina.sh Modifying Memory

java_opts= '-server-xms the m-xmx1500m-xx:maxnewsize= + m-xx:maxpermsize=512m-djava.awt.headless=true '


1. Upload a valid tomcat file directly to the desired directory (example: see Attachment)

2. Add Tomcat user, configure permissions

/usr/sbin/groupadd Tomcat

/usr/sbin/useradd-s/bin/bash-g Tomcat Tomcat

/usr/sbin/usermod-l Tomcat #锁定密码 to invalidate the password (two lines above, used when no Tomcat user is available)

Then, the permissions to the Tomcat directory are given to the user tomcat

Chown-r Tomcat:tomcat/.../.../tomcat

The following limitations control methods are as needed: (Prevent malicious file upload and execution)

Bulk set the Tomcat directory and the following subdirectory permissions to 544,tomcat users and no write permissions.

However, the following three directories have to be handled in a special order: Logs,temp,work

Logs: Directory can prohibit execute permission (644) After Tomcat boot, write permission cannot be forbidden; turn on execute permission when Tomcat is turned off (744)

Temp:tomcat users to have maximum permissions, the operation process needs to read, write, execute

Work: Normally shutting down Tomcat cleans up the files, and the process needs to be read, written, and executed. However, you can disallow write access to the previous levels of the directory.


Other than that:

Servers with the Tomcat service are prohibited from executing permissions on the/tmp directory.

#chmod-R 1666/tmp

This directory is very special, can be viewed: http://ycgit.blog.51cto.com/8590215/d-2


3, upload the Tomcat boot file to/etc/init.d/(see attachment, the TOMCAT/JDK directory in the file needs to be modified as needed),

chmod 755/etc/init.d/tomcat

Chown-r Tomcat:tomcat/etc/init.d/tomcat


4. shortcut key Settings

#alias # View currently existing shortcuts

#alias cdtom3= ' cd/usr/local/tomcat3/' # new ( This way to quit is useless )

Increase (Exit re-login only takes effect) in the following ways

#cd

#vi. BASHRC

Add the following

Alias cdtom= ' CD/.../.../tomcat/'


5. mount files, establish soft links (as needed)

Mount Files (NFS server)

#mount-T NFS 0.0.0.88:/web/web

Create a soft link

Ln-s/.../.../root//usr/local/tomcat/webapps/


6. Set Tomcat boot mode, boot start

VI /etc/rc.d/rc.local

Add to:

Export jdk_home=/usr/java/jdk1.6.0

Export java_home=/usr/java/jdk1.6.0

/etc/init.d/tomcat start

Mount-t NFS 0.0.0.88:/web/web


Attachment Description: A tomcat-related file that is sent to the Download Center. Because the JDK file is not transmitted over 50M.



Linux installation JDK and Tomcat

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.