Premise
Apache is a Web server environment program that enables him to be used as a Web server. However, only static web pages are supported, and dynamic Web pages are not supported, such as ASP, JSP, PHP, CGI.
If you want to run the JSP in an Apache environment, you need an interpreter to execute the JSP Web page, and this JSP interpreter is Tomcat
Then why do we need the JDK? Since the JSP needs to connect to the database, the JDK is required to provide the drive to connect to the database, so the Web server platform to run the JSP needs APACHE+TOMCAT+JDK
Benefits of Consolidation:
If the client is requesting a static page, only the Apache server responds to the request
If the client requests a dynamic page, the Tomcat server responds to the request
Because JSP is a server-side interpretation code, consolidation can reduce the service overhead of Tomcat
Apache is a C language implementation, supporting a variety of features and modules to extend the core functions, Tomcat is written in Java, better support servlet and JSP.
First, create a user
If only the root user needs to create a user for Tomcat to run independently
Adduser-g users-s/bin/bash-d/opt/xxx xxx-g is the group-s designated user login after the shell-d is to create this user's directory, by default in the/home directory XXX own name, the first/opt/ XXX is the directory name, the last xxx is the user name to create
Second, install jdk1.7 (click to download)
1. Preparation
Querying the current system for Jdkrpm-qa|grep JDK removal JDKRPM-E service name (from above query)
2. Installation
Download the JDK installation package to a directory such as:/opt/mao in the current directory where the JDK is placed use the root account to run the command RPM-IVH jdk-7u21-linux-i586.rpm successfully enter Update-alternatives--install/ Usr/bin/java Java/usr/java/jdk1.7.0_21/bin/java 60update-alternatives--config Java then choose the JDK version, choose 1, enter
3. Modifying variables
Switch to the home directory of the newly created user you can also use the command switch su-xxx to run command VI with root privileges. BASHRC at the end of the file, enter export Java_home=/usr/java/jdk1.7.0_21export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jarexport path= $PATH: $JAVA _home/ Bin (the error that is often made here is that the path is not set correctly, we mainly modify the Java_home path according to the actual situation.) Check under your/usr/java, if there is a jdk1.7.0_21, if you have 64-bit, it must be wrong. Modify the path here according to your actual situation java_home=/usr/java/jdk1.7.0_21) (another mistake is to direct WPS to open this document and copy the above content.) After pasting export is not a space, but programming it? , modify it yourself)
5. Variable takes effect
source. BASHRC
Run
Java-version
If there is a version prompt, the installation succeeds
Three. Install TOMCAT7 (click to download)
1. Preparation
Place the apache-tomcat-7.0.63.tar.gz under/opt tar-xzvf apache-tomcat-7.0.63.tar.gz unzip the installation package MV apache-tomcat-7.0.63/opt/xxx/ Tomcat7 the extracted files are moved to the user directory renamed TOMCAT7------CENTOS6 use--------------------------------Add the trust port on the firewall vi/etc/sysconfig/ iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dpor T 8080-j accept as above, copy the previous line, change 22 to 8080,esc:wq! , Exit Save service iptables Restart Restart firewall-----CENTOS7 use-----------------------------------systemctl stop Firewalld.service Close Firewall command------------------supplemental content without action----------------------systemctl start firewalld.service# Start Firewall--systemctl stop firewalld.service# stop firewall--systemctl disable firewalld.service# Disable firewall boot--firewall-cmd--zone=public--add-port=80/tcp--permanent--command meaning:--zone #作用域--add-port=80/tcp #添加端口, The format is: Port/Communication protocol--permanent #永久生效, without this parameter restart after failure--open the permanent port number: Firewall-cmd--add-port=8020/tcp--permanent--Query port number: Firewall-cmd- -query-port=8020/tcp--Restart Firewall: Firewall-cmd--reload
3. Installation
After entering/tomcat7/bin./startup.sh execution, Tomcat is turned on to successfully display Tomcat service star ... You can then open the browser in the client login/HTTP//native ip:8080/
4. Modify the port number
Modify port number if port number is occupied
Vi/opt/xxx/tomcat7/conf/server.xml input/Enter lookup mode input 8080, press n next to change 8080 to another port on the line
5. View the Tomcat boot log
Vi/opt/xxx/tomcat7/logs/catalina.out
6. Where to place the application server
/opt/xxx/tomcat7/webapps/xxxx.war
Put the Wae bag below, restart Tomcat or wait for a moment to unzip it automatically. Other compressed packages can also be extracted directly under this WebApps directory. The war can be decompressed with unzip.
Let's try it on the. War pack. If you can open in IE, then you have installed the environment.
7. Query commands
Ps–ef |grep Java (tomcat) to see if the process is started
Netstat–an |grep 8080 to see if the port is occupied
Kill-9 PID Forced termination process
Four. Introduction to Remote Connection tool
sshsecureshellclient--has a graphical interface and command interface, but the Chinese support is not good (click to download)
winscp--has a graphical interface and command interface, Chinese support is good, the command line need to input data easy problem (click to download)
putty--Green Convenient, only with command port (click to download)
Environment Build--linux Install Tomcat