Windows Server Set up Tomcat Server and Java project application

This article mainly introduces the use of Ali Cloud Windows Server to build Tomcat Server and Java project application, after writing the article you can also have a look in time.


Tools and Software

  • Server: Aliyun Windows Server 2012 R2 Datacenter 64-bit Chinese version
  • Remote Desktop connection tool: Microsoft Remote Desktop for Mac
  • The JDK: jdk1.8.0 _131
  • MYSQL: MYSQL – 5.6.36 – winx64
  • Application server: Apache-tomcat-7.0.79
  • PS: the owner of the building uses Mac development, if there is any difference, please understand

Visualizing Windows Server tools

I bought a Window server on Ali Cloud, so I directly use Ali Cloud server to demonstrate, as follows:

The next step is the detailed server interface:

It is recommended that you use Remote Desktop connection tools, here the main use of Mac OS X Microsoft Remote Desktop for Mac, here will not be detailed, specific download way Baidu many.

Microsoft Remote Desktop Connection properties are attached here as follows:

After filling in the information, you can enter the Windows Server. The interface is the same as the common Windows interface.

Win2012_64, so the first step into the server configuration is completed.

JDK & MYSQL

C: Program Files\Java\jdk1.8.0_131 C:\server\mysql-5.6.36-winx64, configure mysql environment variables, create localhost database, add admin user and grant database permissions; At this point the JDK and mysql are ready.

Tomcat structures,

Apache-tomcat-7.0.79, apache-tomcat-7.0.79, apache-tomcat-7.0.79 1: Install Tomcat

Install tomcat server directly, all the way down, install to the end is OK (too many online resources); Note: If you want to directly access the tomcat server Files or add Files and folders to the Tomcat project code, the tomcat folder should not be placed under Program Files. The recommended path is C:\ tomcat 7.0 or C:\soft\ tomcat 7.0.

2: Configure the database and automatic deployment code

To configure the database, go to the tomcat/conf/context. XML file and add the following code to the context tag:

<Resource name="jdbc/db" auth="Container"
factory="com.alibaba.druid.pool.DruidDataSourceFactory"
	   type="javax.sql.DataSource"
	   driverClassName="com.mysql.jdbc.Driver"
	   url="jdbc:mysql://localhost:3306/test? useUnicode=true& characterEncoding=utf-8"
	   username="admin"
	   password="123456"
	   maxActive="500"
	   initialSize="15"
	   maxIdle="15"
	   minIdle="15"
	   maxWait="30000"
	   removeAbandoned="true"
	   removeAbandonedTimeout="60"
	   logAbandoned="false"
	   timeBetweenEvictionRunsMillis="900000"
	   minEvictableIdleTimeMillis="1800000"
	   numTestsPerEvictionRun="10"
	   poolPreparedStatements="true"
	   maxOpenPreparedStatements="500"
	   validationQuery="SELECT 1"
	   validationInterval="60000"
	   testOnBorrow="true"/>
Copy the code

To configure automatic decompression deployment, go to the tomcat/conf/server. XML file and add the following code to the Host tag:

<Context docBase="C: \ Tomcat 7.0 \ webapps \ ROOT war" path="/" reloadable="true"/>
Copy the code

The default server access project is ROOT. For convenience, we can directly change the name of the war package to root. war. If you want to use a custom name, change ROOT to custom XXX in docBase. When accessing the project, you need to add/XXX/after the domain name to access the project.

At this point our Tomcat has been set up successfully.

Project access

Go to tomcat/webapps/, rename the old ROOT folder to ROOT_old, click tomcat/bin/ tomcat7w.exe, click Start to start tomcat. The ROOT folder is automatically decompressed, and the browser can access localhost:8080.

PS:

If you use domain names to access websites, you need to set additional port security rules as follows: Cloud Server ECS > Network and Security > Security Group Configuration Rules > Quick Creation Rules

The above common ports need to be configured, and then OK

This article is over, if you have any questions, please leave a message, welcome to exchange!

Scan the qr code below and follow my official account!!