建站不啰嗦,上手跟我做(五)tomcat 下载和安装
下载
tomcat 在apache 官方下载
安装
以 apache-tomcat-8.5.31.tar.gz 为例
1、解压 tomcat 包
[root@localhost /]# cd usr
[root@localhost usr]# ls
apache-tomcat-8.5.31.tar.gz bin etc games include lib lib64 libexec local sbin share src tmp
[root@localhost usr]# mkdir tomcat
[root@localhost usr]# ls
apache-tomcat-8.5.31.tar.gz bin etc games include lib lib64 libexec local sbin share src tmp tomcat
[root@localhost usr]# mv apache-tomcat-8.5.31.tar.gz ./tomcat
[root@localhost usr]# ls
bin etc games include lib lib64 libexec local sbin share src tmp tomcat
[root@localhost usr]# cd tomcat
[root@localhost tomcat]# ls
apache-tomcat-8.5.31.tar.gz
[root@localhost tomcat]# tar -zxvf apache-tomcat-8.5.31.tar.gz
apache-tomcat-8.5.31/conf/
.....
[root@localhost tomcat]# ls
apache-tomcat-8.5.31 apache-tomcat-8.5.31.tar.gz
2、修改 tomcat 服务器的启动端口
[root@localhost tomcat]# ls
apache-tomcat-8.5.31 apache-tomcat-8.5.31.tar.gz
[root@localhost tomcat]# cd apache-tomcat-8.5.31/
[root@localhost apache-tomcat-8.5.31]# ls
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[root@localhost apache-tomcat-8.5.31]# cd conf
[root@localhost conf]# ls
catalina.policy context.xml jaspic-providers.xsd server.xml tomcat-users.xsd
catalina.properties jaspic-providers.xml logging.properties tomcat-users.xml web.xml
[root@localhost conf]# vi server.xml
修改port
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
3、启动服务器
[root@localhost apache-tomcat-8.5.31]# ls
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[root@localhost apache-tomcat-8.5.31]# cd bin
[root@localhost bin]# ls
bootstrap.jar commons-daemon-native.tar.gz digest.sh startup.bat tool-wrapper.sh
catalina.bat configtest.bat setclasspath.bat startup.sh version.bat
catalina.sh configtest.sh setclasspath.sh tomcat-juli.jar version.sh
catalina-tasks.xml daemon.sh shutdown.bat tomcat-native.tar.gz
commons-daemon.jar digest.bat shutdown.sh tool-wrapper.bat
[root@localhost bin]# sh startup.sh
Using CATALINA_BASE: /usr/tomcat/apache-tomcat-8.5.31
Using CATALINA_HOME: /usr/tomcat/apache-tomcat-8.5.31
Using CATALINA_TMPDIR: /usr/tomcat/apache-tomcat-8.5.31/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/tomcat/apache-tomcat-8.5.31/bin/bootstrap.jar:/usr/tomcat/apache-tomcat-8.5.31/bin/tomcat-juli.jar
Tomcat started.
4、查看服务器启动情况
[root@localhost bin]# cd ..
[root@localhost apache-tomcat-8.5.31]# ls
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[root@localhost apache-tomcat-8.5.31]# cd logs
[root@localhost logs]# ls
catalina.2018-05-31.log host-manager.2018-05-31.log localhost_access_log.2018-05-31.txt
catalina.out localhost.2018-05-31.log manager.2018-05-31.log
[root@localhost logs]# tail -f catalina.out
5、查看端口占用情况
[root@localhost logs]# lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 11545 root 46u IPv6 62718 0t0 TCP *:webcache (LISTEN)
6、服务器启动后不能访问
centos6查看当前iptables(防火墙)规则
可使用"iptables –L –n"查看当前iptables规则
[root@localhost logs]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
centos6开放8080端口
添加指定端口到防火墙中
iptables -I INPUT -p 协议 --dport 端口号 -j ACCEPT
[root@localhost logs]# iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
[root@localhost logs]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
centos7开放8080端口
[root@localhost sysconfig]# systemctl start firewalld
[root@localhost sysconfig]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[root@localhost sysconfig]# systemctl restart firewalld
上一篇 建站不啰嗦,上手跟我做(四)jdk 安装和环境配置
目录
下一篇 建站不啰嗦,上手跟我做(六)mysql 数据库下载和安装