上传Tomcat压缩包
1、通过终端在/usr/local下创建tomcat文件夹
sudo mkdir /usr/local/tomcat
2、上传tomcat解压包要服务器
解压Tomcat
1、解压tomcat
sudo tar zxvf apache-tomcat-8.5.34.tar.gz
解压过程
将解压完成的压缩包清除,命令行
sudo rm apache-tomcat-8.5.34.tar.gz
Tomcat配置
2、修改Tomcat编码
vi /usr/local/apache-tomcat-8.5.34/conf/server.xml
在8080端口后加上
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>
2、配置8080端口防火墙
vim /etc/sysconfig/iptables
添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
![img](file:///private/var/folders/_m/9k7sm4jj3jx3hx4v3n3bk9_80000gn/T/WizNote/d799b66a-78c4-46c4-ba81-dba8d15724f1/index_files/90298f13-d482-46bc-b812-892f56e1d0bc.png)
注意:8080是tomcat端口号,如果想添加多个端口8080-8090中间的端口都会被配置上
3、重启服务
使用命令
[root@slave1 tomcat]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
注意:
- iptables后使用
- restart 重启
- start 启动
- stop 停止
启动Tomcat服务器
1、启动Tomcat服务器。进入tomcat/bin文件中,启动Tomcat服务器
./startup.sh
./startup.sh & tail -f /Users/mars/Desktop/apache-tomcat-8.5.40/logs/catalina.out
以上命令二选一,后缀& tail -f /Users/mars/Desktop/apache-tomcat-8.5.40/logs/catalina.out
表示启动并输出在控制台输出日志
2、访问页面,输入ip地址:8080
关闭Tomcat服务器
[root@slave1 bin]# ./shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-8.5.34
Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-8.5.34
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-8.5.34/temp
Using JRE_HOME: /usr/local/java/jdk1.8.0_191
Using CLASSPATH: /usr/local/tomcat/apache-tomcat-8.5.34/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-8.5.34/bin/tomcat-juli.jar