我在 Ubuntu 18 上安装了 Apache。配置文件 /etc/apache2/apache2.conf 不包含 DocumentRoot 指令。但是有/etc/apache2/sites-enabled/000-默认它将 DocumentRoot 定义为 /var/www/html。目录 /var/www/html 包含具有简单内容的 index.php 文件。<? phpinfo() ?>
但如果我尝试从浏览器调用服务器 IP,例如http://40.69.5.143/它没有显示 www/html/index.php 但是它打开 /var/www/html 中的第一个目录及其 index.php。我不明白为什么它忽略了 000-default 配置文件。000-default 看起来像:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>