Blogger Information
Blog 28
fans 0
comment 0
visits 49180
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
centos7环境搭建jdk安装配置Java tomcat
益伦的博客
Original
1039 people have browsed it

上传jdk.tar.z和tomcat.tar.gz到/opt
解压
tar -zxvf jdk.tar.gz (z解压参数x解压开v解压过程f压缩包名称)
tar -zxvf tomcat.tar.gz
ll
删除原压缩文件,留下解压文件释放内存
rm -rf *tar.gz
安装java
修改配置文件
vim /etc/profile
进入插入模式
export JAVA_HOME=/opt/jdk1.8.0_191
export JRE_HOME=/opt/jdk1.8.0_191/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
:wq
不重启服务器的情况下,配置文件生效
source /etc/profile
检验生效
Java -version
显示java版本

打开tomcat中bin目录中的启动目录startup.sh
cd apache-tomcat-9.0.35/bin
ll
执行其中startup.sh这个脚本
./startup.sh
显示
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /opt/apache-tomcat-9.0.35
Using CATALINA_HOME: /opt/apache-tomcat-9.0.35
Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.35/temp
Using JRE_HOME: /opt/jdk1.8.0_191/jre
Using CLASSPATH: /opt/apache-tomcat-9.0.35/bin/bootstrap.jar:/opt/apache-tomcat-9.0.35/bin/tomcat-juli.jar
Tomcat started.
显示标识启动中
实时打印目录
tail -f ../logs/catalina.out
显示详细日志
ctrl+C 关闭实时日志
在本机中查看tomcat是否运行成功,浏览器中输入:虚拟机ip:8080,看是否显示
如果没显示,查看防火墙是否打开
[root@localhost bin]# firewall-cmd —state
not running
[root@localhost bin]# systemctl status firewall
Unit firewall.service could not be found.
[root@localhost bin]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@localhost bin]#
关闭防火墙,或者加入8080 端口信任
firewall-cmd —zone=public —add-port=80/tcp —permanent(—permanent为永久生效,没有此参数重启后失效)
创建test1.html,输入Hellow world!
[root@localhost test]# pwd
/opt/apache-tomcat-9.0.35/webapps/test
[root@localhost test]# ll
total 4
-rw-r—r—. 1 root root 11 May 17 23:29 test1.html
[root@localhost test]#
服访问浏览器虚拟机IP:8080/test/test1.html 显示Hellow world!
防火墙加入8080 端口信任
[root@localhost ~]# firewall-cmd —zone=public —add-port=8080/tcp —permanent
success
重新载入防火墙配置生效
[root@localhost ~]# firewall-cmd —reload
success
查看
[root@localhost ~]# firewall-cmd —zone=public —query-port=8080/tcp
yes
删除
[root@localhost ~]# firewall-cmd —zone=public —remove-port=8080/tcp —permanent
success
[root@localhost ~]#
注意事项
要显示的HTML文件必须是放在webapps中一个新建文件夹里面,也就是说不能直接就把HTML放在webapps文件夹中或者直接放在webapps中已有的文件夹中,然后浏览器输入localhost:8080/hello.html,这样是不行的,结果还是404 — NOT FOUND。这样在webapps中新建文件夹test(名字为英文随意起),然后浏览器输入localhost:8080/test/hello.html即可。

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post