Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 426
baao Avatar asked Jan 09 '23 08:01

baao


2 Answers

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
like image 70
GM-Script-Writer-62850 Avatar answered Jan 11 '23 23:01

GM-Script-Writer-62850


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.

like image 25
Dan Walmsley Avatar answered Jan 11 '23 21:01

Dan Walmsley