Linux
在 Centos 7 上更改 Apache 2.4.x 的日誌文件目錄
目前我的日誌文件在 `/var/log/httpd/ 下可用。由於我的根分區數量有限,因此日誌超出了限制並導致系統卡住。
我想將 apache 日誌目錄更改為另一個已安裝的捲。
我沒有更改並在配置文件中找到有關日誌文件目錄的任何內容,將
/var/log/http/*
目錄更改為的最簡單方法是什麼/someRandomVolume/httpLogFolder/*
這就是我關於登錄配置文件的內容;
# # ErrorLog: The location of the error log file. # If you do not specify an ErrorLog directive within a <VirtualHost> # container, error messages relating to that virtual host will be # logged here. If you *do* define an error logfile for a <VirtualHost> # container, that host's errors will be logged there and not here. # ErrorLog "logs/error_log" # # LogLevel: Control the number of messages logged to the error_log. # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. # LogLevel warn <IfModule log_config_module> # # The following directives define some format nicknames for use with # a CustomLog directive (see below). # LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> # You need to enable mod_logio.c to use %I and %O LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> # # The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a <VirtualHost> # container, they will be logged here. Contrariwise, if you *do* # define per-<VirtualHost> access logfiles, transactions will be # logged therein and *not* in this file. # #CustomLog "logs/access_log" common # # If you prefer a logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive. # CustomLog "logs/access_log" combined </IfModule>
在 RHEL/CentOS 上,日誌文件的預設位置是相對於
ServerRoot
基本目錄的,通常是從to/etc/httpd/
的符號連結。/etc/httpd/logs``/var/log/httpd
如果您想使用不同的目錄,只需移動
/var/log/httpd
並更新該符號連結。或者,正如@TomTomTom 建議的那樣,在
CustomLog
andErrorLog
指令中使用絕對路徑。如果您啟用了 SELinux,請確保為該新目錄設置/保留正確的上下文。