What is tomcat? tomcat how to use?
Please refer to the official website https://tomcat.apache.org/tomcat-9.0-doc/index.html
For detailed description please click https://www.cnblogs.com/xdp-gacl/p/4097608.html
method one:
Download tomcat installation package
Decompression
./startup.sh run under the bin file
- bin: mainly open, change the Tomcat command
- conf: store some configuration files
- lib: store some libraries, is that some jar package
- logs: log files generated by the operation storage
- temp: When saving operation to generate some temporary files
- webapps: deployment of applications to be run on this store directory
- work: class files generated during operation
Method Two:
From Shanghai long https://www.cnblogs.com/yoyoketang/p/10186513.html
Foreword
Install the software on linux, you can use yum very convenient, no need to download codecs, you can use a command yum install java and tomcat environment.
General Development Kit is a .war file, which need to use a middle button, such as a tomcat, tomcat is dependent on the java environment, so install java environment
environment to prepare:
1.Linux system servers: CentOS 7
2.yum 3.4.3
3.java 1.8
4.tomcat
yum environment
yum (called the Yellow dog Updater, Modified) is a front end package manager Shell Fedora and RedHat and CentOS in. Based on RPM packages can be automatically downloaded from the server specified RPM package and install, can be handled automatically dependencies and install all dependent packages, again without cumbersome download, install
First check under the current system, there are no tools yum, some words do not installed. I am here to display the system which already have this tool yum-3.4.3, so no need to install.
rpm -qa | grep yum
[root@yoyo ~]# rpm -qa | grep yum
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-plugin-fastestmirror-1.1.31-42.el7.noarch yum-3.4.3-154.el7.centos.noarch
java environment
Since jdk has been configured, there is no longer download and install, because the method is different, so do the record!
To see if there is java environment: rpm -qa | grep java
If there is no java environment, then went to find the installation package can then use the java-1.8.0: yum list | grep java-1.8.0 -openjdk
[root@yoyo ~]# yum list | grep java-1.8.0-openjdk java-1.8.0-openjdk.i686 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk.x86_64 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-accessibility.i686 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-accessibility-debug.i686 java-1.8.0-openjdk-accessibility-debug.x86_64 java-1.8.0-openjdk-debug.i686 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-debug.x86_64 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-demo.i686 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-demo.x86_64 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-demo-debug.i686 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-demo-debug.x86_64 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-devel.i686 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-devel.x86_64 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-devel-debug.i686 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-devel-debug.x86_64 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-headless.i686 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-headless.x86_64 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-headless-debug.i686 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-javadoc-debug.noarch 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-javadoc-zip.noarch 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-javadoc-zip-debug.noarch java-1.8.0-openjdk-src.i686 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-src.x86_64 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-src-debug.i686 1:1.8.0.191.b12-1.el7_6 updates java-1.8.0-openjdk-src-debug.x86_64 1:1.8.0.191.b12-1.el7_6 updates
Install all the files java-1.8.0-openjdk
[root@yoyo ~]# yum -y install java-1.8.0-openjdk*
The installation process takes 1-2 minutes, a cup of coffee is now installed, check the version number: java -version
[root@yoyo ~]# java -version openjdk version "1.8.0_191" OpenJDK Runtime Environment (build 1.8.0_191-b12) OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
Then enter javac, if you can see what it means output has been installed
[root@yoyo ~]# javac Usage: javac <options> <source files> where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output messages about what the compiler is doing -deprecation Output source locations where deprecated APIs are used -classpath <path> Specify where to find user class files and annotation processors
Installed java junior partner should be aware that you need to set the environment variable After installation is complete, the benefits of front via yum install is already automatically help us set up the environment variables.
Do openjdk and jdk is not much difference? That why I had to uninstall the Si Jin fee! embarrassed
tomcat installation --yum installation
tomcat installation can download the installation package, and then decompressed. Online can be directly used yum install yum here with us directly online more convenient installation
yum install tomcat //或者 yum -y install tomcat
-y met representatives are elected to ask y, so the installation process does not need to manually enter the y ---------- (another harvest, turned out to be mean)
after the installation is complete, the installation directory in the "/ usr / share / tomcat ", we use the cd command to cut this catalog, view the directory of files with ls (or ll) command
[root@yoyo tomcat]# ls bin conf lib logs temp webapps work [root@yoyo tomcat]# ll total 4 drwxr-xr-x 2 root root 4096 Dec 28 10:41 bin lrwxrwxrwx 1 root tomcat 11 Dec 28 10:41 conf -> /etc/tomcat lrwxrwxrwx 1 root tomcat 22 Dec 28 10:41 lib -> /usr/share/java/tomcat lrwxrwxrwx 1 root tomcat 15 Dec 28 10:41 logs -> /var/log/tomcat lrwxrwxrwx 1 root tomcat 22 Dec 28 10:41 temp -> /var/cache/tomcat/temp lrwxrwxrwx 1 root tomcat 23 Dec 28 10:41 webapps -> /var/lib/tomcat/webapps lrwxrwxrwx 1 root tomcat 22 Dec 28 10:41 work -> /var/cache/tomcat/work
Start tomcat service
View tomcat status : systemctl status tomcat
[root@yoyo tomcat]# systemctl status tomcat ● tomcat.service - Apache Tomcat Web Application Container Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled) Active: inactive (dead)
Active: inactive (dead) Description tomcat is now in a dead (hung up) state, the service has not yet up and running.
Start Tomcat : systemctl Start Tomcat (or systemctl start tomcat.service)
[root@yoyo tomcat]# systemctl start tomcat [root@yoyo tomcat]# systemctl status tomcat ● tomcat.service - Apache Tomcat Web Application Container Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2018-12-28 10:48:38 CST; 5s ago Main PID: 5216 (java) CGroup: /system.slice/tomcat.service └─5216 /usr/lib/jvm/jre/bin/java -classpath /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin... Dec 28 10:48:38 yoyo server[5216]: Dec 28, 2018 10:48:38 AM org.apache.catalina.core.StandardService startInternal Dec 28 10:48:38 yoyo server[5216]: INFO: Starting service Catalina Dec 28 10:48:38 yoyo server[5216]: Dec 28, 2018 10:48:38 AM org.apache.catalina.core.StandardEngine startInternal Dec 28 10:48:38 yoyo server[5216]: INFO: Starting Servlet Engine: Apache Tomcat/7.0.76 Dec 28 10:48:38 yoyo server[5216]: Dec 28, 2018 10:48:38 AM org.apache.coyote.AbstractProtocol start Dec 28 10:48:38 yoyo server[5216]: INFO: Starting ProtocolHandler ["http-bio-8080"] Dec 28 10:48:38 yoyo server[5216]: Dec 28, 2018 10:48:38 AM org.apache.coyote.AbstractProtocol start Dec 28 10:48:38 yoyo server[5216]: INFO: Starting ProtocolHandler ["ajp-bio-8009"] Dec 28 10:48:38 yoyo server[5216]: Dec 28, 2018 10:48:38 AM org.apache.catalina.startup.Catalina start Dec 28 10:48:38 yoyo server[5216]: INFO: Server startup in 61 ms Hint: Some lines were ellipsized, use -l to show in full.
You can see the state Active: active (running)
, this time has been on behalf of tomcat normal run up.
You can also view Main PID: 5216 (java)
know is PID 5216
Access tomcat
tomcat default port is 8080, then enter the browser address: http: // server public network ip: 8080 /. This page is temporarily inaccessible
due to the tomcat web page is the need to install plug-ins here and continue to use the tomcat-webapps tomcat-admin-webapps two plug-in package
yum install tomcat-webapps tomcat-admin-webapps
Port, authority, firewall issues themselves ---
Browser to access http: // server public network ip: 8080 , you can open an address of a tomcat
doubt
This, everything is normal, but my version is 7.0.76 installed! Yum may only install this version of it!
Manager App user name and password
If you want to enter Manager App, at home the point Manager App
there will be a pop-up box, enter a user name and password
Direct point canceled, there will be 401 interface
Copy the red frame of two lines, you can directly set username = "root" password = "root"
<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
Then opening the Xshell, enter tomcat installation directory (cd / usr / share / tomcat), into the conf directory, tomcat-users.xml file is opened, at the tag, add the following configuration:
<role rolename="manager-gui"/>
<user username="root" password="root" roles="manager-gui"/>
Edit the file, you can use vi or vim points to open the file directly edit
cd /usr/share/tomcat
cd conf
vim tomcat-users.xml
After opening the vim, i is the keyboard keys to enter the edit mode, to move the mouse over the last line, directly pasted into the line
After editing, press the ESC key, enter :wq
Enter to save and exit
tomcat related commands
Stop tomcat service ---- systemctl stop tomcat
Restart tomcat --------- systemctl restart tomcat
Boot --------- systemctl enable tomcat
查看tomcat状态------systemctl status tomcat
启动tomcat------systemctl status tomcat