Apache 中的错误日志和自定义日志限制

Apache 中的错误日志和自定义日志限制

我使用的服务器版本:Apache/2.4.6 (CentOS)

我已经编写了如下的域配置

<virtualhost *:80>
ServerName xxx.com
ServerAlias  www.xxx.com
ServerAdmin [email protected]
DocumentRoot "/var/sentora/hostdata/saravana/public_html/"
ErrorLog "/var/logs/domains/xxx.com-error.log"
CustomLog "/var/logs/domains/xxx.com-access.log" combined
CustomLog "/var/logs/domains/xxx.com-bandwidth.log" common
<Directory "/var/www/xxx/public_html/">
  Options +FollowSymLinks -Indexes
  AllowOverride All
    Require all granted
</Directory>
AddType application/x-httpd-php .php3 .php
ErrorDocument 510 /_errorpages/510.html
ErrorDocument 403 /_errorpages/403.html
ErrorDocument 404 /_errorpages/404.html
ErrorDocument 500 /_errorpages/500.html
DirectoryIndex index.html index.htm index.php index.asp index.aspx index.jsp index.jspa index.shtml index.shtm
# Custom Global Settings (if any exist)

# Custom VH settings (if any exist)

</virtualhost>

如果我配置了更多域,那么 apache 就不会重新启动。 如果我已经评论了ErrorLog和CustomLog,那么Apache就已成功重启。 ErrorLog 和 CustomLog 数量是否有限制?我需要创建 1000 个具有类似配置的域。请告诉我这个问题的解决方案?

答案1

通常,您会为 Apache httpd 设置一个常规错误日志来记录启动错误,然后为每个特定的虚拟主机设置特定的日志文件:

# httpd.conf
# This is the main Apache server configuration file.
...
ErrorLog "/var/log/httpd/error_log"
...
<VirtualHost *:80>
   ServerName example.com
   ErrorLog "/var/logs/domains/example.com-error.log"
   ...
</VirtualHost>
<VirtualHost *:80>
   ServerName example.net
   ErrorLog "/var/logs/domains/example.net-error.log"
   ...
</VirtualHost>

日志文件的目录必须存在,并且任何现有的日志文件和目录对于 Apache httpd 启动用户都应该是可写的。

首先检查您的版本是否/var/log/httpd/error_log存在启动错误和/或消息。


问题在于,您的配置中每个域都包含三个不同的日志文件:

ErrorLog "/var/logs/domains/xxx.com-error.log"
CustomLog "/var/logs/domains/xxx.com-access.log" combined
CustomLog "/var/logs/domains/xxx.com-bandwidth.log" common

(尤其是与prefork MPM) 就是它每个 httpd 进程需要打开1000 x 3 = 3000文件才能收集日志。例如,使用非常适中的文件StartServers 10意味着3万打开文件描述符只是为了开始Apache 如果您有一些实际的访问者,那么甚至更多!

相关内容