httpd-2.2

http://httpd.apache.org/docs/2.2/logs.html

Log Rotation
日志轮替
On even a moderately busy server, the quantity of information stored in the log files is very large. The access log file typically grows 1 MB or more per 10,000 requests.
即使在一个适度繁忙的服务器上,存储在日志文件里的信息数量是非常大的。访问日志通常每10000次请求增长1M或更多。
It will consequently be necessary to periodically rotate the log files by moving or deleting the existing logs.
因此移动或删除已经存在的日志来周期性的轮替日志文件是很有必要的
This cannot be done while the server is running, because Apache will continue writing to the old log file as long as it holds the file open.
当server运行的时候不能轮替,因为只要apache保持文件打开就会继续写老的文件。
Instead, the server must be restarted after the log files are moved or deleted so that it will open new log files.
所以,server必须在日志文件移动或删除后重启以便server打开新的日志文件。
By using a graceful restart, the server can be instructed to open new log files without losing any existing or pending connections from clients.
使用一个优雅的重启,server能被指示打开新的日志文件而不用丢失任何来自客户端的已存在或试图访问的连接。

However, in order to accomplish this, the server must continue to write to the old log files while it finishes serving old requests.
然而,为了实现这个目标,server必须继续完成服务老的请求的同时写老的文件。
It is therefore necessary to wait for some time after the restart before doing any processing on the log files.
因些在重启之后,对日志文件做任何处理之前等待一些时间是必须的。
A typical scenario that simply rotates the logs and compresses the old logs to save space is:
简单地轮替日志并压缩老的日志来节约空间的一个典型的场景是:

mv access_log access_log.old
mv error_log error_log.old
apachectl graceful
sleep 600
gzip access_log.old error_log.old

Another way to perform log rotation is using piped logs as discussed in the next section.
另一种完成日志轮替的方法是在下一部分要讨论的管道日志。

Piped Logs
管道日志
Apache httpd is capable of writing error and access log files through a pipe to another process, rather than directly to a file.
apache httpd 有能为通过一个管道写错误与访问日志到另一个进程,而非直接至一个文件。
This capability dramatically increases the flexibility of logging, without adding code to the main server.
这个能力显著地增加了记录的灵活性,不用添加代码到主server。
In order to write logs to a pipe, simply replace the filename with the pipe character "|", followed by the name of the executable which should accept log entries on its standard input.
为了写日志给一个管道,简单地用管道符|替换文件名,跟随可执行程序名字,这个程序应该在它的标准输入上接受日志项。
Apache will start the piped-log process when the server starts, and will restart it if it crashes while the server is running. (This last feature is why we can refer to this technique as "reliable piped logging".)
当server启动时,apache将启动一个管道日志进程,并且服务器运行的同时,假如管道当机可以重启。(最后一个特性就是为什么我们能称这项技术为“可靠的管道日志”)
Piped log processes are spawned by the parent Apache httpd process, and inherit the userid of that process. This means that piped log programs usually run as root.
管道日志进程由httpd父进程派生,继承了父进程的uid。这意味着管道日志程序通常以root运行。
It is therefore very important to keep the programs simple and secure.
因此保持程序简单和安全是非常重要的。
One important use of piped logs is to allow log rotation without having to restart the server.
管道日志的一个重要用法是允许轮替而不用重启server。
The Apache HTTP Server includes a simple program called rotatelogs for this purpose. For example, to rotate the logs every 24 hours, you can use:
server包含一个简单的程序,叫做rotatelogs来达到这个目的。例如,每24小时轮替日志,你能使用:
CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/access_log 60" common 这个可能不能正常使用,所以用下面的那一条,加入下面的一条指令,然后访问页面,日志就会在一分钟后替换。

Notice that quotes are used to enclose the entire command that will be called for the pipe. Although these examples are for the access log, the same technique can be used for the error log.
注意双引号被用来封闭由管道调用的整个命令。尽管这个例子被用于访问日志,同样的技术也能用于error_log。
As with conditional logging, piped logs are a very powerful tool, but they should not be used where a simpler solution like off-line post-processing is available.

By default the piped log process is spawned using a shell. (usually with /bin/sh -c). Depending on the shell specifics invocation via shell might lead to an additional shell process for the lifetime of the logging pipe program and signal handling problems during restart.

Use "||" instead of "|" to spawn without invoking a shell:

# Invoke "rotatelogs" without using a shell
CustomLog "||/usr/local/apache/bin/rotatelogs /var/log/access_log 60" common

时间: 2024-10-03 05:26:02

