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:

(Internet) http://www.cnblogs.com/sixiweb/archive/2012/11/25/2787684.html

Or the previous page:

(Intranet) CentOS uninstall the built-in OpenJDK and install the Sun JDK method.

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 documentationProduct 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/ipdables

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
  • Linux 18
  • Centos 1
  • Tomcat 1
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=256m -XX:MaxPermSize=512m" 

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

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.