1. 安装过程
需要事先已经安装好jdk
- 新建用户,也可使用已有用户。传tomcat文件之后解压
[root@VM_0_3_centos ~]# useradd wechat
[root@VM_0_3_centos ~]# su - wechat
[wechat@VM_0_3_centos ~]$ rz
[wechat@VM_0_3_centos ~]$ tar -xzvf apache-tomcat-7.0.81.tar.gz
- apachetomcat名字太长改下
[wechat@VM_0_3_centos ~]$ ll
total 8784
drwxrwxr-x 9 wechat wechat 4096 Jun 10 17:00 apache-tomcat-7.0.81
-rw-r--r-- 1 wechat wechat 8989099 May 15 16:59 apache-tomcat-7.0.81.tar.gz
[wechat@VM_0_3_centos ~]$ mv apache-tomcat-7.0.81 yuxin_tomcat
- 把war包放到默认的webapps文件夹下,启动
[wechat@VM_0_3_centos ~]$ cd yuxin_tomcat/
[wechat@VM_0_3_centos yuxin_tomcat]$ ll
total 116
drwxr-xr-x 2 wechat wechat 4096 Jun 10 17:00 bin
drwxr-xr-x 2 wechat wechat 4096 Aug 11 2017 conf
drwxr-xr-x 2 wechat wechat 4096 Jun 10 17:00 lib
-rw-r--r-- 1 wechat wechat 56846 Aug 11 2017 LICENSE
drwxr-xr-x 2 wechat wechat 4096 Aug 11 2017 logs
-rw-r--r-- 1 wechat wechat 1239 Aug 11 2017 NOTICE
-rw-r--r-- 1 wechat wechat 8965 Aug 11 2017 RELEASE-NOTES
-rw-r--r-- 1 wechat wechat 16195 Aug 11 2017 RUNNING.txt
drwxr-xr-x 2 wechat wechat 4096 Jun 10 17:00 temp
drwxr-xr-x 7 wechat wechat 4096 Aug 11 2017 webapps
drwxr-xr-x 2 wechat wechat 4096 Aug 11 2017 work
[wechat@VM_0_3_centos yuxin_tomcat]$ cd webapps/
[wechat@VM_0_3_centos webapps]$ rz
[wechat@VM_0_3_centos webapps]$ ll
total 22872
drwxr-xr-x 14 wechat wechat 4096 Jun 10 17:00 docs
drwxr-xr-x 7 wechat wechat 4096 Jun 10 17:00 examples
drwxr-xr-x 5 wechat wechat 4096 Jun 10 17:00 host-manager
drwxr-xr-x 5 wechat wechat 4096 Jun 10 17:00 manager
drwxr-xr-x 3 wechat wechat 4096 Jun 10 17:00 ROOT
-rw-r--r-- 1 wechat wechat 23398540 May 20 17:42 weixinHTML.war
[wechat@VM_0_3_centos bin]$ ./startup.sh
Using CATALINA_BASE: /home/wechat/yuxin_tomcat
Using CATALINA_HOME: /home/wechat/yuxin_tomcat
Using CATALINA_TMPDIR: /home/wechat/yuxin_tomcat/temp
Using JRE_HOME: /opt/java/jdk1.8.0_161
Using CLASSPATH: /home/wechat/yuxin_tomcat/bin/bootstrap.jar:/home/wechat/yuxin_tomcat/bin/tomcat-juli.jar
Tomcat started.
2. 验证
浏览器输入:http://ip:8080/
这就成功了,如果8080端口被占用,自己去server.xml修改即可
[wechat@VM_0_3_centos logs]$ netstat -nltp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::5432 :::* LISTEN -
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 32199/java
tcp6 0 0 :::8009 :::* LISTEN 32199/java
tcp6 0 0 :::8080 :::* LISTEN 32199/java
可以用过这个命令查看已被tcp占用的端口