Tomcat
Environment: VMS
Centos1:192.168.1.1/24
Centos2:192.168.1.2/24
Rehl:192.168.1.3/24
CentOS 1
#yum开始
Mount the image and connect
Mount /dev/cdrom/mnt/Mountwrite-protected, mounting read-only
Delete the existing Yum configuration file and write your own
rm -rf/etc/yumrepos.d/*vim/etc/yum.repos.d/yum.repo [yum] Name=yum Install baseurl=file:///mnt/ enabled=1 gpgcheck=0
Yum-y Install bind #测试
#yum结束
Close Iptables Firewall
Service Iptables Stop
The installation package that needs to be used,
Apache-tomcat-7.0.54.tar.gz #tomcat安装包
Nginx-1.6.0.tar.gz #nginxweb服务安装包
Jdk-7u65-linux-x64.gz #java环境安装包
Unzip all to/usr/src/
#java开始
TAR-ZXVF jdk-7u65-linux-x64.gz-c/usr/src/
Delete the original Java environment
[Email protected] ~]# Rm-rf/usr/bin/java
[Email protected] ~]# Rm-rf/usr/bin/javac
[Email protected] ~]# cd/usr/src/
[[email protected] src]# ls
Debug jdk1.7.0_65 Kernels
[Email protected] src]# MV jdk1.7.0_65//usr/local/java
[Email protected] src]# vim/etc/profile.d/java.sh
Export java_home=/usr/local/JAVA #设置java路径export PATH= $PATH: $JAVA _home/bin
Import the Java script into the variable environment to make it effective: source/etc/profile.d/java.sh
Use Java-version to view the Java version
#java完成
#tomcat开始
tar -zxvf apache-tomcat-7.0. . tar. gz-c/usr/src/ #解压
Move past, and rename to Tomcat
MV apache-tomcat-7.0. si//usr/local/tomcat
Start the Tomcat service
[Email protected] src]#/usr/local/tomcat/bin/startup. SH Using catalina_base: /usr/local/tomcatusing catalina_home: /usr/local//usr/local/tomcat/tempusingjre_home: /usr/local/javausing CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/ tomcat/bin/tomcat-Juli.jartomcat started.
Tomcat runs on port 8080 by default
grep 8080 TCP 0 0 :::8080 :::* LISTEN 13786
access [[email protected] ~]# Firefox http://192.168.1.1:8080/
If you want to close execution/usr/local/tomcat/bin/shutdown.sh
#tomcat完毕
Create a folder that holds the site Directory
[Email protected] ~]# mkdir-vp/web/webhttp
mkdir: The directory "/web" has been created
mkdir: The directory "/web/webhttp" has been created
#网页编写
vim/web/webhttp/inde.jsp
<%@ page language="java" import="java.util.*" pageencoding="UTF-8"%>head><title>jsp</ title></head><body><% out.println ("This isjava 1111111111 ");%></body>
#修改Tomcat的server. xml files
Vim/usr/local/tomcat/conf/server.xml
Insert at bottom (press g)
<context docbase="/web/webhttp" path="" reloadable="false "> </Context>
Restart Service
[Email protected] ~]#/usr/local/tomcat/bin/shutdown.SHUsing catalina_base:/usr/local/tomcatusing catalina_home:/usr/local/tomcatusing Catalina_tmpdir:/usr/local/tomcat/tempusing jre_home:/usr/local/javausing CLASSPATH:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-Juli.jar[[email protected]~]#/usr/local/tomcat/bin/startup.SHUsing catalina_base:/usr/local/tomcatusing catalina_home:/usr/local/tomcatusing Catalina_tmpdir:/usr/local/tomcat/tempusing jre_home:/usr/local/javausing CLASSPATH:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-Juli.jartomcat started.
Access
Firefox http://192.168.1.1:8080/
#tomcat结束
#CentOS 2 Building Nginx Web ServicesNeed to build the same as CentOS 1
Close Iptables Firewall
Install the same version of the Java environment
Installation configuration Tomcat, version consistency
Note that when writing index.jsp Web pages, to differentiate between load balancing we wrote two different pages to make it easy to differentiate
<%@ page language="java" import="java.util.*" pageencoding="UTF-8"%>head><title>jsp</ title></head><body><% out.println ("This isjava 2222222222 ");%></body>
The rest is the same as the CentOS 1 operation
#安装Nginx
tar -zxvf nginx-1.6. 0. tar. gz-c/usr/src/ #解压
CD cut into the extracted directory
Create program user, do not log on using
Useradd-m-s/sbin/nologin Nginx
Compiling the installation
./configure--prefix=/usr/local/nginx--user=nginx--group=nginx--with-file make make Install
[Email protected] ~]# ln-s/usr/local/nginx/sbin/*/usr/local/sbin/#软连接一个权限
[Email protected] ~]# nginx-t #版本
[Email protected] ~]# Nginx
[Email protected] ~]# NETSTAT-ANPT | grep 80
[[email protected] ~]# killall-s HUP nginx//Reload
[[email protected] ~]# killall-s QUIT nginx//Shutdown service
[Email protected] ~]# Nginx
Verify:
[email protected] ~]# Firefox http://localhost/&
RHELInstalling Nginx
Set weights
[Email protected] ~]# vim/usr/local/nginx/conf/nginx.conf
Add in http{}:
upstream tomcat_server { server 192.168. 1.10:8080 weight=1; Server 192.168. 1.20:8080 weight=1; }
Add in Location/{}:
Proxy_pass http://tomcat_server;
Restart Nginx Service
[[email protected] ~]# killall-s QUIT nginx
[Email protected] ~]# Nginx
[Email protected] ~]# NETSTAT-ANPT | grep nginx
Verify:
[email protected] ~]# Firefox http://192.168.1.3/&
Validation results: Displays the site pages on TOMCAT1 and TOMCAT2, respectively.
[linux]-deploying Tomcat and its load balancing