首页 > 代码库 > JAVA企业应用【第二篇】TOMCAT安装
JAVA企业应用【第二篇】TOMCAT安装
1、软件准备:
JDK下载:http://www.oracle.com
Tomcat下载:http://tomcat.apache.org/
2、部署java环境:
mkdir -p /application/tools/ && cd /application/tools/ tar xf jdk-8u60-linux-x64.tar.gz -C /application/ ln -s /application/jdk1.8.0_60 /application/jdk sed -i.ori ‘$a export JAVA_HOME=/application/jdk\nexport PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH\nexport CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar‘ /etc/profile source /etc/profile
[root@tomcat ~]# java -version java version "1.8.0_60" Java(TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
3、安装tomcat:
tar xf apache-tomcat-8.0.27.tar.gz -C /application/ ln -s /application/apache-tomcat-8.0.27 /application/tomcat echo ‘export TOMCAT_HOME=/application/tomcat‘>>/etc/profile source /etc/profile chown -R root.root /application/jdk/ /application/tomcat/
[root@tomcat ~]# tail -4 /etc/profile export JAVA_HOME=/application/jdk export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar export TOMCAT_HOME=/application/tomcat
4、tomcat目录:
[root@tomcat ~]# cd /application/tomcat/ [root@tomcat tomcat]# tree -L 1 . ├── bin #→用以启动、关闭Tomcat或者其它功能的脚本(.bat文件和.sh文件) ├── conf #→用以配置Tomcat的XML及DTD文件 ├── lib #→存放web应用能访问的JAR包 ├── LICENSE ├── logs #→Catalina和其它Web应用程序的日志文件 ├── NOTICE ├── RELEASE-NOTES ├── RUNNING.txt ├── temp #→临时文件 ├── webapps #→Web应用程序根目录 └── work #→用以产生有JSP编译出的Servlet的.java和.class文件 7 directories, 4 files [root@tomcat tomcat]# cd webapps/ [root@tomcat webapps]# ll total 20 drwxr-xr-x 14 root root 4096 Oct 5 12:09 docs #→tomcat帮助文档 drwxr-xr-x 6 root root 4096 Oct 5 12:09 examples #→web应用实例 drwxr-xr-x 5 root root 4096 Oct 5 12:09 host-manager #→管理 drwxr-xr-x 5 root root 4096 Oct 5 12:09 manager #→管理 drwxr-xr-x 3 root root 4096 Oct 5 12:09 ROOT #→默认网站根目录
5、启动tomcat:
#→启动程序/application/tomcat/bin/startup.sh
#→关闭程序/application/tomcat/bin/shutdown.sh
[root@tomcat ~]# /application/tomcat/bin/startup.sh Using CATALINA_BASE: /application/tomcat Using CATALINA_HOME: /application/tomcat Using CATALINA_TMPDIR: /application/tomcat/temp Using JRE_HOME: /application/jdk Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar Tomcat started. [root@tomcat ~]# netstat -tunlp|grep java tcp 0 0 :::8009 :::* LISTEN 4743/java tcp 0 0 :::8080 :::* LISTEN 4743/java [root@tomcat ~]# ps -ef|grep [j]ava
6、访问网站:
网址:http://1.1.1.1/8080
7、tomcat日志:
[root@tomcat tools]# cd /application/tomcat/logs/
[root@tomcat logs]# ls
catalina.2016-10-26.log host-manager.2016-10-26.log localhost_access_log.2016-10-26.txt
catalina.out localhost.2016-10-26.log manager.2016-10-26.log
#→tomcat实时日志
[root@tomcat logs]# tailf catalina.out 26-Oct-2016 15:53:23.782 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /application/apache-tomcat-8.0.27/webapps/docs has finished in 60 ms 26-Oct-2016 15:53:23.786 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /application/apache-tomcat-8.0.27/webapps/host-manager 26-Oct-2016 15:53:23.888 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /application/apache-tomcat-8.0.27/webapps/host-manager has finished in 102 ms 26-Oct-2016 15:53:23.889 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /application/apache-tomcat-8.0.27/webapps/examples 26-Oct-2016 15:53:24.673 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /application/apache-tomcat-8.0.27/webapps/examples has finished in 784 ms 26-Oct-2016 15:53:24.674 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /application/apache-tomcat-8.0.27/webapps/manager 26-Oct-2016 15:53:24.772 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /application/apache-tomcat-8.0.27/webapps/manager has finished in 98 ms 26-Oct-2016 15:53:24.779 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"] 26-Oct-2016 15:53:24.795 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"] 26-Oct-2016 15:53:24.800 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1994 ms
JAVA企业应用【第二篇】TOMCAT安装
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。