LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache2 - disable default virtual hosts problem (http://www.linuxquestions.org/questions/linux-server-73/apache2-disable-default-virtual-hosts-problem-4175422358/)

mcc28 08-16-2012 04:14 AM

Apache2 - disable default virtual hosts problem
 
Hi,

I have created 3 virtual hosts e.g. /etc/apache2/sites-available/mynewsite and used a2ensite and restarted apache. I can browse to the site no problem.

I want to disable the default site /etc/apache2/sites-available/default but when I issue a2dissite default and restart apache none of the virtual hosts can be accessed either?

How do I do this?

cheers


Mark

bathory 08-16-2012 07:04 AM

Hi,

I guess there is a
Code:

NameVirtualHost *
in /etc/apache2/sites-available/default, that there not exists in your vhosts files, that's why vhosts are not working
If you're sure you want to disable the default vhos, move the above directive into apache2.conf

Regards

mcc28 08-16-2012 09:29 AM

Quote:

Originally Posted by bathory (Post 4755471)
Hi,

I guess there is a
Code:

NameVirtualHost *
in /etc/apache2/sites-available/default, that there not exists in your vhosts files, that's why vhosts are not working
If you're sure you want to disable the default vhos, move the above directive into apache2.conf

Regards

This is my "/etc/apache2/sites-available/default" file contents

Code:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

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

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

No sign of a
Code:

NameVirtualHost *
?

bathory 08-16-2012 11:06 AM

Since you're using a <VirtualHost *:80> notation, there should be a directive like:
Code:

NameVirtualHost *:80
By default it's in the default vhost file. Maybe you have moved it in some other config file. So search /etc/apache2/
Anyway, what it the error you get whne trying to access your other vhosts?

Wim Sturkenboom 08-17-2012 07:28 AM

I don't think you need to add 'namevirtualhost'; it's more than likely already set in one of the config files.

You can navigate to /etc/apache2 and run
Code:

grep -iR namevirtualhost *
to find it. You might find it in http.conf (not sure).

mcc28 08-17-2012 10:27 AM

The output of
Code:

grep -iR namevirtualhost *
is

Code:

ports.conf:NameVirtualHost *:80
ports.conf:    # If you add NameVirtualHost *:443 here, you will also have to change

I might just leave it for now and come back later as someone has suggested it would be good practice to leave the default as a catchall?


All times are GMT -5. The time now is 04:15 AM.