Installing configuration Java and Tomcat under Linux systems

Source: Internet
Author: User
Tags symlink wrapper blank page

Personal habits to put the source package under opt

1. Installing the JDK

The JDK is the Java operating environment, the entire Jenkins is a var package, is written by Java program.

1.1. Install via Yum

A. Install Yum:

#yum Install wget

Download in opt catalogue

  #cd opt  #wget http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

B. Download and upload

A.Oracle downloads the latest version of the JDK (jdk-8u171-linux-x64.tar.gz):

Http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

B. Install the upload command

Yum-y Install Lrzsz

C. In the OPT directory, run rz-be and upload the file.

rz-be
1.3. Unzip the TAR package
TAR-ZXVF jdk-8u171-linux-x64.tar.gz

LS Confirmation has been extracted: (fill in the map)           

1.4 Move the extracted files to the/usr/local/
MV jdk1.8.0_171//usr/local/

LS Confirmation has been moved under/usr/local/: (Complement map)

1.5 making Java soft links  
Ln-s/usr/loca/jdk/usr/local/java

Ln-s/usr/loca/jdk/usr/local/java

Remove Soft Link: RM java********

Why do you want to do a soft link ***********

JDK often to ascend version, if upgrade, do a soft link, just need to delete the previous soft link, re-do a soft link (ln-s jdk1.9.0/java). The path inside the program does not have to be changed, the configuration file, environment variables should not be re-matching.

Whether Java,tomcat,nginx is a soft link, link to a version number, if you want to upgrade, the soft link refers to the new version number ********

1.6 Configuring environment variables

1. Open Environment variables

[Email protected] local]# Vi/etc/profile

2. add /usr/local/java to path:

Place the following sentence at the end of the/etc/profile . path=/usr/local/java/bin: $PATH

3. exit the login again, or execute source/etc/profile directly

4. Run java-version to see if it is successful.

[[email protected] local]# Java-versionjava version "1.8.0_171" Java (TM) SE Runtime Environment (build 1.8.0_171-B11) Java HotSpot (TM) 64-bit Server VM (build 25.171-b11, Mixed mode)

 

2. Install Tomcat

Tomcat is a Java container that is itself a web container that can provide Web pages or provide parsing of Java pages.

All Java-developed, either directly from the Var package or with a container.

2.1 in the OPT directory, the Apache official website Downloads the latest version of Tomcat.

[Email protected] opt]# wget http://apache.fayea.com/tomcat/tomcat-8/v8.5.30/bin/apache-tomcat-8.5.30.tar.gz

[email protected] opt]# LL
Total 195740
-rw-r--r--. 1 root root 9541892 Apr 4 04:35 apache-tomcat-8.5.30.tar.gz
-rw-r--r--. 1 root root 190890122 Apr 17:15 jdk-8u171-linux-x64.tar.gz

2.2 Tomcat can be used directly by unlocking the boot, provided the JDK is installed correctly

[Email protected] opt]# TAR-ZXVF apache-tomcat-8.5.30.tar.gz

[email protected] opt]# LL
Total 195740
Drwxr-xr-x. 9 root root (APR) 11:08 apache-tomcat-8.5.30
-rw-r--r--. 1 root root 9541892 Apr 4 04:35 apache-tomcat-8.5.30.tar.gz
-rw-r--r--. 1 root root 190890122 Apr 17:15 jdk-8u171-linux-x64.tar.gz

2.3 Move to/usr/local/

[[Email protected] opt]# mv Apache-tomcat-8.5.30/usr/local/[[email protected] opt]# cd/usr/local/[[email protected] Loc al]# lltotal 0drwxr-xr-x. 9 root root (APR) 11:08 apache-tomcat-8.5.30

2.4 Making Soft Links

[Email protected] local]# ln-s apache-tomcat-8.5.30/tomcat[[email protected] local]# lsapache-tomcat-8.5.30  etc< C1/>include  jdk1.8.0_171  lib64    sbin   srcbin                   Games  Java     lib           libexec  share  Tomcat

