Installation and configuration of Tomcat under Linux

1. Download and install the corresponding jdk, and configure the Java environment.

Official website download address:

http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html

Download and pressurize the jdk and put it in the /usr/local directory:

 [root@master ~]#chmod 755 jdk-6u5-linux-x64.bin

[root@master ~]# ./jdk-6u5-linux-x64.bin

[root@master ~]#mv jdk1.6.0_05 /usr/local

 

Establish a jdk soft connection under /usr/local/ to facilitate future version upgrades:

 [root@master ~]# ln -s /usr/local/jdk1.6.0_05/ /usr/local/jdk

 

Configure environment variables:

Add the following to /etc/profile:

JAVA_HOME=/usr/local/jdk1.6.0_05

JAVA_BIN=/usr/local/jdk1.6.0_05/bin

PATH=$PATH:$JAVA_BIN

CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME JAVA_BIN PATH CLASSPATH

save and exit

[root@master ~]source /etc/profile

 

Check if the java environment variable takes effect

[root@master ~]# java -version

Java version "1.6.0_05"

Java(TM) SE Runtime Environment (build 1.6.0_05-b13)

Java HotSpot(TM) 64-Bit Server VM (build 10.0-b19, mixed mode)

Test succeeded

two. Download and install tomcat ( http://tomcat.apache.org/ )

[root@master ~]# unzip apache-tomcat-6.0.30.zip

[root@master ~]# mv apache-tomcat-6.0.30/ /usr/local/

[root@master ~]cd /usr/local/

[root@master local]# ln -s /usr/local/apache-tomcat-6.0.30/ /usr/local/tomcat

[root@master local]# cd tomcat/bin/

[root@master bin]#ls

[root@master bin]#vim catalina.sh

Add the following:

CATALINA_HOME=/usr/local/apache-tomcat-6.0.30/

[root@master local]#chmod +x *.sh

three. Start the tomcat server

[root@master tomcat]# /usr/local/tomcat /bin/catalina.sh start

Using CATALINA_BASE:   /usr/local/apache-tomcat-6.0.30/

Using CATALINA_HOME:   /usr/local/apache-tomcat-6.0.30/

Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.30//temp

Using JRE_HOME:        /usr/local/jdk1.6.0_05

Using CLASSPATH:       /usr/local/apache-tomcat-6.0.30//bin/bootstrap.jar

[root@master logs]# cd /usr/local/tomcat/logs/

[root@master logs]# tail -f catalina.out

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:597)

        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)

        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Jul 4, 2011 11:06:57 AM org.apache.coyote.http11.Http11Protocol pause

INFO: Pausing Coyote HTTP/1.1 on http-8080

Jul 4, 2011 11:06:58 AM org.apache.catalina.core.StandardService stop

INFO: Stopping service Catalina

Jul 4, 2011 11:06:58 AM org.apache.coyote.http11.Http11Protocol destroy

INFO: Stopping Coyote HTTP/1.1 on http-8080

Four. Type in the browser

http://localhost:8080/ (if not local, enter the corresponding ip address)

The test is successful if the tomcat page appears in the test

ps: It should be noted that the default test page of tomcat is placed under webapps, which is actually configured in the server.xml file, as shown below:

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

[root@SOR_SYS apache-tomcat-6.0.30]# ls
LICENSE  NOTICE  RELEASE-NOTES  RUNNING.txt  bin  conf  lib  logs  temp  webapps  work

 

         1) The webapps folder is mainly used for web application deployment. For example, you can copy your application package, such as war file, to this directory, and the container will be automatically deployed.
  2) The conf folder is mainly to place the relevant configuration files of the tomcat server

 

Fives. Add the app and test again

Put the test package in the webapps directory ( note: the application package is mainly placed under the webaapps directory. War will be automatically decompressed after tomcat restarts access )

[root@master webapps]# pwd
/usr/local/tomcat/webapps

[root@master webapps]# tar -zxvf moni2.tar.gz

[root@master webapps]# ls
docs  examples  host-manager  manager
  moni2  moni2.tar.gz  ROOT

[root@master webapps]# /usr/local/tomcat/bin/catalina.sh start(重启tomcat)
Using CATALINA_BASE:   /usr/local/apache-tomcat-6.0.30/
Using CATALINA_HOME:   /usr/local/apache-tomcat-6.0.30/
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.30//temp
Using JRE_HOME:        /usr/local/jdk1.6.0_05
Using CLASSPATH:       /usr/local/apache-tomcat-6.0.30//bin/bootstrap.jar

Enter the following address in your browser:

http://192.168.55.229:8080/moni2/

 

 

 six. Modify the listening port of tomcat

[root@master ~]#  cd  /usr/local/tomcat/conf

[root@master ~]# ls

[root@master ~]# vim server.xml

<Server port="8005" shutdown="SHUTDOWN">[port when tomcat is stopped]

 <Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" /> [The default listening port of tomcat is 8080, now it is changed to 8081]

 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />[ The port to access tomcat in apache+tomcat mode]

Now restart tomcat. Visit http://192.168.55.229:8081 / moni2/ [Note: You need to modify the port at this time, hehe. . .

 

 

 seven. Create tomcat instance

If the address we are using now is: 192..168.55.229, if we want to create a tomcat instance on this machine, but the script we create the instance is online on the server 192.168.55.233, then what do we need to do, please see the following step:

[root@master ~]# mount -t nfs 192.168.55.233:/opt/nfs /nfs [mount directory]

[root@master ~]# cd /nfs/

[root@master nfs]# ls
tcfile

[root@master nfs]# cd tcfile/
[root@master tcfile]# ls
backupfile  deployfile  instancefile

[root@master instancefile]# ls
tomcatTemplate  tomcatTemplate.zip

[root@master instancefile]# cd tomcatTemplate
[root@master tomcatTemplate]# ls
bin  conf  lib  LICENSE  logs  NOTICE  RELEASE-NOTES  RUNNING.txt  temp  webapps  work

[root@master tomcatTemplate]# cd bin
[root@master bin]# ls
bootstrap.jar       commons-daemon.jar            createResource.sh  resource.properties  startup.bat           tool-wrapper.sh
c3p0.template       commons-daemon-native.tar.gz  digest.bat         setclasspath.bat     startup.sh            version.bat
catalina.bat        cpappend.bat                  digest.sh          setclasspath.sh      tomcat-juli.jar       version.sh
catalina.sh         createInstance.sh             encrypt.bat        shutdown.bat         tomcat-native.tar.gz
catalina-tasks.xml  createInstance.sh.bak         encrypt.sh         shutdown.sh          tool-wrapper.bat

[root@master bin]# sh createInstance.sh tomcatServer229-1【创建实例】
/nfs/tcfile/instancefile/tomcatTemplate
New instance tomcatServer229-1 has successfully builded, and
shutdown.port=10001
ajp.port=8011
http.port=8081
https.port=8041
jmx.port=6901


[root@master bin]# cd /opt/ Oracle /tomcat/ [can be viewed under this directory]
[root@master tomcat]# ls
tomcatServer229-1 [naming rules, the default is tomcat name +-n indicates the number An example; in fact, there is a format specified in the script]
[root@master tomcat]#

 

Experience it yourself:

tomcat

1. Multiple items can be arranged

2. Static projects, such as html type pages, can be placed in several projects without configuration, otherwise, it is not possible, and needs to be configured

3.tomcat can be used directly after decompression

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326381546&siteId=291194637