标签:环境变量 .sh 应用 tomcat服务 config port map configure tom
Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。其特点是占有内存少,并发能力强
Tomcat2:192.168.10.129/24 (jdk-8u91-linux-x64.、apache-tomcat-8.5.16)
如图:
* 首先配置安装 2台Tomcat服务器的 :Java环境和Tomcat
# systemctl stop firewalld.service //关闭防火墙
# setenforce 0
# mkdir /gx | mount.cifs //192.168.10.1/gx /gx //挂载共享文件
# tar zxvf /gx/jdk-8u91-linux-x64.tar.gz -C /opt
# mv /opt/jdk1.8.0_91/ /usr/local/java
# vim /etc/profile.d/java.sh
export JAVA_HOME=/usr/local/java //设置Java根目录//
export PATH=$PATH:$JAVA_HOME/bin //在PATH环境变量中添加Java根目录下的bin/子目录//
# source /etc/profile.d/java.sh //java.sh脚本导入到环境变量,使其生效//
# java -version //查看版本//
.
安装Tomcat
# tar zxvf /gx/apache-tomcat-8.5.16.tar.gz -C /opt/
# mv /opt/apache-tomcat-8.5.16/ /usr/local/tomcat8
# /usr/local/tomcat8/bin/startup.sh //启动tomcat//
# netstat -ntap | grep 8080 //监听8080端口//
# /usr/local/tomcat8/bin/shutdown.sh //关闭tomcat//
Tomcat 2 输出 http://www.test2.com
# mkdir -pv /web/webapp1 //创建web目录//
# vim /web/webapp1/index.jsp //创建测试页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>JSP test1 page</title>
</head>
<body>
<% out.println("Welcome to test site,http://www.test1.com");%>
</body>
</html>
.
在Tomcat的配置文件里添加web目录
# vim /usr/local/tomcat8/conf/server.xml
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
//在该行下面添加↓↓↓//
<Context docBase="/web/webapp1" path="" reloadable="false">
</Context>
# /usr/local/tomcat8/bin/startup.sh //启动tomcat//
安装配置Nginx
# systemctl stop firewalld.service //关闭防火墙
# setenforce 0
# yum install pcre-devel zlib-devel openssl-devel gcc gcc-c++ -y
# useradd -s /bin/false www
# tar zxvf /gx/nginx-1.6.0.tar.gz -C /opt
# cd /opt/nginx-1.6.0/
# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module
# make && make install //安装编译安装
.
# vim /usr/local/nginx/conf/nginx.conf
#gzip on;
//在该行下面添加两台Tomcat的地址端口↓↓↓
upstream tomcat_server {
server 192.168.10.128:8080 weight=1;
server 192.168.10.129:8080 weight=1;
}
server {
listen 80;
.....
location / {
root html;
index index.html index.htm;
// 在该行下面添加↓↓↓//
proxy_pass http://tomcat_server;
}
.
# /usr/local/nginx/sbin/nginx -t //检测是否成功//
# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
# nginx //启用nginx服务//
标签:环境变量 .sh 应用 tomcat服务 config port map configure tom
原文地址:http://blog.51cto.com/13630803/2130721