Most of my understanding about tomcat in apache open-source projects stays in Windows. This time I will use a simple example to introduce how to build a tomcat environment and deploy a web project in linux. Start with the basic installation, but do not underestimate the File Installation in linux. It is not completed by clicking next in windows, but it is not complicated, the important thing is that we learn how to use it to quickly understand and master it, so everything will become much easier. Let's get started. Of course, before installing and deploying tomcat, we must first install
Most of my understanding about tomcat in apache open-source projects stays in Windows. This time I will use a simple example to introduce how to build a tomcat environment and deploy a web project in linux.
Start with the basic installation, but do not underestimate the File Installation in linux. It is not completed by clicking next in windows, but it is not complicated, it is important that we learn how to quickly understand and master it, so everything becomes much easier. Let's get started. Of course, we must install the jdk1.6 environment before installing and deploying tomcat, for details, refer to the jdk installation in linux on the previous blog.
1. Download The tomcat6.0 series files from the Apache official website.
2. Transfer the downloaded file to linux via ftp. Here I recommend the remote connection tool SSH, and there are many linux remote connection tools.
3) decompress apache-tomcat-6.0.30.zip, the command is: unzip apache-tomcat-6.0.30.zip to get apache-tomcat-6.0.30 directory, copy the directory to/opt/, and then rename it to/opt/tomcat for convenience.
4. Modify the environment variable and place the following variable configuration after the jdk environment variable is configured as follows:
Modify the profile file in the/etc directory and run the following command: vi/etc/profile.
Export CATALINA_HOME =/opt/tomcat
Export CLASSPATH =.: $ JAVA_HOME/lib: $ CATALINA_HOME/lib
Export PATH = $ PATH: $ CATALINA_HOME/bin
After the configuration is complete, run the command: source/etc/profile. If no error is prompted, the configuration is OK.
You can use echo $ CLASSPATH to view the environment configuration.
5. Start the tomcat Service
Switch the directory to opt/tomcat/bin and execute sh catalina. sh. The following message is displayed:
The BASEDIR environment variable is not defined correctly
This environment variable is needed to run this program
After the configuration is complete, this type of error message will be reported, indicating that the bin directory is related. THE sh suffix file has no execution permission. Use the command chmod + x *. sh to all. sh file to execute permissions,
Run sh catalina. sh or sh startup. sh, and the following message is displayed, indicating that the configuration is OK:
Using CATALINA_BASE:/opt/tomcat
Using CATALINA_HOME:/opt/tomcat
Using CATALINA_TMPDIR:/opt/tomcat/temp
Using JRE_HOME:/usr/jdk1.6.0 _ 23
Using CLASSPATH:/opt/tomcat/bin/bootstrap. jar
6. View tomcat service port 8080
Command: netstat-ntl | grep 8080. A message is displayed, indicating that tenlet ip 8080 is used from the windows client. The result is that the port is not enabled. Continue to check the firewall as follows:
Find/etc/sysconfig/, vi iptables and add the following configuration to open port 8080 in the firewall configuration file:
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 8080-j ACCEPT
You can also disable the firewall by running the command "service iptables stop.
7. Visit the tomcat homepage on the client
Http: // localhost: 8080/If the tomcat homepage is displayed normally, the configuration is OK.
8. Deploy a web Project
Upload the ssh2.war package to the opt/tomcat/webapps directory and restart tomcat. run the following command:./catalina. sh run to deploy ssh2.war and start tomcat.
Enter http: // localhost: 8080/ssh2 on the client. The logon page indicates that the project is successfully deployed.
Through the above simple introduction to tomcat installation and deployment, and the problems encountered in the installation and deployment process are also described in detail, I also did the above operations myself. As a tester, building a testing environment is an indispensable part of our work process. Most web services will be deployed in linux based on the influence of linux, this is a development trend based on performance and security, so the knowledge of studying linux will greatly improve our skills.
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2