1 Configuring Tomcat Listener port to 80
编辑tomcat配置文件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
2 Configuring the Tomcat virtual host
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.
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
下载zrlog wget http://dl.zrlog.com/release/zrlog-1.7.1-baaecb9-release.warmv 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浏览器访问 ip:8080/zrlog/install/ 创建数据库create database zrlog;grant all on zrlog.* to ‘zrlog‘@127.0.0.1 identified by ‘lvlinux‘;依照提示安装完zrlog,再次访问
Add a virtual host below
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 is actually under the AppBase directory, but in its subdirectory root.
Add virtual host, edit Server.xml, add below </Host> below
<Host name="www.123.cn" appBase="" unpackWARs= "true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="/data/wwwroot/123.cn/" debug="0" reloadable="true" crossContext="true"/></Host>
mv /usr/local/tomcat/webapps/zrlog/* /data/wwwroot/123.cn//usr/local/tomcat/bin/shutdown.sh/usr/local/tomcat/bin/startup.sh
Access www.123.cn in the browser
3 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 "%r" %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 logged catalina.out in. About the Tomcat log, you need to focus on catalina.out, when there is a problem, we should first want to see it.
Linux Learning Summary (50) Tomcat build Zrlog