LNMP架构tomcat的配置

1.获取安装包,解压安装

tar zxf openresty-1.13.6.1.tar.gz 
cd openresty-1.13.6.1
 ./configure
  gmake && gmake install
 tar zxf jdk-7u79-linux-x64.tar.gz -C /usr/local/
 tar zxf apache-tomcat-7.0.37.tar.gz -C /usr/local/

2.制作软链接

cd /usr/local/
ln -s jdk1.7.0_79 java
ln -s apache-tomcat-7.0.37 tomocat

3.配置环境变量

vim /etc/profile
source /etc/profile
在这里插入图片描述

4.启动tomcat

   11  cd /usr/local/tomocat/
   12  cd bin/
   13  ls
   14  ./startup.sh 

5.修改配置文件

 vim /usr/local/openresty/nginx/conf/nginx.conf

在这里插入图片描述

../sbin/nginx -t  ##检测语法错误
[root@server1 conf]# ../sbin/nginx -tnginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successfu

6.修改发布页

cd /usr/local/tomocat/webapps/ROOT/
[root@server1 ROOT]# vim test.jsp
[root@server1 ROOT]# cat test.jsp
server1 the time is: <%=new java.util.Date() %>
./nginx -s reload

在这里插入图片描述在这里插入图片描述

粘制位

准备另一台虚拟机
server1:
 cd /usr/local/tomocat/webapps/ROOT/
 scp test.jsp server2:/usr/local/tomcat/webapps/ROOT/

 vim /usr/local/lnmp/nginx/conf/nginx.conf
 17 http {
 18     include       mime.types;
 19     default_type  application/octet-stream;
 20         upstream tomcat{
 21         server 172.25.61.1:8080;
 22         server 172.25.61.2:8080;
 23 
 24         }
 31     sendfile        on;
 32     #tcp_nopush     on;
 33 
 34     #keepalive_timeout  0;
 35     keepalive_timeout  65;
 36 
 37     #gzip  on;
 38 
 39     server {
 40         listen       80;
 41         server_name  localhost;
 42 
 47         location / {
 48             root   /usr/local/tomcat/webapps/ROOT;
 49             index   index.html index.htm;
 50         }
 51 
 52         #error_page  404              /404.html;
 53 
 54         # redirect server error pages to the static page /50x.html
 55         #
 56         error_page   500 502 503 504  /50x.html;
 57         location = /50x.html {
 58             root   html;
 59         }
 60         location ~ \.jsp$ {
 61                 proxy_pass http://tomcat;
server2:
    8  tar zxf jdk-7u79-linux-x64.tar.gz -C /usr/local/
    9  tar zxf apache-tomcat-7.0.37.tar.gz -C /usr/local/
   10  cd /usr/local/
   11  ln -s apache-tomcat-7.0.37/ tomcat
   12  ln -s jdk1.7.0_79 java
   13  vim /etc/profile
   14  source /etc/profile
   15  cd /usr/local/tomcat/webapps/ROOT/
   16  ls
   17  ps ax
   18  cd ../..
   19  cd bin/
   20  ./startup.sh 
   21  vim /usr/local/tomcat/webapps/ROOT/test.jsp 
   22  cat /usr/local/tomcat/webapps/ROOT/test.jsp 
    server2 the time is: <%=new java.util.Date() %>

测试

server1 the time is: Wed May 01 06:48:16 CST 2019
[root@foundation61 ~]# curl 172.25.61.1/test.jsp
server2 the time is: Wed May 01 06:48:17 CST 2019
[root@foundation61 ~]# curl 172.25.61.1/test.jsp
server2 the time is: Wed May 01 06:48:18 CST 2019
[root@foundation61 ~]# curl 172.25.61.1/test.jsp
server1 the time is: Wed May 01 06:48:18 CST 2019
[root@foundation61 ~]# curl 172.25.61.1/test.jsp
server1 the time is: Wed May 01 06:48:18 CST 2019
[root@foundation61 ~]# curl 172.25.61.1/test.jsp
server2 the time is: Wed May 01 06:48:19 CST 2019
[root@foundation61 ~]# curl 172.25.61.1/test.jsp
server2 the time is: Wed May 01 06:48:20 CST 2019
[root@foundation61 ~]# curl 172.25.61.1/test.jsp
server1 the time is: Wed May 01 06:48:20 CST 2019
[root@foundation61 ~]# curl 172.25.61.1/test.jsp
server1 the time is: Wed May 01 06:48:21 CST 2019
发现确实轮循!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值