1.在/url/local目录下建文件及tomcat,并进入目录
mkdir tomcat
cd /url/local/tomcat
2.wegt下载tomcat8.5.47
wget
http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.47/bin/apache-tomcat-8.5.47.tar.gz
3.解压
tar -zxvf apache-tomcat-8.5.47.tar.gz
4.开放80和8080端口,重启防火墙
开放接口后要重启防火墙
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload
查看开放了那些接口
firewall-cmd --list-ports
firewall-cmd --permanent --add-port=8080/tcp
systemctl list-unit-files|grep firewalld.service 查看防火墙的状态是否未disabled
如果不是disabled
systemctl unmask firewalld更改
5.更改tomcat启动端口为80,当启动端口为80时,访问时就只用输入ip地址就可以访问
cd /usr/local/tomcat/apache-tomcat-8.5.47/conf
vim server.xml
改为
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
6.开启tomcat
进入bin目录
cd /usr/local/tomcat/apache-tomcat-8.5.47/bin
./startup.sh
如果启动不成功的话就建议关闭防火墙
service firewalld stop
可以在tomcat安装目录下的bin下执行./catalina.sh run 让它debug运行,看看错误出在哪里
使用ip:port访问成功,既tomcat配置成功
http://ip:8080/
7.关闭tomcat端口
./shutdown.sh
如果关闭不成功的话就查看tomcat用了那些进程,然后杀掉进程
ps -ef |grep tomcat
杀死:kill -9 端口号
进入:
vim /usr/local/jdk/jdk1.8.0_141/jre/lib/security/java.security
查找:
/securerandom.source=file:/dev/random
改为:
securerandom.source=file:/dev/urandom
重启tomcat