标签:linux
16.1?Tomcat介绍16.2?安装JDK
jdk版本1.6,1.7,1.8
从官网手动下载地址 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
下载jdk8,放到/usr/local/src/目录下
tar zxvf jdk-8u161-linux-x64.tar.gz
mv jdk1.8.0_161 /usr/local/jdk1.8
vi /etc/profile //最后面增加
JAVA_HOME=/usr/local/jdk1.8/
JAVA_BIN=/usr/local/jdk1.8/bin
JRE_HOME=/usr/local/jdk1.8/jre
PATH=$PATH:/usr/local/jdk1.8/bin:/usr/local/jdk1.8/jre/bin
CLASSPATH=/usr/local/jdk1.8/jre/lib:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib/charsets.jar
使生效并查看java版本
source /etc/profile
?java -version
查看java版本安装了openjdk,需要卸载掉,注意若跑了其它的东西不要随便卸载它
rpm -qa |grep openjdk
yum -y remove java-1.7.0-openjdk
yum -y remove java-1.8.0-openjdk
16.3安装 ?Tomcat
所有版本网址: http://archive.apache.org/dist/tomcat/ 下载二进制包不需要编译
cd /usr/local/src
wget http://archive.apache.org/dist/tomcat/tomcat-8/v8.5.9/bin/apache-tomcat-8.5.9.tar.gz
tar zxvf apache-tomcat-8.5.9.tar.gz
mv apache-tomcat-8.5.9 /usr/local/tomcat
启动: /usr/local/tomcat/bin/startup.sh
停止: /usr/local/tomcat/bin/shutdown.sh
ps aux|grep tomcat
netstat -lntp |grep java
三个端口8080为提供web服务的端口,8005为管理端口,8009端口为第三方服务调用的端口,比如httpd和Tomcat结合时会用到
iptables -nvL 查看是否由防火墙并关闭
systemctl stop firewalld
systemctl disable firewalld
在浏览器查看: 192.168.188.128:8080
16.4 配置Tomcat监听80端口
编辑配置文件:
vim /usr/local/tomcat/conf/server.xml
Connector port="8080" protocol="HTTP/1.1"修改为Connector port="80" protocol="HTTP/1.1"
重启服务
/usr/local/tomcat/bin/shutdown.sh
/usr/local/tomcat/bin/startup.sh
netstat -lntp |grep java
netstat -lntp |grep 80
/etc/init.d/nginx stop
/usr/local/tomcat/bin/shutdown.sh
/usr/local/tomcat/bin/startup.sh
如果是实际的生产环境,就不要随便停掉nginx了。肯定会影响你的线上业务的。?
这时候你就可以让nginx代理tomcat了。80 代理 ?8080?
标签:linux
原文地址:http://blog.51cto.com/iammalt/2095884