httpd-2.2的相关文章

Nginx为什么比Apache Httpd高效:原理篇

一.进程.线程? 进程是具有一定独立功能的,在计算机中已经运行的程序的实体.在早期系统中(如linux 2.4以前),进程是基本运作单位,在支持线程的系统中(如windows,linux2.6)中,线程才是基本的运作单位,而进程只是线程的容器.程序 本身只是指令.数据及其组织形式的描述,进程才是程序(那些指令和数据)的真正运行实例.若干进程有可能与同一个程序相关系,且每个进程皆可以同步(循 序)或异步(平行)的方式独立运行.现代计算机系统可在同一段时间内以进程的形式将多个程序加载到存储器中,并借

centos7,监控httpd运行状态

#!/bin/bash # 获取运行状态 http=$(systemctl status httpd | grep Active | awk '{print $2}') # 判断运行状态 if [ "$http" != "active" ];then # 运行状态为失败时尝试重启并发出重启成功信息,如果运行失败发出失败警告! systemctl restart httpd && echo "httpd Restart successfull

Mac OS X取消Apache(httpd)开机启动

关闭http开机启动 sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 开机启动 sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

httpd搭建及知识点

http 的默认端口:80/tcphttps 的默认端口:443/tcp http协议的版本:    http/0.9    http/1.0    http/1.1    http/2.0 socket:BSD是 socket ipc的一种实现,允许在不同的主机上的进程之间相互通信的解决方式基于套接字有三中通信:    tcp套接字    udp套接字    裸套接字套件字的使用格式    ipv4    ipv6    unix sock 工作的模式: 一次完整http事务:请求 -- 响应

linux服务之http协议和httpd的配置(一)

http协议和httpd的配置 URL:Unifrom Resource Locator URL方案:scheme 服务器地址:ip:port 资源路径: http://www.magedu.com:80/bbs/index.php, https:// 基本语法: <scheme>://<user>:<password>@<host>:<port>/<path>;<params>?<query>#<fra

linux服务之http协议和httpd的配置(二)

httpd-2.2的常见配置(2) 14.curl命令 curl是基于URL语法在命令行方式下工作的文件传输工具,它支持FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE及LDAP等协议.curl支持HTTPS认证,并且支持HTTP的POST.PUT等方法, FTP上传, kerberos认证,HTTP上传,代理服务器, cookies, 用户名/密码认证, 下载文件断点续传,上载文件断点续传, http代理服务器管道( proxy tunnel

linux服务之http协议和httpd的配置(三)

httpd的基本应用(3) httpd-2.4: 新特性: (1) MPM支持运行为DSO机制:以模块形式按需加载: (2) event MPM生产环境可用: (3) 异步读写机制: (4) 支持每模块及每目录的单独日志级别定义: (5) 每请求相关的专用配置: (6) 增强版的表达式分析式: (7) 毫秒级持久连接时长定义: (8) 基于FQDN的虚拟主机也不再需要NameVirutalHost指令: (9) 新指令,AllowOverrideList: (10) 支持用户自定义变量: (11

Centos7 httpd+openssl+ssh登录实现过程(爱你就给你写详细点)

上篇已经讲了LAMP的yum简易搭建 http://rexchow.blog.51cto.com/11619161/1885533 我们针对这套服务延伸openssl功能 原理就不多说了,谷X百X去 环境说明: server:CentOS7-192.168.230.202 client: win8.1-192.168.230.59 Apache/2.4.6 php Version 5.4.16 5.5.52-MariaDB 新增签发服务器:192.168.230.204 需要安装openssl

lvs DR模式 +keepalived 实现directory 高可用、httpd服务负载均衡集群

功能: lvs+keepalived高可用负载均衡集群中: ·keepalived负责后端real server健康状态检查 如果一台real server服务出现故障,则会从集群服务中剔除,等恢复之后再自动加入到集群. ·keepalived负责负载均衡器(directory server)高可用 A和B两台虚拟机装lvs+keepalived(主)和lvs+keepalived(备),但是对外表现为一个虚拟IP,主服务器会发送消息给备服务器,当备服务器收不到消息的时候,认为主出现故障,然后接

linux httpd安装

2. 解压缩# tar zxf httpd-2.2.4.tar.gz# cd httpd-2.2.4 3. 安装apache依赖包apr和apr-util,他们都在srclib目录中 3.1 安装apr# cd srclib/apr# ./configure --prefix=/usr/local/apr# make# make install 3.2 安装apr-util# cd ../apr-util# ./configure --prefix=/usr/local/apr-util --w