DocumentRoot 接受一个参数,文档树的根目录错误

DocumentRoot 接受一个参数,文档树的根目录错误

好的,我的电脑上安装了 xubuntu 这个 Linux 操作系统,外部 IP 无法通过内部或外部网络工作,在我的电脑上也不起作用。只是显示 404 未找到。我该怎么办?

这是 000-default.conf,我也尝试了 /var/www/html:

<VirtualHost *:80>
Servername <redacted>
ServerAdmin webmaster@localhost
DocumentRoot "/var/www"            # try quoting
DirectoryIndex index.html               # just in case
ErrorLog /var/log/apache2/error.log        # fully specified
CustomLog /var/log/apache2/acces.log      # fully specified
<Directory "/var/www">             # quoted
    AllowOverride All
    Require all granted                 # required in Apache 2.4
</Directory>

这是错误日志:

    [Mon Apr 09 17:00:10.218418 2018] [mpm_event:notice] [pid 19936:tid 139990600419200] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
    [Mon Apr 09 17:00:10.218550 2018] [core:notice] [pid 19936:tid 139990600419200] AH00094: Command line: '/usr/sbin/apache2'
    [Mon Apr 09 17:08:21.130698 2018] [mpm_event:notice] [pid 19936:tid 139990600419200] AH00491: caught SIGTERM, shutting down
    [Mon Apr 09 17:08:22.235195 2018] [mpm_event:notice] [pid 20519:tid 139868456769408] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
    [Mon Apr 09 17:08:22.235323 2018] [core:notice] [pid 20519:tid 139868456769408] AH00094: Command line: '/usr/sbin/apache2'
    [Mon Apr 09 17:10:02.485055 2018] [mpm_event:notice] [pid 20519:tid 139868456769408] AH00491: caught SIGTERM, shutting down
    [Mon Apr 09 17:12:24.738049 2018] [mpm_event:notice] [pid 1729:tid 140330444584832] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
    [Mon Apr 09 17:12:24.794357 2018] [core:notice] [pid 1729:tid 140330444584832] AH00094: Command line: '/usr/sbin/apache2'
    [Mon Apr 09 17:25:02.357488 2018] [mpm_event:notice] [pid 1729:tid 140330444584832] AH00491: caught SIGTERM, shutting down
    [Mon Apr 09 17:25:03.449348 2018] [mpm_event:notice] [pid 3730:tid 140047470462848] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
    [Mon Apr 09 17:25:03.449459 2018] [core:notice] [pid 3730:tid 140047470462848] AH00094: Command line: '/usr/sbin/apache2'
    [Mon Apr 09 17:50:02.495314 2018] [mpm_event:notice] [pid 3730:tid 140047470462848] AH00493: SIGUSR1 received.  Doing graceful restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
    [Mon Apr 09 17:50:02.500105 2018] [mpm_event:notice] [pid 3730:tid 140047470462848] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
    [Mon Apr 09 17:50:02.500112 2018] [core:notice] [pid 3730:tid 140047470462848] AH00094: Command line: '/usr/sbin/apache2'
    [Mon Apr 09 18:03:51.249126 2018] [mpm_event:notice] [pid 3730:tid 140047470462848] AH00491: caught SIGTERM, shutting down
    [Mon Apr 09 18:03:52.335467 2018] [mpm_event:notice] [pid 4815:tid 140214087751552] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
    [Mon Apr 09 18:03:52.335607 2018] [core:notice] [pid 4815:tid 140214087751552] AH00094: Command line: '/usr/sbin/apache2'
    [Mon Apr 09 18:03:59.131805 2018] [mpm_event:notice] [pid 4815:tid 140214087751552] AH00491: caught SIGTERM, shutting down
    [Mon Apr 09 18:04:00.216384 2018] [mpm_event:notice] [pid 4918:tid 140288963467136] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
    [Mon Apr 09 18:04:00.216562 2018] [core:notice] [pid 4918:tid 140288963467136] AH00094: Command line: '/usr/sbin/apache2'
    [Mon Apr 09 18:23:59.494573 2018] [mpm_event:notice] [pid 4918:tid 140288963467136] AH00491: caught SIGTERM, shutting down
    [Mon Apr 09 18:24:00.582049 2018] [mpm_event:notice] [pid 5302:tid 140040924424064] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
    [Mon Apr 09 18:24:00.582221 2018] [core:notice] [pid 5302:tid 140040924424064] AH00094: Command line: '/usr/sbin/apache2'
    [Mon Apr 09 18:39:00.113290 2018] [mpm_event:notice] [pid 5302:tid 140040924424064] AH00491: caught SIGTERM, shutting down

在 systemctl status apache2 我得到

        ● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) since ma 2018-04-09 19:30:35 EEST; 6min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1509 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/apache2.service
           ├─1672 /usr/sbin/apache2 -k start
           ├─1675 /usr/sbin/apache2 -k start
           └─1676 /usr/sbin/apache2 -k start

huhti 09 19:30:33 ossasecurity-desktop systemd[1]: Starting LSB: Apache2 web server...
huhti 09 19:30:33 ossasecurity-desktop apache2[1509]:  * Starting Apache httpd web server apache2
huhti 09 19:30:34 ossasecurity-desktop apache2[1509]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
huhti 09 19:30:35 ossasecurity-desktop apache2[1509]:  *
huhti 09 19:30:35 ossasecurity-desktop systemd[1]: Started LSB: Apache2 web server.

您还需要什么其他信息?我必须提到 /var/www/ 目录中有一个 index.html!

答案1

您在上面分享的配置似乎是来自更大 conf 的一个片段,或者是整个 conf 中的一个包含文件。如果您在某个地方有另一个 conf 作为“默认”虚拟主机,那么如果不使用指定的“ServerName”或“ServerAlias”,您将无法浏览该虚拟主机。

我怀疑您定义的 vhost 不是 apache 用来处理请求的 vhost。

默认情况下,Apache 将使用读取的第一个 vhost 配置作为默认值,除非您定义 vhost _default_。考虑到这一点,这就是我始终使用唯一日志文件创建 vhost 的 100% 原因。它使这些事情更容易调试。

例如:

<VirtualHost _default_:80>
  DocumentRoot /blah/blah
  DirectoryIndex index.html
  ErrorLog ${APACHE_LOG_DIR}/default.error.log
  LogLevel warn
  CustomLog ${APACHE_LOG_DIR}/default.access.log combined
</VirtualHost>

和/或

<VirtualHost *:80>
  DocumentRoot /blah/blah
  ServerName blah.blah.blah
  DirectoryIndex index.html
  ErrorLog ${APACHE_LOG_DIR}/blah.blah.blah.error.log
  LogLevel warn
  CustomLog ${APACHE_LOG_DIR}/blah.blah.blah.access.log combined
</VirtualHost>

相关内容