apache 错误日志 debian 中的“无法打开日志”

apache 错误日志 debian 中的“无法打开日志”

[已解决] 更高的文件描述符限制解决了该问题

APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'

我无法启动 apache2 服务:

[root@myhost ~]# service apache2 start
[....] Starting web server: apache2[Thu May 22 00:32:41 2014] [warn] NameVirtualHost *:443 has no VirtualHosts
Action 'start' failed.
The Apache error log may have more information.
 failed!
[root@myhost ~]#

/var/log/apache2/error.log

[root@myhost ~]# tail -200 /var/log/apache2/error.log

(...)
Unable to open logs
Unable to open logs
Unable to open logs
Unable to open logs
Unable to open logs
Unable to open logs
Unable to open logs
Unable to open logs
[root@myhost ~]#

权限:

[root@myhost /var/log/apache2]# ls -l
total 14892
-rw-r----- 1 root adm        379215 May 21 23:34 access.log
-rw-r----- 1 root adm       1583118 May 18 07:35 access.log.1
-rwxrwxrwx 1 root root          163 May 22 00:32 error.log
-rw-r----- 1 root adm      13096039 May 18 07:35 error.log.1
-rw-r----- 1 root adm          3423 May 21 22:27 other_vhosts_access.log
-rw-r--r-- 1 root root       153149 May 18 04:46 other_vhosts_access.log.1
-rw-r----- 1 root adm             0 May 18 07:35 suexec.log
-rw-r--r-- 1 root www-data     1620 May 16 13:08 suexec.log.1
[root@myhost /var/log/apache2]#

/etc/apache2/环境变量

# envvars - default environment variables for apache2ctl

# this won't be correct after changing uid
unset HOME

# for supporting multiple apache2 instances
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
        SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
        SUFFIX=
fi

# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
#. /etc/default/locale

export LANG

## The command to get the status for 'apache2ctl status'.
## Some packages providing 'www-browser' need '--dump' instead of '-dump'.
#export APACHE_LYNX='www-browser -dump'

## If you need a higher file descriptor limit, uncomment and adjust the
## following line (default is 8192):
#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'


## If you would like to pass arguments to the web server, add them below
## to the APACHE_ARGUMENTS environment.
#export APACHE_ARGUMENTS=''

有任何想法吗?

谢谢

答案1

/etc/apache2/envvars 中更高的文件描述符限制解决了该问题

APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'

答案2

今天在 Apache/2.4.52 中遇到了同样的问题,通过取消注释 /etc/apache2/apache2.conf 中的 include ports.conf 解决了该问题:

sed -i 's/#Include ports.conf/Include ports.conf/g' /etc/apache2/apache2.conf
service apache2 restart

相关内容