Linux-Tomcat
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux-Tomcat相关的知识,希望对你有一定的参考价值。
Tomcat配置
- Tomcat介绍
- 安装jdk
- 安装Tomcat
- 配置Tomcat监听80端口
- 配置Tomcat的虚拟主机
- Tomcat日志
Tomcat介绍
Tomcat是Apache软件基金会(Apache software Foundation)的Jakarta项目中的一个核心项目,由Apache、Sun和其他一些公司及个人共同开发而成。
java程序写的网站用tomcat+jdk来运行
tomcat是一中间件,真正起作用的,解析脚本的是jdk
jdk(java development kit)是整个java的核心,它包含了java运行环境和一堆java相关的工具以及java基础库。
最主流的jdk为sun公司发布的jdk,除此之外,其实IBM公司也有发布JDK,CentOS上也可以用yum安装openjdk
安装jdk
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
ctrl+alt+f打开xftp(双击就可下载到linux系统的/usr/src目录下)
cd /usr/local/src/
tar -zxvf jdk-8u161-linux-x64.gz
mv jdk1.8.0_161/ /usr/local/jdk1.8
vim /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
source /etc/profile
java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
安装Tomcat
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.28/bin/apache-tomcat-8.5.28.tar.gz
tar -zxvf apache-tomcat-8.5.28.tar.gz
mv apache-tomcat-8.5.28 /usr/local/tomcat
启动tomcat
/usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/jdk1.8
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
ps aux|grep java
root 43424 1.1 5.5 4056596 103120 pts/2 Sl 09:53 0:05 /usr/local/jdk1.8/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
root 43527 0.0 0.0 112676 980 pts/2 S+ 10:01 0:00 grep --color=auto java
/usr/local/tomcat/bin/shutdown.sh //关闭tomcat
/usr/local/tomcat/bin/startup.sh
netstat -tlnp|grep java
tcp6 0 0 :::8080 :::* LISTEN 43578/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 43578/java
tcp6 0 0 :::8009 :::* LISTEN 43578/java
8080为提供web服务的端口
8005为管理端口
8009端口为第三方服务调用的端口,比如httpd和tomcat结合时会用到
关闭防火墙,在浏览器中访问192.168.221.20:8080
配置Tomcat监听80端口
vim /usr/local/tomcat/conf/server.xml //将8080改为80
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
/etc/init.d/nginx stop
/usr/local/tomcat/bin/shutdown.sh;/usr/local/tomcat/bin/startup.sh
netstat -tlnp|grep java //以下是查看到的内容
tcp6 0 0 :::80 :::* LISTEN 43897/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 43897/java
tcp6 0 0 :::8009 :::* LISTEN 43897/java
访问192.168.221.20
以上是关于Linux-Tomcat的主要内容,如果未能解决你的问题,请参考以下文章