卸载
rpm -e
查看当前linux系统都安装了那些软件
rpm -qa
卸载linux中原有的jdk的步骤
(1)先查看原有的linux中的jdk
rpm -qa | grep java
------------------------------------------------
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
tzdata-java-2013g-1.el6.noarch
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
(2)然后再追个的把原有的和java有关的都卸载掉
rpm -e java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
-------------------------------------------------------
rpm -e java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
-------------------------------------------------------
rpm -e tzdata-java-2013g-1.el6.noarch
(3)然后查看是否卸载干净
java -version
-----------------------------------------------
-bash: /usr/bin/java: No such file or directory
安装jdk
(1)第一步:用xftp软件将提前下载好的jdk安装包传到linux服务器上
(2)在linux中将安装包解压到指定路经
tar -xvf jdk-8u191-linux-x64.tar.gz -C /usr/local/
(3)配置环境变量
vim /etc/profile
(4)进入编辑界面之后,键盘输入i
(5) 然后编辑文本
export JAVA_HOME=/usr/local/jdk1.8.0_191
export JRE_HOME=/usr/local/jdk1.8.0_191/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
(6)使环境变量生效
source /etc/profile
(7)检验
java -version
安装tomcat
(1)安装:直接解压就行
tar -xvf apache-tomcat-9.0.2.tar.gz -C /usr/local
(2)tomcat启动
a.进入到Tomcat目录中
cd /usr/local/apache-tomcat-9.0.2/
---------------------------------------------------
[root@leitingyan apache-tomcat-9.0.2]# ls
b.查看tomcat文件键
ls
---------------------------------------------------
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
c.进入bin目录
cd bin
---------------------------------------------------
ls
---------------------------------------------------
bootstrap.jar ciphers.sh daemon.sh shutdown.bat tomcat-native.tar.gz
catalina.bat commons-daemon.jar digest.bat shutdown.sh tool-wrapper.bat
catalina.sh commons-daemon-native.tar.gz digest.sh startup.bat tool-wrapper.sh
catalina-tasks.xml configtest.bat setclasspath.bat startup.sh version.bat
ciphers.bat configtest.sh setclasspath.sh tomcat-juli.jar version.sh
d.启动tomcat
./startup.sh
---------------------------------------------------------------------------------
Using CATALINA_BASE: /usr/local/apache-tomcat-9.0.2
Using CATALINA_HOME: /usr/local/apache-tomcat-9.0.2
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-9.0.2/temp
Using JRE_HOME: /usr/local/jdk1.8.0_191/jre
Using CLASSPATH: /usr/local/apache-tomcat-9.0.2/bin/bootstrap.jar:/usr/local/apache-tomcat-9.0.2/bin/tomcat-juli.jar
Tomcat started.
e.验证tomcat是否安装成功
打卡linux中的火狐浏览器,输入
http://localhost:8080
显示如下结果,证明安装成功
关掉linux的防火墙
- 防火墙默认是开机自动运行。
service iptables stop
-----------------------------------------------------------------------
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules:
-
关闭防火墙之后,外网可以访问服务器啦
-
防火墙开机后
不主动启动
chkconfig iptables off
在tomcat上部署web项目
- 把项目的web.war 防止到tomcat中的webapps目录下,
cp web.war /usr/local/apache-tomcat-9.0.2/webapps/
- 然后重启tomact
cd /usr/local/apache-tomcat-9.0.2/
cd bin
ls
-----------------------------------------------------------------------------------------
bootstrap.jar ciphers.sh daemon.sh shutdown.bat tomcat-native.tar.gz
catalina.bat commons-daemon.jar digest.bat shutdown.sh tool-wrapper.bat
catalina.sh commons-daemon-native.tar.gz digest.sh startup.bat tool-wrapper.sh
catalina-tasks.xml configtest.bat setclasspath.bat startup.sh version.bat
ciphers.bat configtest.sh setclasspath.sh tomcat-juli.jar version.sh
-----------------------------------------------------------------------------------------
./startup.sh
Using CATALINA_BASE: /usr/local/apache-tomcat-9.0.2
Using CATALINA_HOME: /usr/local/apache-tomcat-9.0.2
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-9.0.2/temp
Using JRE_HOME: /usr/local/jdk1.8.0_191/jre
Using CLASSPATH: /usr/local/apache-tomcat-9.0.2/bin/bootstrap.jar:/usr/local/apache-tomcat-9.0.2/bin/tomcat-juli.jar
Tomcat started.
- 然后访问:http://192.168.222.128:8080/web/