Apache doesn't use DocumentRoot after upgradin

2020-07-05 06:05发布

I have various virtual hosts for my web development work, including cnm. The

sites-available/cnm

my file says very simply:

<VirtualHost *:80>
    ServerName cnm
    DocumentRoot /var/www/cnm/public_html
</VirtualHost>

I upgraded to Ubuntu 13.10, and when I point my browser to cnm/, I see the /var/www/index.html file that seems to be indicated in the default file

sites-available/000-default.conf

which says (among other things):

<VirtualHost *:80>
    DocumentRoot /var/www

What do I need to do to get Apache to read my cnm document root when I browse to cnm/ ?

NOTES:

  1. I already tried renaming my sites-available/cnm file to sites-available/cnm.conf and enabling it with a2ensite cnm and service apache2 reload. That is a good thing, but it changes nothing.

  2. I already tried changing <VirtualHost *:80> to <VirtualHost cnm.localhost> or to <VirtualHost cnm>. That did nothing.

7条回答
祖国的老花朵
2楼-- · 2020-07-05 06:47

I found the answer to this issue:

When upgrading to Ubuntu 13.10, the DocumentRoot does not seem to make a difference.

This is because Apache 2.4 moved the Directory configuration somewhere else. Your old .conf files still have these lines:

    DocumentRoot "/var/www/myVhost"
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory "/var/www/myVhost">
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

Remove (or comment out) the <Directory> directives so you only have:

    DocumentRoot "/var/www/myVhost"

Now reload your settings: service apache2 reload and DocumentRoot is back. :)

查看更多
登录 后发表回答