2.5 Tomcat needs to start

Tomcat start and Stop commands: All under the bin of the home directory, there is a catalina.sh

[[Email protected] local]# CD Tomcat/[[email protected] tomcat]# lsbin lib logs release-notes temp workconf LICENSE NOTICE RUNNING.txt WebApps
[Email protected] tomcat]# CD bin/
[[email protected] bin]# ls
Bootstrap.jar daemon.sh startup.sh
Catalina.bat Digest.bat Tomcat-juli.jar
catalina.sh digest.sh tomcat-native.tar.gz
Catalina-tasks.xml Setclasspath.bat Tool-wrapper.bat
Commons-daemon.jar setclasspath.sh tool-wrapper.sh
commons-daemon-native.tar.gz Shutdown.bat Version.bat
Configtest.bat shutdown.sh version.sh
Configtest.sh Startup.bat

Start: SH catalina.sh start

[[Email protected] bin]# sh catalina.sh startusing catalina_home:   /usr/local/tomcatusing catalina_tmpdir:/usr/ Local/tomcat/tempusing jre_home:        /usr/local/javausing CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/ Usr/local/tomcat/bin/tomcat-juli.jartomcat started.

usually start with a node: start tomcat up and log on by the way.

(no var package can start up in half a second.) This time there is no VAR package, if open site is blank page)

[Email protected] bin]# sh catalina.sh start;tail-f. /logs/catalina.outusing catalina_base:   /usr/local/tomcatusing catalina_home:   /usr/local/tomcatusing Catalina_tmpdir:/usr/local/tomcat/tempusing jre_home:        /usr/local/javausing CLASSPATH:       /usr/local/tomcat/ Bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jartomcat started.

2.6 See if Port 8080 is started:

To see if the boot was successful, the Tomcat default port is 8080

NETSTAT-LNP: Is the ******* of the view port

A. Install Net-tools:

[email protected] bin]# Yum install Net-tools

B. View ports:

[email protected] bin]# Yum install Net-tools

Active Internet connections (only servers)
Proto recv-q send-q Local address Foreign address State Pid/program Name
TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1144/sshd
TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1243/master
TCP6 0 0::: 8080:::* LISTEN 1728/java

Log in with your browser:

Now the edge login cannot find the page because the 8080 port is not added to the firewall to allow access within. Can be added or turned off the firewall.

[[email protected] conf]# systemctl stop firewalld.service[[email protected] conf]# systemctl Disable firewalld.serviceremoved symlink/etc/systemd/system/multi-user.target.wants/firewalld.service.removed symlink/ Etc/systemd/system/dbus-org.fedoraproject.firewalld1.service.

[Email protected] conf]# systemctl status Firewalld.service
firewalld.service-firewalld-dynamic Firewall daemon
loaded:loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset:enabled)
Active:inactive (Dead)
DOCS:MAN:FIREWALLD (1)

3. How to configure tomcat:3.1 to stop Tomcat:

Enter/tomcat/bin inside Stop catalina.sh, stop after using Ps-ef | grep Java to see if it really stops (the Java process is gone).

[[Email protected] bin]# sh catalina.sh stopusing catalina_base:   /usr/local/tomcatusing catalina_home:   /usr/ Local/tomcatusing catalina_tmpdir:/usr/local/tomcat/tempusing jre_home:        /usr/local/javausing CLASSPATH:       / Usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar[[email protected] bin]# Ps-ef | grep javaroot      1882  1320  0 13:16 pts/0    00:00:00 grep--color=auto java

3.2 Go to the main directory (Tomcat)/webapps, the others are deleted, leaving only one root,root under also empty.

Including manage also want to delete, if use manage, and to public network release, then instantaneous will be broken off.

[[Email protected] tomcat]# CD Webapps/[[email protected] webapps]# lsdocs  examples  host-manager  Manager  

3.3 In Tomcat/conf/server.xml the capital of the shutdown casually changed to what.

