1.安装tomcat之前要先安装jdk
root@localhost ~]# cd /usr/local
[root@localhost local]# ll
总用量 190112
-rw-r--r--. 1 root root 9150593 9月 15 19:41 apache-tomcat-8.0.30.tar.gz #上传
drwxr-xr-x. 2 root root 6 4月 11 2018 bin
drwxr-xr-x. 2 root root 6 4月 11 2018 etc
drwxr-xr-x. 2 root root 6 4月 11 2018 games
drwxr-xr-x. 2 root root 6 4月 11 2018 include
drwxrwxrwx. 8 10 143 255 7月 12 2017 jdk1.8.0_141 #jdk解压
-rw-r--r--. 1 root root 185516505 9月 15 19:49 jdk-8u141-linux-x64.tar.gz #jdk上传
drwxr-xr-x. 2 root root 6 4月 11 2018 lib
drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
drwxr-xr-x. 5 root root 49 9月 10 18:51 share
drwxr-xr-x. 2 root root 6 4月 11 2018 src
[root@localhost local]# tar -xzvf apache-tomcat-8.0.30.tar.gz
[root@localhost local]#ll
drwxrwxrwx. 9 root root 160 9月 16 09:03 apache-tomcat-8.0.30 #解压,递归赋权777
-rw-r--r--. 1 root root 9150593 9月 15 19:41 apache-tomcat-8.0.30.tar.gz
drwxr-xr-x. 2 root root 6 4月 11 2018 bin
drwxr-xr-x. 2 root root 6 4月 11 2018 etc
drwxr-xr-x. 2 root root 6 4月 11 2018 games
drwxr-xr-x. 2 root root 6 4月 11 2018 include
drwxrwxrwx. 8 10 143 255 7月 12 2017 jdk1.8.0_141
-rw-r--r--. 1 root root 185516505 9月 15 19:49 jdk-8u141-linux-x64.tar.gz
drwxr-xr-x. 2 root root 6 4月 11 2018 lib
drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
drwxr-xr-x. 5 root root 49 9月 10 18:51 share
drwxr-xr-x. 2 root root 6 4月 11 2018 src
[root@localhost local]# vim /etc
[root@localhost etc]# vim profile
#打开配置文件,按 i 进入编辑模式,在profile文件尾部unset -f pathmunge后面添加如下内容
JAVA_HOME=/usr/local/jdk1.8.0_141
JAVA_BIN=$JAVA_HOME/bin
JRE_HOME=$JAVA_HOME/jre
JRE_BIN=$JRE_HOME/bin
PATH=$JAVA_BIN:$JRE_BIN:$PATH
export JAVA_HOME JRE_HOME PATH
[root@localhost etc]cd /usr/local/apache-tomcat-8.0.30/conf
[root@localhost conf]# ll
总用量 224
drwxr-xr-x. 3 root root 23 9月 16 09:17 Catalina
-rwxrwxrwx. 1 root root 12374 12月 2 2015 catalina.policy
-rwxrwxrwx. 1 root root 7106 12月 2 2015 catalina.properties
-rwxrwxrwx. 1 root root 1577 12月 2 2015 context.xml
-rw-r--r--. 1 root root 402 10月 2 01:03 jdbc.properties
-rw-r--r--. 1 root root 762 9月 15 19:40 log4j.properties
-rwxrwxrwx. 1 root root 3387 12月 2 2015 logging.properties
-rwxrwxrwx. 1 root root 6458 12月 2 2015 server.xml
-rwxrwxrwx. 1 root root 1744 12月 2 2015 tomcat-users.xml
-rwxrwxrwx. 1 root root 1846 12月 2 2015 tomcat-users.xsd
-rwxrwxrwx. 1 root root 168822 12月 2 2015 web.xml
[root@localhost conf]# vi jdbc.properties
#修改端口号IP用户名密码
#HYEC dataSource 1
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://192.168.111.128:3306/apple?useUnicode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=123456
cpool.minPoolSize=5
cpool.maxPoolSize=50
cpool.maxIdleTime=7200
cpool.maxIdleTimeExcessConnections=1800
cpool.acquireIncrement=5
cpool.autoCommitonClose=true
cpool.checkoutTimeout=5000
api.root=register
~
~
[root@localhost apache-tomcat-8.0.30]# cd /usr/local/apache-tomcat-8.0.30/bin
[root@localhost bin]# ll
总用量 792
-rwxrwxrwx. 1 root root 28417 12月 2 2015 bootstrap.jar
-rwxrwxrwx. 1 root root 13825 12月 2 2015 catalina.bat
-rw-r--r--. 1 root root 1 9月 16 13:18 catalina.out
-rwxrwxrwx. 1 root root 21389 12月 2 2015 catalina.sh
-rwxrwxrwx. 1 root root 1647 12月 2 2015 catalina-tasks.xml
-rwxrwxrwx. 1 root root 24283 12月 2 2015 commons-daemon.jar
-rwxrwxrwx. 1 root root 204944 12月 2 2015 commons-daemon-native.tar.gz
-rwxrwxrwx. 1 root root 2040 12月 2 2015 configtest.bat
-rwxrwxrwx. 1 root root 1922 12月 2 2015 configtest.sh
-rwxrwxrwx. 1 root root 7888 12月 2 2015 daemon.sh
-rwxrwxrwx. 1 root root 2091 12月 2 2015 digest.bat
-rwxrwxrwx. 1 root root 1965 12月 2 2015 digest.sh
-rwxrwxrwx. 1 root root 3430 12月 2 2015 setclasspath.bat
-rwxrwxrwx. 1 root root 3547 12月 2 2015 setclasspath.sh
-rwxrwxrwx. 1 root root 2020 12月 2 2015 shutdown.bat
-rwxrwxrwx. 1 root root 1902 12月 2 2015 shutdown.sh
-rwxrwxrwx. 1 root root 2022 12月 2 2015 startup.bat
-rwxrwxrwx. 1 root root 1904 12月 2 2015 startup.sh
-rwxrwxrwx. 1 root root 40845 12月 2 2015 tomcat-juli.jar
-rwxrwxrwx. 1 root root 388787 12月 2 2015 tomcat-native.tar.gz
-rwxrwxrwx. 1 root root 4057 12月 2 2015 tool-wrapper.bat
-rwxrwxrwx. 1 root root 5061 12月 2 2015 tool-wrapper.sh
-rwxrwxrwx. 1 root root 2026 12月 2 2015 version.bat
-rwxrwxrwx. 1 root root 1908 12月 2 2015 version.sh
#重启tomcat
[root@localhost bin]# ./shutdown.sh
Using CATALINA_base: /usr/local/apache-tomcat-8.0.30
Using CATALINA_HOME: /usr/local/apache-tomcat-8.0.30
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.0.30/temp
Using JRE_HOME: /usr/local/jdk1.8.0_141/jre
Using CLASSPATH: /usr/local/apache-tomcat-8.0.30/bin/bootstrap.jar:/usr/local/apache-tomcat-8.0.30/bin/tomcat-juli.jar
[root@localhost bin]# ./startup.sh
Using CATALINA_base: /usr/local/apache-tomcat-8.0.30
Using CATALINA_HOME: /usr/local/apache-tomcat-8.0.30
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.0.30/temp
Using JRE_HOME: /usr/local/jdk1.8.0_141/jre
Using CLASSPATH: /usr/local/apache-tomcat-8.0.30/bin/bootstrap.jar:/usr/local/apache-tomcat-8.0.30/bin/tomcat-juli.jar
Tomcat started.
在地址栏中输入http://localhost:8080或localhost:8080回车,如果看到Tomcat自带的一个JSP页面,说明JDK和Tomcat已搭建成功。



