Apache2 [SOLVED]: Virtual Host Displays Two out of Three Sites

Apache2 [SOLVED]: Virtual Host Displays Two out of Three Sites

Home Forums Apache2 Apache2 [SOLVED]: Virtual Host Displays Two out of Three Sites

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #36897

    Anonymous

    QuestionQuestion

    I have setup apache2 to use three domains. They are pointed correctly and I have setup the sites-available config files as the following:

    Here is hfd-server.domain1.com, this one displays the default APACHE2 success page. However, it works with http://www.hfd-server.domain1.com. Don’t understand.

    <VirtualHost *:80>
            ServerAdmin email@domain1.com
            ServerName www.hfd-server.domain1.com
            DocumentRoot /var/www/hfd-server.domain1.com/public_html
            ServerAlias hfd-server.domain1.com
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
            #Other Directives Here
            <Directory /var/www/hfd-server.domain1.com/public_html>
                    Options -Indexes +FollowSymLinks +MultiViews
                    AllowOverride All
                    Require all granted
            </Directory>
    </VirtualHost>
    

    Here are the other two working config files:

    house.domain1.com

    <VirtualHost *:80>
            ServerAdmin email@domain1.com
            ServerName www.house.domain1.com
            DocumentRoot /var/www/house-server.domain1.com/public_html
            ServerAlias house.domain1.com
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
            #Other Directives Here
            <Directory /var/www/house.domain1.com/public_html>
                    Options -Indexes +FollowSymLinks +MultiViews
                    AllowOverride All
                    Require all granted
            </Directory>
    </VirtualHost>
    

    house.domain2.com

    <VirtualHost *:80>
            ServerAdmin email@domain1.com
            ServerName www.house.domain2.com
            DocumentRoot /var/www/house.domain2.com/public_html
            ServerAlias house.domain2.com
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
            #Other Directives Here
            <Directory /var/www/house.domain2.com/public_html>
                    Options -Indexes +FollowSymLinks +MultiViews
                    AllowOverride All
                    Require all granted
            </Directory>
    </VirtualHost>
    

    The access log and error log shows nothing out of the ordinary. Not sure why one would work but not the other one.

    I didn’t modify 000-default.conf. I was afraid to, so I made copies and just enabled them.

    Is there anything else I can try, HFD-SERVER.domain1.com is linked to a control panel that I would like to have access.

    UPDATE 12-28-17

    I used sudo apachectl -t -D DUMP_VHOSTS and this is what it listed.

    VirtualHost configuration: *:80  is a NameVirtualHost
    default server HFD-SERVER.domain1.us (/etc/apache2/sites-enabled/000-default.conf:1)
    port 80 namevhost hfd-server.domain1.us (/etc/apache2/sites-enabled/000-default.conf:1)
    port 80 namevhost www.hfd-server.domain1.us (/etc/apache2/sites-enabled/hfd-server.domain1.us.conf:1) alias hfd-server.domain1.us
    port 80 namevhost house.domain1.us (/etc/apache2/sites-enabled/house.domain1.us.conf:1) alias www.house.domain1.us
    port 80 namevhost house.domain2.us (/etc/apache2/sites-enabled/house.domain2.us.conf:1) alias www.house.domain2.us
    

    Appears that the default server is 000-default.conf. Is there a way to make the hfd-domain1.us.conf the default server?

    #36898

    Anonymous

    Accepted AnswerAnswer

    You can solve this in a few different ways

    Change the 000-default.conf replace the relevant lines to match the hfd-domain1.us.conf and deleting the hfd-domain1.us.conf in /etc/apache2/sites-enabled then it would be the “000-default.conf” that points to the proper hdf-domain1.us with the proper folder structure and the other two would be show up as they did in the dump.

    another way would be to change the 000-default.conf and change the ServerName and ServerAlias entries to something different so they dont have the same name as in hfd-domain1.us.conf and then you would have a default site pointing to these new settings .. and the 3 virtual ones you created.

    and the last way is to go to the /etc/apache2/sites-enabled/ directory and remove or rename the shortcut to 000-default.conf changing the extension to 000-default.conf~

    Updated:
    this was pointed out that it doesn’t seem to allow you just to remove the file so I updated this answer with the information by the original poster the best way for this would be to run sudo a2dissite 000-deafult.conf to remove the 000-default.conf thus leaving the 3 virtual hosts enabled and should function as you want.

    Source: https://askubuntu.com/questions/990092/virtual-host-displays-two-out-of-three-sites
    Author: John Orion
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.