How To Install Apache Tomcat 7 on CentOS 7 via Yum
摘自:https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-7-on-centos-7-via-yum
Introduction
Apache Tomcat is a web server and servlet container that is used to serve Java applications. Tomcat is an open source implementation of the Java Servlet and JavaServer Pages technologies, released by the Apache Software Foundation.
This tutorial covers the basic installation and some configuration of Tomcat 7 with yum on your CentOS 7 server. Please note that this will install the latest release of Tomcat that is in the official Ubuntu repositories, which may or may not be the latest release of Tomcat. If you want to guarantee that you are installing the latest version of Tomcat, you can always download the latest binary distribution.
Note: Tomcat can be installed automatically on your Droplet by adding this script to its User Data when launching it. Check out this tutorial to learn more about Droplet User Data.
Prerequisites
Before you begin with this guide, you should have a separate,
non-root user account set up on your server. You can learn how to do
this by completing the initial server setup for CentOS 7 tutorial. We will be using the demo user for the rest of this tutorial.
Install Tomcat
Now you are ready to install Tomcat 7. Run the following command to install the Tomcat package:
- sudo yum install tomcat
Answer y at the confirmation prompt to install tomcat. This will install Tomcat 7 and its dependencies, such as Java, and it will also create the tomcat user.
Most of the important Tomcat files will be located in /usr/share/tomcat. If you already have a Tomcat application that you want to run, you can place it in the /usr/share/tomcat/webapps directory, configure Tomcat, and restart the Tomcat service. In this tutorial, however, we will install a few additional packages that will help you manage your Tomcat applications and virtual hosts.
Let's make a quick change to the Java options that Tomcat uses when it starts. Open the Tomcat configuration file:
- sudo vi /usr/share/tomcat/conf/tomcat.conf
Add the following JAVA_OPTS line to the file. Feel free to change the Xmx and MaxPermSize values—these settings affect how much memory Tomcat will use:
JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC"
Save and exit.
Note that the Tomcat service will not be running yet.
Install Admin Packages
If you are just getting started with Apache Tomcat, you will most likely want to install some admin tools that will help you deploy your Java applications and manage your virtual hosts. Luckily, there are packages that include these tools as web applications.
To install the default Tomcat root page (tomcat-webapps), and the Tomcat Web Application Manager and Virtual Host Manager (tomcat-admin-webapps), run this command:
- sudo yum install tomcat-webapps tomcat-admin-webapps
Answer y at the confirmation prompt.
This adds the ROOT, examples, sample, manager, and host-manager web apps to the tomcat/webapps directory.
Install Online Documentation (Optional)
If you want to install the Tomcat documentation, so that all of the links on the default Tomcat page will work, run this command:
- sudo yum install tomcat-docs-webapp tomcat-javadoc
Answer y at the prompt to install the documentation packages.
Configure Tomcat Web Management Interface
In order to use the manager webapp installed in the previous step, we must add a login to our Tomcat server. We will do this by editing the tomcat-users.xml file:
- sudo vi /usr/share/tomcat/conf/tomcat-users.xml
This file is filled with comments which describe how to configure the file. You may want to delete all the comments between the following lines, or you may leave them if you want to reference the examples:
<tomcat-users>
...
</tomcat-users>
You will want to add a user who can access the manager-gui and admin-gui (the management interface that we installed earlier). You can do so by defining a user similar to the example below. Be sure to change the username and password to something secure:
<tomcat-users>
<user username="admin" password="password" roles="manager-gui,admin-gui"/>
</tomcat-users>
Save and exit the tomcat-users.xml file.
Now we're ready to start the Tomcat service.
Start Tomcat
To put our changes into effect, restart the Tomcat service:
- sudo systemctl start tomcat
If you started the service earlier for some reason, run the restart command instead:
- sudo systemctl restart tomcat
Enable Tomcat Service
If you want Tomcat to run every time the server is booted up, you will need to enable the service:
- sudo systemctl enable tomcat
Now we're ready to access the web interface.
Access the Web Interface
Now that Tomcat is up and running, let's access the web management interface in a web browser. You can do this by accessing the public IP address of the server, on port 8080:
http://server_IP_address:8080
You will see something like the following image:

As you can see, there are links to the admin webapps that you installed earlier.
Let's take a look at the Manager App, accessible via the link or http://server_IP_address:8080/manager/html:

The Web Application Manager is used to manage your Java applications. You can Start, Stop, Reload, Deploy, and Undeploy here. You can also run some diagnostics on your apps (i.e. find memory leaks). Lastly, information about your server is available at the very bottom of this page.
Now let's take a look at the Host Manager, accessible via the link or http://server_IP_address:8080/host-manager/html/:

