标签:tle pat 网站 连接 解压 ima enc jsp list
环境:VM
CentOS1:192.168.1.1/24
CentOS2:192.168.1.2/24
REHL:192.168.1.3/24
#yum开始
挂载镜像并连接
[root@localhost ~]# mount /dev/cdrom /mnt/ mount: block device /dev/sr0 is write-protected, mounting read-only
删除原有的yum配置文件,写入自己的
rm -rf /etc/yum.repos.d/* vim /etc/yum.repos.d/yum.repo [yum] name=yum install baseurl=file:///mnt/ enabled=1 gpgcheck=0
yum -y install bind #测试
#yum结束
关闭iptables防火墙
service iptables stop
需要用到的安装包,
apache-tomcat-7.0.54.tar.gz #tomcat安装包
nginx-1.6.0.tar.gz #nginxweb服务安装包
jdk-7u65-linux-x64.gz #java环境安装包
全部解压到/usr/src/
#java开始
tar -zxvf jdk-7u65-linux-x64.gz -C /usr/src/
删除原有的java环境
[root@localhost ~]# rm -rf /usr/bin/java
[root@localhost ~]# rm -rf /usr/bin/javac
[root@localhost ~]# cd /usr/src/
[root@localhost src]# ls
debug jdk1.7.0_65 kernels
[root@localhost src]# mv jdk1.7.0_65/ /usr/local/java
[root@localhost src]# vim /etc/profile.d/java.sh
export JAVA_HOME=/usr/local/java #设置java路径
export PATH=$PATH:$JAVA_HOME/bin
把java脚本导入变量环境,使其生效: source /etc/profile.d/java.sh
使用java -version查看java版本
#java完成
#tomcat开始
tar -zxvf apache-tomcat-7.0.54.tar.gz -C /usr/src/ #解压
移动过去,并改名为tomcat
mv apache-tomcat-7.0.54/ /usr/local/tomcat
启动tomcat服务
ot@localhost src]# /usr/local/tomcat/bin/startup.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/local/java Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started.
tomcat默认运行在8080端口
ot@localhost ~]# netstat -anpt | grep 8080 tcp 0 0 :::8080 :::* LISTEN 13786/java
访问[root@localhost ~]# firefox http://192.168.1.1:8080/
如果要关闭执行 /usr/local/tomcat/bin/shutdown.sh
#tomcat完毕
创建一个存放网站目录的文件夹
[root@localhost ~]# mkdir -vp /web/webhttp
mkdir: 已创建目录 "/web"
mkdir: 已创建目录 "/web/webhttp"
#网页编写
vim /web/webhttp/inde.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <html> <head> <title>JSP</title> </head> <body> <% out.println("This is java 1111111111");%> </body> </html>
#修改Tomcat的server.xml文件
vim /usr/local/tomcat/conf/server.xml
在底部(按G)插入
<Context docBase="/web/webhttp" path="" reloadable="false"> </Context>
重启服务
[root@localhost ~]# /usr/local/tomcat/bin/shutdown.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/local/java Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar [root@localhost ~]# /usr/local/tomcat/bin/startup.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/local/java Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started.
访问
firefox http://192.168.1.1:8080/
#tomcat结束
需要搭建和centos 1一样的
关闭iptables防火墙
安装相同版本的java环境
安装配置tomcat,版本保持一致
注意在写index.jsp网页的时候,为了区分负载均衡我们写了两个不同的网页,方便区分
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <html> <head> <title>JSP</title> </head> <body> <% out.println("This is java 2222222222");%> </body> </html>
其余跟centos 1 操作一样
#安装Nginx
tar -zxvf nginx-1.6.0.tar.gz -C /usr/src/ #解压
cd切入解压的目录
创建程序用户,不登录使用
useradd -M -s /sbin/nologin nginx
编译安装
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module && make && make install
[root@localhost ~]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/ #软连接一个权限
[root@localhost ~]# nginx -t #版本
[root@localhost ~]# nginx
[root@localhost ~]# netstat -anpt | grep 80
[root@localhost ~]# killall -s HUP nginx //重新加载
[root@localhost ~]# killall -s QUIT nginx //关闭服务
[root@localhost ~]# nginx
验证:
[root@localhost ~]# firefox http://localhost/ &
安装Nginx
设置权重
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
在http{ }中添加:
upstream tomcat_server { server 192.168.1.10:8080 weight=1; server 192.168.1.20:8080 weight=1; }
location / { }中添加:
proxy_pass http://tomcat_server;
重启Nginx服务
[root@localhost ~]# killall -s QUIT nginx
[root@localhost ~]# nginx
[root@localhost ~]# netstat -anpt | grep nginx
验证:
[root@localhost ~]# firefox http://192.168.1.3/ &
验证结果:分别显示Tomcat1和Tomcat2上的网站页面。
标签:tle pat 网站 连接 解压 ima enc jsp list
原文地址:http://www.cnblogs.com/chenwz/p/7531236.html