码迷,mamicode.com
首页 > 其他好文 > 详细

Nginx+tomcat负载均衡

时间:2017-09-13 01:42:32      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:环境   rss   jre   name   1.3   exception   index   amp   image   

[root@Java-JDK ~]# tar zxvf jdk-7u65-linux-x64.gz

技术分享

[root@Java-JDK ~]# mkdir /usr/java
[root@Java-JDK ~]# mv jdk1.7.0_65/ /usr/java/

[root@Java-JDK ~]# /usr/java/jdk1.7.0_65/bin/java -verssion
Unrecognized option: -verssion
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
[root@Java-JDK ~]# /usr/java/jdk1.7.0_65/bin/java -version
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)    #Java运行的环境即JRE
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

设置环境变量

[root@Java-JDK ~]# vim /etc/profile

export JAVA_HOME=/usr/java/jdk1.7.0_65
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin

[root@Java-JDK ~]# java -version
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

安装tomcat

http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.81/bin/apache-tomcat-7.0.81.tar.gz

[root@Java-JDK ~]# tar zxvf apache-tomcat-7.0.81.tar.gz

[root@Java-JDK ~]# mv apache-tomcat-7.0.81 /usr/local/tomcat

root@localhost local]# cp -a tomcat/ tomcat_1 && cp -a tomcat/ tomcat_2   #创建两个tomcat

[root@Java-JDK ~]# /usr/local/tomcat/bin/startup.sh

<Server port="8005" shutdown="SHUTDOWN">    #管理关闭Tomcat的端口

<Connector port="8080" protocol="HTTP/1.1"    #管理tomcat协议浏览访问 

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />    #管理AJP代理协议  (PS:apache与tomcat连接需要借助8009/nginx与tomcat连接直接借助8080即可)

[root@localhost local]# vim tomcat_1/webapps/ROOT/index.jsp 

<html>
<body>
<h1>Tomcat Server Nmae hexun JSP Test Page </h1>
<%=new java.util.Date()%>
<hr color="red">
<h1>www.hexun.net</h1>
</body>
</html>

 

[root@localhost local]#vim tomcat_2/conf/server.xml

<Server port="8006" shutdown="SHUTDOWN">

<Server port="8006" shutdown="SHUTDOWN">

 

<Connector port="8081" protocol="HTTP/1.1"

 <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />

[root@localhost local]# vim tomcat_2/webapps/ROOT/index.jsp

<html>
<body>
<h1>Tomcat Server Name jfedu JSP Test Page </h1>
<%=new java.util.Date()%>
<hr color="red">
<h1>www.jfedu.net</h1>
</body>
</html>

[root@localhost local]# /usr/local/tomcat_1/bin/startup.sh 

[root@localhost local]# /usr/local/tomcat_1/bin/startup.sh 

技术分享

[root@localhost html]# vim  /usr/local/nginx/conf/nginx.conf    #在Nginx配置文件中配置方向代理负载均衡后端两个Tomcat虚拟主机

技术分享

技术分享

技术分享

 

Nginx+tomcat负载均衡

标签:环境   rss   jre   name   1.3   exception   index   amp   image   

原文地址:http://www.cnblogs.com/bixiaoyu/p/7510760.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!