Web website services (1) continued

  1. 3. View web site visits

  1. The httpd server uses two types of logs, access logs and error logs. The names of these two logs are access_log and error_log respectively, both of which are located in the /usr/local/httpd/logs directory.

  1. By accessing log files, you can understand the access status of the web site in a timely manner. Each line in the access log corresponds to an access record, which records the client's IP address, the date and time of access to the server, the requested web page object, and other information.

  1. The error log file error_log can provide a reference for troubleshooting server operation failures.

  1. Each line of the error log file corresponds to an error record, which records the date and time when the error was released, the error event type, and the error event content description.

  1. 1.2.2.httpd.conf configuration file

  1. If you want to configure the Web site more specifically and powerfully, it is not enough to just learn to participate in the "servername" configuration item. You must also be familiar with the httpd.conf configuration file.

  1. The main configuration file httpd.conf consists of a comment line and a setting line. Like most configuration files, it is commented with "#". Except for comment lines and blank lines, they are all configuration lines, which constitute the effective configuration of the web service. Depending on the scope of the configuration items, the setting row can be divided into global configuration and regional configuration.

  1. 1. Global configuration

  1. The global configuration determines the global operating parameters of the httpd server, using the "keyword value" configuration format.

  1. Each configuration item is an independent configuration and does not need to be included in other task areas. Here is a list of commonly used global configuration items in httpd.conf

  1. The meaning of each configuration item is as follows:

  1. ServerRoot: Set the root directory of each server. This directory includes subdirectories and files necessary to run the web site. By default, the root directory of the httpd server is the httpd installation directory.

  1. Listen: Set the port number that the httpd server listens to, the default is 80

  1. User: Set the user identity for running the httpd process. The default is daemon.

  1. Group: Set the group identity when running the httpd process. The default is daemon.

  1. ServerAdmin: Set the administrator email address of the httpd server. You can contact the administrator of the website through the email address in a timely manner.

  1. ServerName: Set the complete host name of the web site (host name + domain name)

  1. DocumentRoot:设置网站根目录,即网页文档在系统中的实际存放路径

  1. Directoryindex:设置网站的默认索引页,可以设置多个首页文件,以空格分开,默认首页文件为index.html

  1. ErrorLog:设置错误日志文件的路径,默认路径为logs/error_log

  1. LogLevel:设置记录日志的级别,默认级别为warn(警告)

  1. CustomLog:设置访问日志文件的路径,日志类型,默认路径为logs/access_log,类型为common(通用格式)

  1. PidFile:设置用于保存httpd进程号(PID)的文件,默认地址为logs/httpd.pid,log目录位于Apache的服务器根目录下

  1. AddDefaultCharset:设置站点中的网页默认使用的字符集编码,如:utf-8,gd2312

  1. Include:包含另一个配置文件的内容,可以实现将一些特殊功能的配置放到一个单独的文件中,在使用Include配置项将其包含到http.conf文件中,这样便于独立进行配置功能的维护而不影响主配置文件

  1. 以上时httpd.conf中重要的全局配置项。还有很多配置项,需要使用可以查看Apache服务器中的相关帮助手册

  1. 2.区域配置项

  1. 除全局配置项外,httpd.conf文件中的大多数配置项时包括在区域中的。区域配置使用一对组合标记,限定了配置项的作用范围。

  1. 以上区域中,设置了一个根目录的区域配置,其中添加的访问控制相对配置支队根目录有效,而不会作用于全局或其他目录区域。

  1. *注意:这里说的根目录时指设置httpd服务的根目录,而不是centos系统的根目录

Guess you like

Origin blog.csdn.net/m0_65487180/article/details/129731218