Java web and web gis study notes (a) - Tomcat environment to build

A .JDK installation and configuration environment

JDK is the Java language Software Development Kit, is the core of java development, it contains the Java Runtime Environment JRE (JVM + Java system class library) and Java tools. Deploy Tomcat server requires JDK support.

  1. In Oracle's official website can download a free version of the JDK their needs, Oracle need to register an account and login. If you think the official website download speed is too slow can use this link to download the Java SE 8u241
    link: https://pan.baidu.com/s/1NXFhIvOlrlDW2db7m6wvMg
    extraction code: pe7w
  2. Run the downloaded JDK installation package to Jdk-8u241-Windows-x64 for example, click Next to complete the installation. Also according to their need to install to a different path (not recommended). Jre installed next to the appropriate directory jdk like, it is recommended that the default installation path
    2345 screenshots 20200302153032
    2345 screenshots 20200302153134
  3. Configuring JDK environment variable. You need to add to the system after the installation is complete JDK environment variables,
    1) the new "JAVA_HOME" variable in the system variable, the variable value: C: \ Program Files \ the Java \ jdk1.8.0_241 (here write their own jdk installation path)
    2 ) New system variables in the "classpath" variable, the variable value: ;.% JAVA_HOME% \ lib;% JAVA_HOME% \ lib \ tools.jar
    3) to find the path variable and edit, add variable value % JAVA_HOME% \ bin;% JAVA_HOME% \ jre \ bin
    specific methods can refer to this blog https://www.cnblogs.com/xch-yang/p/7629351.html

Deploy two .Tomcat server

Tomcat server is a free open source Web application server, are lightweight application server, is widely used in small and medium systems and concurrent user access is not a lot of occasions, is the first choice of program development and debugging JSP

  1. From apache tomcat download version of the official website you need Tomcat (for example to Tomcat 8). For Windows, the official website provides two ways to install version and unpack version. Specific reference https://www.iteye.com/blog/zhuanghu-849155 this difference can a blog. Here I choose the 64-bit version of decompression.
    Snipaste_2020-03-02_16-16-29
    If the download speed is slow Tomcat can also be downloaded via the following link 8
    link: https://pan.baidu.com/s/1H-tqfjwuHpdhR8HYcDUhgg
    extraction code: v046

  2. The downloaded Tomcat 8 decompression, following directory structure
    image-20200302164827261
    • bin目录 : 主要存放Tomcat命令,以.sh结尾的文件表示Linux的命令,以.bat结尾的文件表示Windows下的批处理命令。其中startup文件用于启动Tomcat,shutdown文件用于关闭Tomcat
    • conf目录: 存放Tomcat服务器的各种配置文件等。
    • lib目录: 存放Tomcat服务器所需要的所有jar包。
    • log目录: 存放Tomcat执行产生的日志文件。
    • temp目录: 用于存放Tomcat执行过程中产生的临时文件。
    • webapps目录: 是Tomcat的默认部署路径。Tomcat启动时会加载该目录下的程序,可以将自己的网页以war包,jar包和普通文件夹三种形式发布。之后我们见到的Tomcat的默认页面也在该目录下的ROOT文件夹中。
    • work目录: 用于存放Tomcat运行编译后的项目文件。
  3. 点击bin目录下的startup.bat文件,运行Tomcat服务器。
    需要注意的是,如果点击startup.bat文件之后,黑框一闪而过,可能是JDK环境变量中JAVA_HOME未配置正确,需要检查其是否为JDK安装路径,或者修改bin目录下的startup.bat文件(不推荐):在第一行前面加入如下两行--
    SET JAVA_HOME=(JDK目录) SET CATALINA_HOME=(前面解压后Tomcat的目录)
    如果需要使用shutdown.bat关闭服务器,也需要在shutdown.bat文件添加以上语句。
    image-20200302171927535
    如果出现如上图所示的中文乱码情况,可能是由于其编码方式与系统编码不同,在conf目录下找到logging.properties文件,将其中的
    java.util.logging.ConsoleHandler.encoding = UTF-8
    改为
    java.util.logging.ConsoleHandler.encoding = GBK
    就okk了

  4. Tomcat的默认端口是8080,保证该端口没有被占用(例如Oracle数据库会占用8080接口)。如果被占用,可以在conf目录下的server.xml文件中修改端口。

  5. At this point, enter in the browser http: // localhost: 8080 will be able to access the default page under Tomcat ROOT directory, you can see alovelySmall cat.

Deployment of the simple static web project

  1. I would like to create a random html, as a simple static web page (for example, named helloWorld.html)
    image-20200302185342733

  2. Create a new file in the webapps directory folder (such as hello) as a directory of the project and put your static pages in this folder

  3. The Tomcat server startup, you can http: // localhost: 8080 / hello / helloWorld.html visit this page friends. If you do not want to be accessed through the folder directory name (hello), may be in the server.xml file The tag, add
    <Context docBase="hello" path="/yahaha" reloadable="true"/>
    in which the value docBase file you just created folder name, URL path to access the value of this project in the virtual directory. Can be set up after the http: // localhost: 8080 / yahaha / helloWorld.html access to the project.
    image-20200302185012684

  4. These steps just to ensure that the project can visit our deployed by the network (127.0.0.1 or localhost).
    If the Tomcat server is deployed on the cloud, for example, ESC Ali cloud instances, you want to access the Tomcat deployment project through a public network, you need to configure the appropriate security group policy for ESC Ali cloud instance on site, open port 8080.
    2345 screenshots 20200302190653
    For details refer to this blog https://blog.csdn.net/qq_34496005/article/details/95320547

  5. After the setup is complete appropriate safety set of rules that can be accessed via the public network ip ESC instance of it!
    2345 screenshots 20200302190859

Guess you like

Origin www.cnblogs.com/ssjxx98/p/12395417.html