Score:0

apache2ctl -S shows incorrect/unexpected DocumentRoot location

ru flag

I'm baffed by this fairly simple apache2 configuration. Given the following two configuration files, I expect the DocumentRoot to be /www/htdocs but instead, it's the apache default of /var/www/html. These are the configuration files with all the comment lines removed:

grep -v '^\s*#' /etc/apache2/apache2.conf|grep -v '^\s*$'

    DefaultRuntimeDir ${APACHE_RUN_DIR}
    PidFile ${APACHE_PID_FILE}
    Timeout 300
    KeepAlive On
    MaxKeepAliveRequests 100
    KeepAliveTimeout 5
    User ${APACHE_RUN_USER}
    Group ${APACHE_RUN_GROUP}
    HostnameLookups Off
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    IncludeOptional mods-enabled/*.load
    IncludeOptional mods-enabled/*.conf
    Include ports.conf
    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
    </Directory>
    <Directory /usr/share>
        AllowOverride None
        Require all granted
    </Directory>
    <Directory /www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
    AccessFileName .htaccess
    <FilesMatch "^\.ht">
        Require all denied
    </FilesMatch>
    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
    IncludeOptional conf-enabled/*.conf
    IncludeOptional sites-enabled/*.conf

grep -v '^\s*#' /etc/apache2/sites-enabled/000-default.conf|grep -v '^\s*$'

    <VirtualHost *:80>
        ServerName hpmicro1.lovelady.com
        ServerAdmin webmaster@localhost
        DocumentRoot /www/htdocs
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>

Here, I'll stop the apache service, do some cleanup and restart it (cleanup is to hopefully avoid confusion for those who cannot see this done)

    > sudo service apache2 stop
    > date '+%Y-%m-%d-%H:%M:%S'
    2021-07-19-09:47:52
    > > /var/log/apache2/error.log
    > service apache2 start
    > ls -l /var/log/apache2/error.log
    -rw-r----- 1 root adm 245 Jul 19 09:47 /var/log/apache2/error.log
    > ps -ef|grep apache2|grep www
    www-data  111420  111414  0 09:47 ?        00:00:00 /usr/sbin/apache2 -k start
    www-data  111421  111414  0 09:47 ?        00:00:00 /usr/sbin/apache2 -k start
    www-data  111422  111414  0 09:47 ?        00:00:00 /usr/sbin/apache2 -k start
    www-data  111423  111414  0 09:47 ?        00:00:00 /usr/sbin/apache2 -k start
    www-data  111424  111414  0 09:47 ?        00:00:00 /usr/sbin/apache2 -k start
    > cat /var/log/apache2/error.log
    [Mon Jul 19 09:47:53.833123 2021] [mpm_prefork:notice] [pid 111414] AH00163: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
    [Mon Jul 19 09:47:53.834328 2021] [core:notice] [pid 111414] AH00094: Command line: '/usr/sbin/apache2'

With all this done, here's what apache2 reports as the current configuration. As I said, the DocumentRoot is not what I expect. What might I be missing? The apache2ctl -S command identifies the very file that has the /www/htdocs DocumentRoot named. Hmmm....

    > apache2ctl -S
    VirtualHost configuration:
    *:80                   hpmicro1.lovelady.com (/etc/apache2/sites-enabled/000-default.conf:1)
    ServerRoot: "/etc/apache2"
    Main DocumentRoot: "/var/www/html"
    Main ErrorLog: "/var/log/apache2/error.log"
    Mutex watchdog-callback: using_defaults
    Mutex default: dir="/var/run/apache2/" mechanism=default 
    Mutex mpm-accept: using_defaults
    PidFile: "/var/run/apache2/apache2.pid"
    Define: DUMP_VHOSTS
    Define: DUMP_RUN_CFG
    User: name="www-data" id=33
    Group: name="www-data" id=33

In case there are questions about permissions, here's the pertinent ownership stuff about /www/htdocs...

    > ls -ld /www/htdocs
    drwxrwxr-x 5 www-data www-data 4096 Jul 18 22:58 /www/htdocs
    total 72
    > ls -l /www/htdocs
    -rw-rw-rw- 1 www-data www-data 35752 Jul 17 14:09 dbg-wizard.php
    drwxrwxr-x 2 www-data www-data  4096 Jul 16 08:15 functions
    drwxrwxr-x 2 www-data www-data  4096 Jul 17 12:38 GetChats
    -rw-r--r-- 1 www-data www-data 10918 Jul 18 16:16 index.html
    -rw-rw-rw- 1 www-data www-data    20 Jul 17 14:18 index.php
    drwxrwxrwx 2 www-data www-data  4096 Jun 29 13:32 logs
    -rw-rw-rw- 1 www-data www-data    67 Jul 17 14:18 php-love-info.php
    -rw-rw-rw- 1 www-data www-data    23 Jul 17 14:18 show-php-info.php

Thanks for any help

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.