baao
baao

Reputation: 73241

Apache ignores Document root

I have the following VirtualHost file:

 <VirtualHost *:80>

        ServerName www.domain.com
        ServerAlias domain.com

        ServerAdmin [email protected]
        DocumentRoot /var/www/html/xxx/public

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


</VirtualHost>

Apache seems to ignore my Document Root and shows me instead a file which is located in the

/var/www/html

directory. Is there anything I need to change in order to get this running?

Upvotes: 7

Views: 3808

Answers (2)

GM-Script-Writer-62850
GM-Script-Writer-62850

Reputation: 373

After spending over 30 min trying to figure out why stuff was being ignored it seems apache2.4 ignores your sites-enabled configs if they do not end in .conf for example:

Wrong:

ls /etc/apache2/sites-enabled/
001-owncloud  002-owncloud-ssl  003-ram

Correct:

ls /etc/apache2/sites-enabled/
001-owncloud.conf  002-owncloud-ssl.conf  003-ram.conf

Upvotes: 5

Dan Walmsley
Dan Walmsley

Reputation: 2821

Are you sure that this is the only virtual host that is on port 80. I suspect that another place will be overriding this.

Also there is no directive for the directory, so you may get permission issues when you do get it working.

Often I find other virtual hosts hiding in things like apache.conf.

Also you know that there are two places for the site files right? sites-available and sites-enabled. If it's not in sites-enabled it will do nothing. Use sudo a2ensite siteName to create a simlink to the file in sites-enabled.

Also if you are on Apache 2.4 the files will need to end in .conf to be picked up. Things changed a bit from 2.2 to 2.4.

Upvotes: 4

Related Questions