From the Virtual Host Manager page, you can add virtual hosts to serve your applications from.
Conclusion
Your installation of Tomcat is complete! Your are now free to deploy your own Java web applications!
How To Install Apache Tomcat 7 on CentOS 7 via Yum的更多相关文章
- How to Install Apache Tomcat 8.5 on CentOS 7.3
How to Install Apache Tomcat 8.5 on CentOS 7.3 From: https://www.howtoforge.com/tutorial/how-to-inst ...
- digitalocean --- How To Install Apache Tomcat 8 on Ubuntu 16.04
https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04 Intr ...
- install openjdk & tomcat on the centos
1.检查当前服务器是否已安装openjdk
- [转载]How To Install Nginx And PHP-FPM On CentOS 6 Via Yum
http://www.lifelinux.com/how-to-install-nginx-and-php-fpm-on-centos-6-via-yum/ http://blog.csdn.net/ ...
- 基于RedHat发行的Apache Tomcat本地提权漏洞
描述 Tomcat最近总想搞一些大新闻,一个月都没到,Tomcat又爆出漏洞.2016年10月11日,网上爆出Tomcat本地提权漏洞,漏洞编号为CVE-2016-5425.此次受到影响的主要是基于R ...
- Install Tomcat 6 on CentOS or RHEL --转载
source:http://www.davidghedini.com/pg/entry/install_tomcat_6_on_centos This post will cover installa ...
- 腾讯云Centos下Nginx反向代理Apache+Tomcat
1. 安装Apahce, PHP, MySQL以及php连接mysql库的组件#yum -y install httpd php mysql mysql-server php-mysql // ...
- Linux CentOS 7 下 Apache Tomcat 7 安装与配置
前言 记录一下Linux CentOS 7安装Tomcat7的完整步骤. 下载 首先需要下载tomcat7的安装文件,地址如下: http://mirror.bit.edu.cn/apache/tom ...
- Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7
Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7 By SK - August 12, 201 ...
随机推荐
- 汇编试验四:[bx] 和 loop 的使用
预备知识: 段前缀的使用: ffff:0~ffff:b 和 0020:0~0020:b 的数据: 一次循环的复制效果: 但是,这种方式DS的数据得修改: Source Code: assume cs: ...
- 【转】Android学习系列(39)--Android主题和样式之系统篇(上)
[基于最新的Android4.4的源码分析] 每家公司或者每个移动团队无不想开发出一套自己的UI框架,融入自己的设计和特性,这必然会去修改android的ui.所以,学习和理解android的UI设计 ...
- PHP 基础系列(三) 【转】PHP 函数实现原理及性能分析
作者:HDK (百度) 前言 在任何语言中,函数都是最基本的组成单元.对于PHP的函数,它具有哪些特点?函数调用是怎么实现的?php函数的性能如何,有什么使用建议?本文将从原理出发进行分析结合实际的性 ...
- Redis配置文件(3)常见的配置修改
常见的配置: redis.conf 配置项说明如下: 1. Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程 daemonize no 2. 当Redis以 ...
- Server.xml解析
来源 本文整理自 <Tomcat内核设计剖析>.<Tomcat结构解析> 加上自己的理解.源码来自 Tomcat8.5 版本 <Server port="800 ...
- 【题解】洛谷P3953 [NOIP2017TG] 逛公园(记忆化搜索+SPFA)
题目来源:洛谷P3953 思路 先用SPFA求一遍最短路 在求最短路的同时可以把所有点到终点的最短路求出来 dis数组 注意要反向SPFA 因为从起点开始可能会走到一些奇怪的路上导致时间负责度增加 ...
- Deepin深度Linux系统安装记录
测试设备:小米游戏本,最新版15.6进入安装后发现黑屏,所以使用15.5安装 Deepin 15.5 官方介绍页 官方下载 百度云下载 下载后得到文件夹15.5 Release 将里面的ISO镜像文件 ...
- NodeJ node.js Jquery Ajax 跨域请求
Jquery + Ajax 跨域请求 说白了就是前台请求ajax数据(JSON)但是请求的数据不在本地的绝对路径下,接口数据 是没有这个安全性的我对外公开的接口数据,只要你找到接口你就可以使用里面的数 ...
- 关于ajax请求数据的方法
$.ajax({ //课程详情信息 type:'get', data: {'id':courseId}, dataType:'json', beforeSend : ...
- vi模式下的编辑、删除、保存和退出
vi + 文件名:进入 vi 模式 编辑模式:shift+: 退出编辑模式:Esc 退出编辑模式后可进行光标的上下左右移动(偶尔会出现ABCD,还不知道怎么解决,目前只能出来一个删除一个) 光标处:按 ...