Install Tomcat 7 on centos6

Source: Internet
Author: User

1: uninstall the built-in openjdk

2: Install jdk1.6

3: install Tomcat

4: Configure tomcat to start in daemon mode

The following is officially started:

 

========================================================== ==============

1: uninstall the built-in openjdk

2: Install jdk1.6

 

Refer:

Http://www.cnblogs.com/sixiweb/archive/2012/11/25/2787684.html

 

Original article:

 

View the current system JDK: rpm-Qa | grep JDK

Result:

[Root @ dc-01 Java] # rpm-Qa | grep JDK

Java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.i686

 

Detach:

 [Root @ dc-01 Java] # Yum-y remove java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.i686

 

 

Wait for a while to complete.

Download Sun's JDK. I downloaded

Jdk-6u37-linux-i586-rpm.bin

For a 64-bit system, download:

Jdk-6u37-linux-x64-rpm.bin

And other 64-bit dedicated packages

 

Create a Java directory under the/usr directory and put the downloaded file under the/usr/Java directory

Change the file to an executable file (chmod 777 ):

[Root @ dc-01 Java] # chmod 777 jdk-6u37-linux-i586-rpm.bin

Then execute this file to install it:

[Root @ dc-01 Java] #. /jdk-6u37-linux-i586-rpm.bin unpacking... checksumming... extracting... unzipsfx 5.50 of 17 February 2002, by Info-zip (Zip-Bugs@lists.wku.edu ). inflating: jdk-6u37-linux-i586.rpm inflating: sun-javadb-common-10.6.2-1.1.i386.rpm inflating: sun-javadb-core-10.6.2-1.1.i386.rpm inflating: sun-javadb-client-10.6.2-1.1.i386.rpm inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm preparing... ######################################## ### [100%] 1: JDK ####################################### #### [2, 100%] unpacking jar files... rt. jar... JSSE. jar... charsets. jar... tools. jar... localedata. jar... plugin. jar... javaws. jar... deploy. jar... installing javadbpreparing... ######################################## ### [100%] 1: sun-javadb-common ################################### ####### [17%] 2: sun-javadb-core ################################### ####### [33%] 3: sun-javadb-client ################################### ####### [1, 50%] 4: sun-javadb-demo ################################### ####### [67%] 5: sun-javadb-docs ################################### ####### [83%] 6: sun-javadb-javadoc ################################### ######## [1, 100%] Java (TM) se Development Kit 6 successfully installed. product registration is free and has des between benefits: * notification of new versions, patches, and updates * special offers on Oracle products, services and Training * access to early releases and documentation product and system data will be collected. if your configurationsupports a browser, the JDK product registration form willbe presented. if you do not register, none of this informationwill be saved. you may also register your JDK later byopening the register.html file (located in the JDK installationdirectory) in a browser. for more information on what data registration collects and how it is managed and used, see: http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press enter to continue .....

 

 

Press enter.

Done appears.

 

The installation is now complete.

 

Configure JDK:

 VI/etc/profile open the profile file and add the following at the end of the profile file:

Java_home =/usr/Java/jdk1.6.0 _ 37 Path = $ java_home/bin: $ pathclasspath =.: $ java_home/lib/DT. jar: $ java_home/lib/tools. jarexport java_homeexport pathexport classpath

 

 

 

Save and close the profile file, and run the source/etc/profile command to make the modification take effect.

Run Java-version to check the Java version:

[Root @ dc-01 Java] # Java-version

Java version "1.6.0 _ 37" Java (TM) se Runtime Environment (build 1.6.0 _ 37-b06) Java hotspot (TM) Client VM (build 12-b01, mixed mode, sharing) [root @ dc-01 Java] #

========================================================== ==========

 

So far, the entire installation process is complete.

  

 

3: install Tomcat

Download apache-tomcat-7.0.33.tar.gz. Decompress:

 

Tar-xzvf apache-tomcat-7.0.33.tar.gz

Copy the decompressed folder to/usr/local/tomcat:

