Linux – DocumentRoot takes one argument, Root directory of the document tree error

apache-2.4documentrootlinux

Ok so I have this linux OS on my pc xubuntu and the external IP is not working via internal or external network, not working either on my pc. Just says 404 not found. What can I do?

this is the 000-default.conf, I also tried /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>

this is the error.log:

    [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

at systemctl status apache2 I get

        ● 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.

What other info do you need? I have to mention that there is an index.html in the /var/www/ directory!

Best Answer

The config you shared above appears to be a snippet from a larger conf, or an included file in the overall conf. If you have another conf somewhere that is the "default" vhost, you won't be able to browse that vhost without using the specified "ServerName" or "ServerAlias".

I suspect the vhost you defined is not the vhost apache is using to process the request.

By default, Apache will use the first vhost config that is read as the default, unless you define the _default_ vhost. With that in mind, this is 100% why I always create my vhosts with unique log files. It makes theses sorts of things much easier to debug.

For example:

<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>

and/or

<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>
Related Topic