1.安装Tomcat
进入 /usr/local/ 目录 cd /usr/local
下载 wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.22/bin/apache-tomcat-9.0.22.tar.gz
解压 tar -zxvf apache-tomcat-9.0.22.tar.gz
新建文件夹 mkdir tomcat-9.0.22
重命名 mv ./apache-tomcat-9.0.22 ./tomcat-9.0.22/tomcat1
解压 tar -zxvf apache-tomcat-9.0.22.tar.gz
重命名 mv ./apache-tomcat-9.0.22 ./tomcat-9.0.22/tomcat2
2.配置Tomcat
添加环境变量 vim /etc/profile
export CATALINA_HOME=/usr/local/tomcat-9.0.21/tomcat1 export CATALINA_BASE=/usr/local/tomcat-9.0.21/tomcat1 export TOMCAT_HOME=/usr/local/tomcat-9.0.21/tomcat1 export CATALINA_2_HOME=/usr/local/tomcat-9.0.21/tomcat2 export CATALINA_2_BASE=/usr/local/tomcat-9.0.21/tomcat2 export TOMCAT_2_HOME=/usr/local/tomcat-9.0.21/tomcat2
打开tomcat2/bin下的catalina.sh文件vim /usr/local/tomcat-9.0.22/tomcat2/bin/catalina.sh,在# OS specific support. $var _must_ be set to either true or false.下增加
export CATALINA_BASE=$CATALINA_2_BASE export CATALINA_HOME=$CATALINA_2_HOME
打开tomcat2/conf下的server.xml文件vim /usr/local/tomcat-9.0.22/tomcat2/conf/server.xml,修改端口,避免启动服务器端口冲突
用一张png图片替换tomcat1/webapps/ROOT/下的tomcat.png图片,以区分两个服务器
分别启动两个tomcat,
cd /usr/local/tomcat-9.0.22/tomcat1/bin/
./startup.sh
cd /usr/local/tomcat-9.0.22/tomcat2/bin/
./startup.sh
请求测试对应的服务器
tomcat1:
tomcat2:
3.安装Nginx
yum install Nginx
4.配置Nginx
# For more @R_568_4045@ion on configuration, see: # * Official English Documentation: http://Nginx.org/en/docs/ # * Official Russian Documentation: http://Nginx.org/ru/docs/ user Nginx; worker_processes auto; error_log /var/log/Nginx/error.log; pid /run/Nginx.pid; # Load dynamic modules. See /usr/share/Nginx/README.dynamic. include /usr/share/Nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/Nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/Nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/Nginx/conf.d directory. # See http://Nginx.org/en/docs/ngx_core_module.html#include # for more @R_568_4045@ion. #include /etc/Nginx/conf.d/*.conf; upstream tomcat9{ server IP地址:8080 weight=2; server IP地址:9080 weight=2; } server { listen 80 default_server; listen [::]:80 default_server; server_name 请求地址; root /usr/share/Nginx/html; # Load configuration files for the default server block. include /etc/Nginx/default.d/*.conf; location / { proxy_pass http://tomcat9; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } }
启动Nginx
cd /bin
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。