Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand tomcat logs and FTP

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces you to the tomcat log and FTP, the content is very detailed, interested friends can refer to, hope to be helpful to you.

1) host-manager (manage virtual hosts)

This function is mainly used to manage virtual hosts, and you can stop, start and add virtual hosts through this WEB interface. The first step is to configure user roles:

# vim conf/tomcat-user.xml / / changing or adding admin-gui and admin-script here are two built-in roles in Tomcat, and the host-manager function requires the support of these two roles. Admin-gui is used to control page access, and admin-script is used to control access to host-manager in the form of simple text. At this time, you can access the host management interface by typing http://ip:8080/host-manager/ in the browser, but there is still a problem at this time. This is because Tomcat also has a secure setting. By default, the client IP is not allowed to access the host-manager page. The solution is to modify the configuration file: # vim webapps/host-manager/META-INF/context.xml / / add whitelist IP to the allow line. If it is a network segment, it is indicated by *. For example, 192.168.100.roomallow1 = "127\.\ d+\.\ d+\.\ d+ |:: 1 | 0-0-0-0-0-8-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-1; 192\ .168\ .190. *"

We can add, stop and start virtual hosts through this WEB interface, which is very convenient. With the addition of virtualhost, a directory will be generated under the conf/Catalina/ directory, and the directory will exist permanently, but the virtualhost will disappear after restarting the service, and it can be permanently saved to server.xml, but it needs to be added in server.xml, as follows

If 403 appears, add new roles: admin-gui, admin-script

2) Manager (deployment)

In fact, in the host-manager interface, clicking the "Server Status" button on the right will take you to the Manager interface. To access successfully, you also need to configure tomcat-user.xml and webapps/manager/META-INF/context.xml configuration files:

# vim conf/tomcat-user.xml / / change or add

Manager-gui is used to control the access of manager pages, manager-script is used to control access in the form of simple text, manager,manager-jmx is used to control jmx access, and manager-status is used to control the view of server status. Then edit webapps/manager/META-INF/context.xml:

# vim webapps/manager/META-INF/context.xml / / add whitelist IP to the allow line. If it is a network segment, it is indicated by *, for example, 192.168.100.network allowable = "127\.\ d +\.\ d +\.\ d + |: 1 | 0VOV0VOVOVOVUL0VUL1 | 192.168.190"

After completing the above two steps, you can access the manager interface through http://ip:8080/manager/.

Tomcat's log:

The Tomcat log is in the / usr/local/tomcat/logs/ directory, and there are probably several types of files: catalina.out, catalina.xxxx-xx-xx.log, host-manager.xxxx-xx-xx.log, manager.xxxx-xx-xx.log, localhost.xxxx-xx-xx.log, xxx_access_log.xxxx-xx-xx.txt. Wow, why so much? Which one should we check if we have a problem?

Just remember that if you encounter a problem, check catalina.out. This log is the core log, no matter the correct information or the wrong information, whether it is the tomcat service itself or the application that tomcat runs (such as zrlog). The two manager logs are related to the management desk, so don't pay attention to them. While access_log is the access log, recording the client's access to the website, this log can not be recorded by it, but recorded on the front-end Nginx agent, so there is no need to pay attention to it. This dated catalina.xxxx-xx-xx.log is the log related to the catalina engine, which can be thought of as the log of the tomcat service itself. In fact, there is no need to worry about this, because it is duplicated with catalina.out, that is, the information recorded in this is in the catalina.out. There is also a localhost.xxxx-xx-xx.log, which is mainly the log that the unhandled exception of the application initialization (listener, filter, servlet) is caught by tomcat and output, in fact, you don't have to pay much attention to it.

Log configuration file conf/logging.properties, which mainly defines some attributes of non-access logs, such as log path, which logs are recorded to which files (names), log level, storage cycle and other information. We generally do not change this configuration file, just keep it by default. The format and path of the access log are defined in server.xml. The following is the configuration segment of the access log:

`

`

If you are careful, you may find that the catalina.out file does not have a date suffix, which means that the file will not be cut automatically, it will get bigger and bigger. There are two ways to solve this problem:

1) clear the file at regular intervals, such as adding a scheduled task

`

0 * / 5 * * echo "" > / usr/local/tomcat/logs/catalina.out

`

2) cut with the logrotate tool that comes with the system

`

# vim / etc/logrotate.d/tomcat / / write the following

/ usr/local/tomcat/logs/catalina.out {

Copytruncate # truncate the source catalina.out file after creating a new copy of catalina.out

Daily # rotate catalina.out files every day

Rotate 7 # keep up to 7 copies

Missingok # if the file to be rotated is lost, continue to rotate without reporting an error

Compress # uses compression (saves hard disk space)

Size 16m # rotate when the catalina.out file is larger than 16MB

}

FTP Service:

File transfer protocol, you can upload and download files. For example, we can upload files from Windows to Linux. You can also put the files on the Linux

Download it to windows. Of course, the reverse is possible, because FTP can also be installed on Windows.

There is a vsftpd by default on CentOS

Install pure-ftpd under Linux

Yum install-y epel-release

Yum install-y pure-ftpd

Configure pure-ftpd

Vi / etc/pure-ftpd/pure-ftpd.conf

PureDB / etc/pure-ftpd/pureftpd.pdb

MinUID 1000

Useradd ftpuser

Mkdir / data/ftp

Chown ftpuser:ftpuser / data/ftp

Pure-pw useradd user1-u ftpuser-d / data/ftp

Pure-pw mkdb

Pure-pw list

Systemctl start pure-ftpd

Firewall-cmd-add-port=21/tcp-permanent

Firewall-cmd-reload

Test:

Yum install-y lftp

Lftp user1@127.0.0.1

Win Test:

Download filezilla client https://filezilla-project.org/download.php?type=client

Installation

SFTP

Take the port 22 of ssh

Common software that supports SFTP: filezilla xftp

This is the end of the tomcat log and FTP sharing. I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report