First, install the JDK
Go to the Java website to download the latest Jdk,java SE Downloads
Decompression, TAR-ZXVF jdk-7u45-linux-i586.tar.gz, will extract the generated jdk1.7.0_45 into the directory you need to place, I placed in the/usr/share/directory
Configure Environment variables
1.java_home Environment variables
Function: It points to the installation directory of the JDK, and software such as Ecplise/netbeans/tomcat to find and use the installed JDK by searching Java_home variables
Configuration method:
echo java_home=/usr/share/jdk1.7.0_45 >> ~/.bashrc
Source BASHRC
2.PATH environment variable
Function: is the command search path, when the command is executed under the shell, it will go to the path variable to find the paths specified to see if the appropriate command program can be found. We need to add the bin directory under the JDK installation directory to the existing PATH variable
Configuration method:
Vim. BASHRC
#增加java的PATH路径
export java_home=/usr/share/jdk1.7.0_45
export path= $JAVA _home/bin: $PATH
source. BASHRC
Attention:
You need to append the newly added JDK's Bin directory to the top of the $path, so that when multiple JDK versions are installed in the system, the program will first search for the most previous JDK version
Verify:
3.CLASSPATH environment variable
Role: Specify class search paths, use classes that have already been written, and, of course, be able to find them, and the JVM is looking for classes through classpath. We need to set the Dt.jar, Tools.jar in the Lib subdirectory of the JDK installation directory to classpath, of course, the current directory "." must also be added to the variable
Configuration:
Vim. BASHRC
export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
source. BASHRC
Tip: Do not use echo $CLASSPATH, because Linux will automatically replace $java_home with/usr/share/jdk1.7.0_45, but this variable should be variable, you should know what I mean, that is, programming needs to reject hard code
Verify
View the Java version
Second, the installation of Tomcat
1, first from the official website of Apache download down tomcat6.0 series of documents, http://www.apache.org/tomcat/ Here to find Tomcat6.0 Linux installation files, it is not the same as Windows, the official web has a corresponding description, Linux version of Tomcat is required to compile the source code files, such as download the file as follows: Apache-tomcat-6.0.30.zip
2, will download the file through FTP to the Linux, here I recommend remote Connection Tool Ssh,linux Remote Connection tool more.
3, decompression Apache-tomcat-6.0.30.zip, the command is: Unzip Apache-tomcat-6.0.30.zip get apache-tomcat-6.0.30 This directory, copy the directory to the/opt/, and then to facilitate the change of name to /opt/tomcat can be.
4, modify the environment variables, the variable configuration will be placed before the JDK environment variables to configure the following can be, as follows:
Modify the profile file under the directory/etc, using the command:
Modified as follows:
Export Catalina_home=/opt/tomcat
export classpath=.: $JAVA _home/lib: $CATALINA _home/lib
Export path= $PATH: $ Catalina_home/bin
Execute command after configuration complete: source/etc/profile, if no error is prompted, prove configuration ok
You can view the environment configuration through the Echo $CLASSPATH
5. Start Tomcat Service
Switch directories to Opt/tomcat/bin to perform SH catalina.sh, prompting the following information:
The BASEDIR environment variable is isn't defined correctly this
environment variable be needed to run
This type of error is reported after the condition configuration is complete, which indicates that the associated. sh suffix file in the bin directory does not have execute permissions and uses the command chmod +x *.sh to give all. sh files permission to execute.
After the execution of SH catalina.sh or sh startup.sh, it prompts the following information to indicate configuration 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, look at Tomcat service port 8080
Command: Netstat-ntl | grep 8080, which prompts for normal, uses tenlet IP 8080 from Windows clients to see what happens, the result indicates that the port is not turned on, and continue to check the firewall as follows:
Locate/etc/sysconfig/,vi iptables The configuration of the firewall configuration file to add open 8080 ports is as follows:
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 8080-j ACCEPT
There is another way to turn off the firewall, the command is: Service iptables stop.
7, in the client access Tomcat home
http://localhost:8080/if the normal display of Tomcat home indicates that the configuration OK.
8, deploy a Web project
upload the file as a Ssh2.war package to the Opt/tomcat/webapps directory, and then restart Tomcat as follows:./catalina.sh run, deploy Ssh2.war, and Start Tomcat
on the client input HTTP://LOCALHOST:8080/SSH2, showing the login page indicates that the project was successfully deployed.