Install Tomcat 7 for CentOS6 and start it automatically

Source: Internet
Author: User

Due to training for enterprises and the fact that PHP is used too much in the past few years, the server is gradually built using JavaEE.
JDK 7 and 8 have been downloaded, but you are not familiar with it. Therefore, you can download JDK 7. Here we will not talk about how to install JDK 7.
Currently, the latest Tomcat version is 8.0.5, but I still download version 7.0. Because the Embedded Server plug-in Eclipse JavaEE version supports 7.0 and does not support 8.0, I don't want to work hard.
Download and unzip Tomcat to/usr/local/tomcat-7.0
[Rafael @ centos6 Downloads] $ tar zxvf apache-tomcat-7.0.53.tar.gz
[Rafael @ centos6 Downloads] $ mv apache-tomcat-7.0.53/usr/local/tomcat-7.0
[Rafael @ centos6 Downloads] $ cd/usr/local
Create tomcat users and groups, but do not create the home folder ael @ centos6 local] $ sudo useradd-M tomcat [rafael @ centos6 local] $ sudo chown-R tomcat. tomcat-7.0/

Create a daemon on/etc/init. d. Compile the jsvc: [rafael @ centos6 local] $ cd Tomcat-7.0/bin/
[Rafael @ centos6 bin] $ tar zxvf commons-daemon-native.tar.gz [rafael @ centos6 bin] $ cd commons-daemon-1.0.15-native-src/unix/[rafael @ centos6 unix] $ sudo. /configure -- with-java =/usr/java/default
[Rafael @ centos6 unix] $ sudo make
[Rafael @ centos6 unix] $ sudo cp jsvc ../..
[Rafael @ centos6 unix] $ sudo cd ../..

Edit daemon. sh and add a line at the beginning. chkconfig is supported. The added line is as follows :#! /Bin/sh # chkconfig:-85 15
After the script is commented out, add the following two lines before executing the command: export JAVA_HOME =/usr/java/default
Export CATALINA_HOME =/usr/local/tomcat-7.0
Modify the value of ARG0 as follows:
ARG0 = "/usr/local/tomcat-7.0"

Set daemon. put sh in/etc/init. d, and configure the service to start [rafael @ centos6 unix] $ sudo cp daemon. sh/etc/init. d/tomcatd [rafael @ centos6 bin] $ cd/etc/init. d/
[Rafael @ centos6 init. d] $ sudo chkconfig -- add tomcatd
[Rafael @ centos6 init. d] $ sudo chkconfig -- level 2345 tomcatd on
The last sentence above is to enable tomcat to start automatically at the linux2, 3, 4, and 5 startup levels.
Finally, start tomcat: [rafael @ centos6 init. d] $ cd [rafael @ centos6 ~] $ Sudo service tomcatd start
Open the browser and access: localhost: 8080. Is it okay?
PS: Learn how to configure Tomcat on your own.

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.