CP-r APACHE-Tomcat-7.0.33/usr/local/tomcat

Go to the Tomcat directory to set Tomcat memory usage and other configurations:

CD/usr/local/tomcat/bin

VI daemon. Sh

Add the following content at the beginning of the text (make sure to modify the JDK and other directories according to your actual situation ):

 

# Chkconfig: 2345 20 80 # Description: simple example to start tomcatjava_home =/usr/Java/jdk1.6.0 _ 37catalina_home =/usr/local/modules = "-xms1024m-xmx4096m-XX: permsize = 256 m-XX: maxpermsize = 512 M"

4: Configure tomcat to start in daemon mode

Copy daemon. Sh to the startup directory, install the service, and test the service:

Compile and install commons-daemon first:

Install GCC first, because it is required during compilation.

Yum install gcc

Create a tomcat user to run the Tomcat service:

Using root in the production environment is not safe, so

Useradd-S/sbin/nologin Tomcat

Chown-r Tomcat: tomcat/usr/local/tomcat

Started with the operating system as a service

 

# Tar-xzvf commons-daemon-native.tar.gz

# Cd commons-daemon-1.0.10-native-src/Unix

#./Configure

# Make

# Cp jsvc ../..

# Cd ../..

 

CP daemon. sh/etc/init. d/tomcat

Chmod 755/Etc/init. d/tomcat

Chkconfig -- add Tomcat

Chkconfig Tomcat on

Chkconfig -- list Tomcat

Display:

Tomcat 0: off 1: off 2: On 3: On 4: On 5: on 6: Off confirm 2 ~ 5. If the status is on, OK.

Start Tomcat:

Service Tomcat start

Add firewall configuration to allow port 8080:

# Vi/etc/sysconfig/iptables

Add one to allow SSH:

-A input-M state -- state new-m tcp-p tcp -- dport 8080-J accept

Save and restart the iptables service:

# Service iptables restart

 

Test:

Local test:

Wget http: // localhost: 8080/

Test from other machines:

Enter http: // localhost: 8080/in the browser/

Check whether the website can be opened.

 

========================================================== =

Refer to the blog below during the configuration process:

Http://batizhao.github.com/linux/2012/07/17/install-tomcat7-on-centos/

 

To prevent loss, repost it:

 

Install Tomcat 7 on centos6
    • Linux18
    • Centos1
    • Tomcat1
1. Download
 
# Wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.29/bin/apache-tomcat-7.0.29.tar.gz
2. Installation
# Tar-xzvf apache-tomcat-7.0.29.tar.gz # mv APACHE-Tomcat-7.0.29/opt/tomcat7 # cd/opt/tomcat7 # bin/startup. Sh
3. Configuration

Using root in the production environment is not safe, so

 
# Useradd-S/sbin/nologin Tomcat # chown-r Tomcat: tomcat/opt/tomcat7

Started with the operating system as a service

# Cd/opt/tomcat7/bin # tar-xzvf commons-daemon-native.tar.gz # cd commons-daemon-1.0.10-native-src/Unix #./configure # Make # cp jsvc.../# CD ../..

After the daemon. Sh comment, add the following five elements to the text

 
# Vim daemon. sh ---- # chkconfig: 2345 10 90 # Description: starts and stops the Tomcat daemon. java_home =/usr/Java/jdk1.6.0 _ 31 catalina_home =/opt/tomcat7 catalina_opts = "-xms1024m-xmx2048m-XX: permsize = 256 m-XX: maxpermsize = 512 M"

Add to service

# Cp daemon. sh/etc/init. d/tomcat # chkconfig -- add Tomcat

Check

 
# Chkconfig -- list | grep Tomcat 0: Disable 1: Disable 2: Enable 3: Enable 4: Enable 5: Enable 6: Disable

Open Port

 
# Vim/etc/sysconfig/iptables -----A input-M state -- state new-m tcp-p tcp -- dport 8080-J accept # service iptables restart
BaTi Zhao

17 July 2012 

 

 

========================================================== ==========================================================

 

 

 

 

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.