2018-05-15 Linux Learning

Source: Internet
Author: User
Tags log log apache tomcat

16.4 Configuring Tomcat Listening 80 ports

vim /usr/local/tomcat/conf/server.xmlConnector port="8080" protocol="HTTP/1.1"修改为Connector port="80" protocol="HTTP/1.1"/usr/local/tomcat/bin/shutdown.sh/usr/local/tomcat/bin/startup.sh

Operation Process

[[email protected] src]# vim /usr/local/tomcat/conf/server.xml    <Connector port="80" protocol="HTTP/1.1"               connectionTimeout="20000"               redirectPort="8443" />[[email protected] src]# /etc/init.d/nginx stopStopping nginx (via systemctl):                            [  确定  ][[email protected] src]# /usr/local/tomcat/bin/shutdown.sh[[email protected] src]# /usr/local/tomcat/bin/startup.sh浏览器打开 http://192.168.106.160  显示 Apache Tomcat/9.0.7 页面

16.5 Configuring a Tomcat virtual host (top)

Vim/usr/local/tomcat/conf/server.xml
Where the configuration between <Host> and </Host> is the virtual Host configuration section, name defines the domain name,
AppBase defines the application's directory, Java's application is usually a war compressed package, you just need to put the war's compressed package under the AppBase directory. The Tomcat default page just Amin access is actually under the AppBase directory, but in its subdirectory root.

Add virtual host, edit Server.xml, add below </Host> below
Unpackwars= "true" autodeploy= "true"
Xmlvalidation= "false" Xmlnamespaceaware= "false" >
<context path= "" docbase= "/data/wwwroot/123.cn/" debug= "0" reloadable= "true" crosscontext= "true"/>
</Host>

Operation Process

[Email protected] src]# Vim/usr/local/tomcat/conf/server.xml
Add below </Host>
Unpackwars= "true" autodeploy= "true"
Xmlvalidation= "false" Xmlnamespaceaware= "false" >
<context path= "" docbase= "/data/wwwroot/123.cn/" debug= "0" reloadable= "true" crosscontext= "true"/>
</Host>

16.6 Configuring the Tomcat Virtual Host (medium)

DocBase, this parameter is used to define the Web site's file storage path, if not defined, the default is under the Appbase/root, the definition of docBase is based on this directory, where AppBase and docBase can be the same. In this step of the process, many students have encountered the problem of access 404, in fact, docbase is not defined.
AppBase the directory for the application, usually it needs to put the war package directly under the directory, it will be automatically extracted into a program directory
Below we realize the role of the AppBase and Docbase directories by deploying a Java application

Download Zrlog wget Http://dl.zrlog.com/release/zrlog-1.7.1-baaecb9-release.war

MV zrlog-1.7.1-baaecb9-release.war/usr/local/tomcat/webapps/
Mv/usr/local/tomcat/webapps/zrlog-1.7.1-baaecb9-release/usr/local/tomcat/webapps/zrlog

Browser Access ip:8080/zrlog/install/
mv/usr/local/tomcat/webapps/zrlog/*/data/wwwroot/123.cn/

Operation Process

[[email protected] src]# wget http://dl.zrlog.com/release/zrlog-1.7.1-baaecb9-release.war[[email  Protected] src]# Ls/usr/local/tomcat/webapps/docs examples Host-manager Manager root[[email protected] src]# CP Zrlog-1.7.1-baaecb9-release.war/usr/local/tomcat/webapps/[[email protected] src]# ls/usr/local/tomcat/ Webapps/docs Examples Host-manager manager ROOT zrlog-1.7.1-baaecb9-release.war[[email protected] src]# ls/usr/        Local/tomcat/webapps/docs Host-manager ROOT zrlog-1.7.1-baaecb9-release.warexamples Manager Zrlog-1.7.1-baaecb9-release browser opens http://192.168.106.160/zrlog/[[email protected] webapps]#/etc/init.d/ Mysqld startstarting MySQL .... success! [[email protected] webapps]# mysql-uroot-paminglinuxmysql> CREATE DATABASE Zrlog; Query OK, 1 row Affected (0.00 sec) Mysql> Grant all on zrlog.* to ' Zrlog ' @127.0.0.1 identified by ' Aminglinux '; Query OK, 0 rows affected (0.01 sec) [[email protected] webapps]# mysql-uzrlog-h127.0.0.1-paminglinuxmysql> show databases;+--------------------+| Database |+--------------------+| Information_schema | | Test | | Zrlog |+--------------------+3 rows in Set (0.00 sec) Browser Open http://192.168.106.160/zrlog/Log in, you can post a blog

16.7 Configuring the Tomcat virtual host (bottom)

[[email protected] webapps]# mkdir /data/wwwroot/123.cn[[email protected] webapps]# mv /usr/local/tomcat/webapps/zrlog/* /data/wwwroot/123.cn/[[email protected] webapps]# /usr/local/tomcat/bin/shutdown.sh [[email protected] webapps]# /usr/local/tomcat/bin/startup.sh在浏览器里打开 www.123.cn

16.8 Tomcat Log

Ls/usr/local/tomcat/logs
The log that begins with Catalina is the synthetic log of Tomcat, which records information about the Tomcat service and logs the error log.
where Catalina.2017-xx-xx.log and catalina.out content are the same, the former generates a new log every day.
Host-manager and manager are management-related logs, where Host-manager is the management log for the virtual host.
LocalHost and localhost_access are virtual host-related logs, where the log with access is the access log, and the error log for the default virtual host without the word access.
Access logs are not generated by default and need to be configured in Server.xml.

The specific method is to add the following configuration to the <Host></Host> of the corresponding virtual host (if the domain name is 123.cn):

  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"       prefix="123.cn_access" suffix=".log"       pattern="%h %l %u %t &quot;%r&quot; %s %b" />

Prefix defines the prefix of the access log, suffix defines the suffix of the log, and the pattern defines the log format. The newly added virtual host does not generate the same localhost as the default virtual host by default. Date. log log, the error log is uniformly recorded in Catalina.out. About the Tomcat log, you need to focus on catalina.out, when there is a problem, we should first want to see it.

Operation Process

[[email protected] webapps]# ls/usr/local/tomcat/logs/catalina.2018-04-11.log host-manager.2018-04-11.log Localhost_access_log.2018-04-11.txtcatalina.out Localhost.2018-04-11.log Manager.2018-04-11.log[[email&nbs P;protected] webapps]# cd/usr/local/tomcat/logs/[[email protected] logs]# less catalina.out[[email  Protected] logs]# vim/usr/local/tomcat/conf/server.xml <valve classname= "Org.apache.catalina.valves.AccessLogV Alve "directory=" Logs "prefix=" 123.cn_access "suffix=". Log "pattern="%h%l%u%t &quot;%r& Amp;quot; %s%b "/>[[email protected] logs]#/usr/local/tomcat/bin/shutdown.sh[[email protected] logs]#/usr/  Local/tomcat/bin/startup.sh[[email protected] logs]# Ls123.cn_access.2018-04-11.log Host-manager.2018-04-11.log Logscatalina.2018-04-11.log Localhost.2018-04-11.log manager.2018-0 4-11.logcatalina.out Localhost_access_log.2018-04-11.txt

2018-05-15 Linux Learning

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.