Install Apache-Tomcat-7.0.54

Source: Internet
Author: User
Tags apache tomcat

Tool introduction:

Tomcat is used to run JSP websites. It is a core project of the Jakarta project of the Apache Software Foundation. It is a stable, open-source, free, and popular Web application server.

Installation environment:

The environment is set up on a Windows Server, and tomcat users use MySQL storage (MySQL is a user account storage server for multiple software systems, which is very convenient)

Operating System: Windows Server 2008 R2 Enterprise (64-bit)

MySQL: Any Version

Java version: jdk_1.6.0_24

Tomcat version and Java version need to correspond, refer to the http://tomcat.apache.org/whichversion.html

Download the installation package:

Tomcat: Tomcat official website download: http://tomcat.apache.org/

Here to download the 32-bit Windows Installation Package: apache-tomcat-7.0.54.zip

Mysqljdbc. jar:

Installation Process:

1. decompress the installation package to any path. Select D: \ apache-Tomcat-7.0.54.

2. Set Environment Variables

Computer> Properties> advanced system Settings> environment variables> system variables> New:

Variable name: tomcat_home

Variable value: D: \ apache-Tomcat-7.0.54

3. Set the software as a service and start it on startup

Set as a service:

Switch the command line to: D: \ apache-Tomcat-7.0.54 \ bin

Run the command: Service. Bat install

Set to boot:

Start-> Administrative Tools-> services-> Apache Tomcat 7.0 tomcat7-> General-> Startup Type: automatic

Start the service and make it run

4. Set firewall

Start-> Administrative Tools-> Advanced Security Windows Firewall-> local computer...-> inbound rules-> new rules:

Program-> path: D: \ apache-Tomcat-7.0.54 \ bin \ tomcat7.exe-> allow connection: domain, private, public-> name: tomcat7-> complete

Refresh the firewall to make it take effect

5. Check whether the test is successful.

Use a non-local computer to access: http: // local IP: 8080. If the Tomcat welcome page appears, the installation is successful.

6. Store Tomcat user accounts in MySQL

Assume that the MySQL Administrator account is root Root.

Assume that the database storing user information is authority.

Assume that the user table: Users username field: user_name password field: user_pass

Assume that the role table: roles role name segment: role_name

Assume that the user role relationship table: user_role username field: user_name role name segment: role_name

Assume that a new Tomcat administrator user is created: Ta 1234

A) Copy mysqljdbc. jar to D: \ apache-Tomcat-7.0.54 \ Lib.

B) run the following SQL script in MySQL:

 

 

CREATE DATABASE `authority`;USE `authority`;/*Table structure for table `users` */DROP TABLE IF EXISTS `users`;CREATE TABLE `users` (  `user_name` varchar(20) NOT NULL,  `user_pass` varchar(20) NOT NULL,  PRIMARY KEY (`user_name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;/*Data for the table `users` */insert  into `users`(`user_name`,`user_pass`) values (‘ta‘,‘1234‘);/*Table structure for table `roles` */DROP TABLE IF EXISTS `roles`;CREATE TABLE `roles` (  `role_name` varchar(20) NOT NULL,  PRIMARY KEY (`role_name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;/*Data for the table `roles` */insert  into `roles`(`role_name`) values (‘manager-gui‘),(‘manager-jmx‘),(‘manager-script‘),(‘manager-status‘);/*Table structure for table `user_role` */DROP TABLE IF EXISTS `user_role`;CREATE TABLE `user_role` (  `user_name` varchar(20) NOT NULL,  `role_name` varchar(20) NOT NULL,  KEY `FK_user` (`user_name`),  KEY `FK_role` (`role_name`),  CONSTRAINT `FK_role` FOREIGN KEY (`role_name`) REFERENCES `roles` (`role_name`) ON DELETE CASCADE ON UPDATE CASCADE,  CONSTRAINT `FK_user` FOREIGN KEY (`user_name`) REFERENCES `users` (`user_name`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8;/*Data for the table `user_role` */insert  into `user_role`(`user_name`,`role_name`) values (‘ta‘,‘manager-gui‘);
Code

C) modify the D: \ apache-Tomcat-7.0.54 \ conf \ Server. xml file and add the following content under the <service name = "Catalina"> node:

 

      <Realm className="org.apache.catalina.realm.JDBCRealm"        driverName="org.gjt.mm.mysql.Driver"        connectionURL="jdbc:mysql://localhost/authority?user=root&amp;password=root"        userTable="users" userNameCol="user_name" userCredCol="user_pass"        userRoleTable="user_role" roleNameCol="role_name"/>
Code

 

 

 

 

 

 

 

 

 

  

 

Install Apache-Tomcat-7.0.54

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.