我一直在 Raspberry Pi 上使用 Apache2 和 Webmin。重启并重新安装后,Apache 无法启动。
> sudo /etc/init.d/apache2 restart
apache2: Syntax error on line 268 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/sites-enabled/000-default: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.
failed!
那里有文件 000-default,并且 root-root 无法打开权限。我的 apache2.conf 文件如下所示(下半部分):
# 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 ${APACHE_LOG_DIR}/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 debug
# Include module configuration:
Include mods-enabled/*.load
Include mods-enabled/*.conf
# Include list of ports to listen on and which to use for name based vhosts
Include ports.conf
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# Include of directories ignores editors' and dpkg's backup files,
# see the comments above for details.
# Include generic snippets of statements
Include conf.d/
# Include the virtual host configurations:
Include sites-enabled/
<VirtualHost *:80>
DocumentRoot /var/www
<Directory /var/www>
allow from all
Options +Indexes
</Directory>
ServerName IMASERVER
</VirtualHost>
有人知道这是什么原因造成的吗?
答案1
首先,在配置文件中使用 VirtualHost 是一个糟糕的举动,(我甚至不确定这是否可行)sites-enabled 的整个想法是将 VirtualHost 放在该文件夹中的不同文件中,然后简单地使用
a2ensite default
a2dissite 000-default
话虽如此,您可以尝试从配置文件中删除 VirtualHost 块,并在 sites-enabled 中创建(或编辑)默认文件。请确保重新启动 apache。
我认为您发布的文件是/<some-dir>/apache2/apache2.conf
但是,您上面发布的文件看起来与我见过的 apache 配置文件完全不同。这一点上我无法帮助您。