centos7.1安装tomcat8

上传软件包

[root@linux-node1 tools]# ls
apache-tomcat-8.0.32.tar.gz  jdk-8u74-linux-x64.tar.gz

 

添加普通用户tomcat(后期此用户专门用于管理tomcat)

[root@linux-node1 tools]# useradd -u 601 tomcat
[root@linux-node1 tools]# passwd tomcat
Changing password for user tomcat.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.

  

解压tomcat和jdk的软件包,用做软链接

[root@linux-node1 tools]# tar xfz  jdk-8u74-linux-x64.tar.gz 
[root@linux-node1 tools]# mv jdk1.8.0_74/ /usr/local/
[root@linux-node1 tools]# ln -s /usr/local/jdk1.8.0_74/  /usr/local/jdk
[root@linux-node1 tools]# tar xfz apache-tomcat-8.0.32.tar.gz 
[root@linux-node1 tools]# mv apache-tomcat-8.0.32 /usr/local/
[root@linux-node1 tools]# ln -s /usr/local/apache-tomcat-8.0.32/ /usr/local/tomcat
[root@linux-node1 tools]# 


[root@linux-node1 tools]# ls -al /usr/local/
total 12
drwxr-xr-x. 14 root root 4096 Feb 24 12:49 .
drwxr-xr-x. 13 root root 4096 Feb  6 01:26 ..
drwxr-xr-x   9 root root  149 Feb 24 12:49 apache-tomcat-8.0.32
drwxr-xr-x.  2 root root    6 Jun 10  2014 bin
drwxr-xr-x.  2 root root    6 Jun 10  2014 etc
drwxr-xr-x.  2 root root    6 Jun 10  2014 games
drwxr-xr-x.  2 root root    6 Jun 10  2014 include
lrwxrwxrwx   1 root root   23 Feb 24 12:48 jdk -> /usr/local/jdk1.8.0_74/
drwxr-xr-x   8   10  143 4096 Jan 30  2016 jdk1.8.0_74
drwxr-xr-x.  2 root root    6 Jun 10  2014 lib
drwxr-xr-x.  2 root root    6 Jun 10  2014 lib64
drwxr-xr-x.  2 root root    6 Jun 10  2014 libexec
drwxr-xr-x.  2 root root    6 Jun 10  2014 sbin
drwxr-xr-x.  5 root root   46 Feb  6 01:26 share
drwxr-xr-x.  2 root root    6 Jun 10  2014 src
lrwxrwxrwx   1 root root   32 Feb 24 12:49 tomcat -> /usr/local/apache-tomcat-8.0.32/
[root@linux-node1 tools]# 

  

设置环境变量

[root@linux-node1 tools]# vim /etc/profile
[root@linux-node1 scripts]# tail -5 /etc/profile
export JAVA_HOME=/usr/local//jdk
export JRE_HOME=/usr/local/jdk/jre
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export TOMCAT_HOME=/usr/local/tomcat
[root@linux-node1 scripts]# 
[root@linux-node1 tools]# source /etc/profile
[root@linux-node1 tools]# cd 
[root@linux-node1 ~]# 

  

目录授权,授权给tomcat用户管理

[root@linux-node1 ~]# chown -R tomcat:tomcat /usr/local/jdk
[root@linux-node1 ~]# chown -R tomcat:tomcat /usr/local/tomcat
[root@linux-node1 ~]# 

  

删除一些用不到的目录,可以增加安全性

[root@linux-node1 ~]# cd /usr/local/tomcat/webapps/
[root@linux-node1 webapps]# ls
docs  examples  host-manager  manager  ROOT
[root@linux-node1 webapps]# mv host-manager/ examples/ docs/ /tmp/
[root@linux-node1 webapps]# ls
manager  ROOT
[root@linux-node1 webapps]# 

  

可以su - 到tomcat用户下进行启停操作。

[root@linux-node1 conf]# su - tomcat
Last login: Fri Feb 24 14:51:28 CST 2017 on pts/0
[tomcat@linux-node1 ~]$ cd /usr/local/tomcat/bin/
[tomcat@linux-node1 bin]$ ./startup.sh 
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/jdk/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[tomcat@linux-node1 bin]$ ./shutdown.sh 
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/jdk/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[tomcat@linux-node1 bin]$ 

 

 

posted on 2019-03-01 14:32  nmap  阅读(346)  评论(0编辑  收藏  举报

导航