0%

CentOS7上安装Tomcat7

下载tomcat7的tar.gz压缩文件

解压到/usr/local目录

1
$ tar -zxvf apache-tomcat-8.5.31.tar.gz

编译server.xml文件,修改编码

1
2
$ cd apache-tomcat-8.5.31/
$ vi conf/server.xml

找到这一行

1
2
3
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

增加URIEncoding=”UTF-8”,替换为

1
2
3
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />

启动Tomcat7

1
2
3
4
5
6
7
bin/startup.sh 
Using CATALINA_BASE: /usr/local/apache-tomcat-8.5.31
Using CATALINA_HOME: /usr/local/apache-tomcat-8.5.31
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.5.31/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/apache-tomcat-8.5.31/bin/bootstrap.jar:/usr/local/apache-tomcat-8.5.31/bin/tomcat-juli.jar
Tomcat started.

查看本地ip地址

1
2
3
4
5
ifconfig

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.30 netmask 255.255.255.0 broadcast 192.168.1.255
...

访问http://192.168.1.30:8080
出现下图

表示tomcat7安装并启动成功了。