This is a feature on the page that can turn off Tomcat and disable this feature. (or you can disable port 8005)

---------to the security of this tomcat is done, you can add something to it. At least not from the problem of Tomcat itself, at least not from the Tomcat page, and the Manager,shutdown is a very simple exploit to come in.

3.4 How to put the project into Tomcat

Tomcat itself can solve the Var package, but there is a drawback: put the Var package into the big root directory, the start of the Tomcat,var package will be automatically solved. This time if you want to modify some parameters in the Var package, configuration, modification, the next time you start Tomcat, again from the Var package to undo the parameters and configuration modified before the start, there will be no need to reconfigure.

So we've all solved the Var package and then put it under the Tomcat path and then load it into the big root directory or the directory with the big root.

4. Install Jenkins

4.1 Download Jenkins via wget

[Email protected] opt]# wget Http://mirrors.jenkins.io/war-stable/latest/jenkins.war

4.2 Create a new directory Jenkins, and copy the Var package in

Place the content extracted from the Jenkins VAR package

Because Jenkins's VAR package unlocks no

[[email protected] opt]# mkdir jenkins[[email protected] opt]# mv Jenkins.war jenkins/[[email protected] opt]# CD jenkins[ [Email protected] jenkins]# lltotal 72824-rw-r--r--. 1 root root 74568464 Apr 04:42 Jenkins.war

4.3 Extracting var package

[Email protected] jenkins]# JAR-XVF Jenkins.war

[[email protected] jenkins]# ls
Bootstrap Logfileoutputstream$2.class
Colorformatter.class Logfileoutputstream.class
CSS Main.class
Dc-license.txt Maindialog$1$1.class
Executable Maindialog$1.class
Favicon.ico Maindialog.class
Help Main$fileanddescription.class
Images Meta-inf
Jenkins.war robots.txt
Jnlpmain.class scripts
Jsbundles Web-inf
Logfileoutputstream$1.class Winstone.jar

Note: The Jenkins.var package above must be deleted. If you put it here, the hacker can take the Var package away. **********

[Email protected] jenkins]# RM Jenkins.war

4.4 to move Jenkins to the Tomcat directory under WebApps.

[email protected] opt]# CP jenkins.war/usr/local/tomcat/webapps/

[Email protected] opt]# cd/usr/local/tomcat/webapps/
[[email protected] webapps]# ls
Jenkins Jenkins.war ROOT

4.3 Start (reboot) Tomcat.

[[Email protected] bin]# sh catalina.sh startusing catalina_base:   /usr/local/tomcatusing catalina_home:   /usr/ Local/tomcatusing catalina_tmpdir:/usr/local/tomcat/tempusing jre_home:        /usr/local/javausing CLASSPATH:       / Usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jartomcat started.

4.4 Browser Access

Ip:8080/jenkins

Use of 5.tomcat

5.1 Log Address: Tomcat/logs/catalina.out

[Email protected] tomcat]# CD Logs/[[email protected] logs]# lscatalina.2018-04-28.log      Localhost.2018-04-28.logcatalina.out                 Localhost_access_log.2018-04-28.txthost-manager.2018-04-28.log  Manager.2018-04-28.log[[email protected] logs]# tail-f catalina.out

5.2 Ports

[Email protected] conf]# VI server.xml

Listening port is 8080

    <connector port= "8080" protocol= "http/1.1"               connectiontimeout= "20000"               redirectport= "8443"/>

Usually will change 8080, can be arbitrarily changed. Generally now does not use 8080 or 80, now generally in front of a Ngnix do forward, do static and dynamic separation.

Now the performance is good, do not pay attention to the movement separation, but still will be dynamic/java things to Tomcat, static to Ngnix, dynamic things.

The number of connections by default is 150, generally do not go to tune. If expansion is required, usually horizontally scaled, 1 containers are not enough, do 2 units.

mv/tmp/zz/*./-----Copy the entire contents to the current directory

Installing configuration Java and Tomcat under Linux systems

Related Article

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.