Monday, January 24, 2011

Why can't I get rid of default index.html even if I disable the default virtual host in Apache2?

I have created a virtual host settings file and I disabled the default settings by using a2dissite default (this is a pretty standard Ubuntu 10.04 installation). But no matter what I try my Apache2 server simply keeps on displaying the default index.html page instead of the index.php page that I set up in the virtual host file. Can someone help me what I'm missing. Details follow:

No default settings:

ls -l /etc/apache2/sites-enabled/
total 0
lrwxrwxrwx 1 root root 51 May  5 13:32 webmin.1273066327.conf -> /etc/apache2/sites-available/webmin.1273066327.conf
lrwxrwxrwx 1 root root 34 May 30 11:03 www.accontax.be -> ../sites-available/www.accontax.be

Contents of the relevant virtual host:

cat /etc/apache2/sites-enabled/www.accontax.be

<VirtualHost *>
    ServerName  www.accontax.be
    ServerAlias accontax.be

    DirectoryIndex index.php
    DocumentRoot /var/www/drupal/

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

Contents of httpd.conf:

cat /etc/apache2/httpd.conf

Listen 80
NameVirtualHost *

I also have those relevant lines in my apache2.conf:

# Include generic snippets of statements
Include /etc/apache2/conf.d/

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/

When I visit http://www.accontax.be I expect apache2 server go to the /var/www/drupal subdirectory and start serving index.php but it simply keeps on serving index.html from /var/www directory. I have reloaded the configuration, restarted the server, deleted my browser cache. Nothing changed.

Probably I'm missing a simple yet crucial step but I just could not find it.

PS: When I ssh to the server and try to browse the localhost it works as I expect!

  • i assume that your hostname is proper (li141-187.members.linode.com)

    in /etc/apache2/httpd.conf change the line below,

    NameVirtualHost * to NameVirtualHost 109.74.194.187:80

    & there can be a duplicate NameVirtualHost in your /etc/apache2/sites-enabled/webmin.1273066327.conf file in line 1. check if exists. if yes delete that line.

    & edit the VirtualHost definition in /etc/apache2/sites-enabled/000-default file as follows.

    <VirtualHost 109.74.194.187:80>
       ServerName 109.74.194.187
       .......
    

    & edit the lines in /etc/apache2/sites-enabled/www.accontax.be as follows.

    <VirtualHost 109.74.194.187:80>
       ServerName accontax.be
       ServerAlias www.accontax.be
       .......
    

    then apache2ctl restart.

    & and also check you bind's zone file for accontax.be, it should be like configuration below.

    $ttl 38400
    @   IN  SOA accontax.be li141-187.members.linode.com. (
                SOA_SERIAL_NUMBER
                10800
                3600
                604800
                38400 )
    accontax.be.    IN  NS  ns1.linode.com.
    accontax.be.    IN  NS  ns2.linode.com.
    accontax.be.    IN  A   109.74.194.187
    www.accontax.be.    IN  A   109.74.194.187
    ftp.accontax.be.    IN  A   109.74.194.187
    webmail.accontax.be.    IN  A   109.74.194.187
    mail.accontax.be.   IN  A   109.74.194.187
    accontax.be.    IN  MX  5 mail.accontax.be.
    accontax.be.    IN  TXT "v=spf1 a mx a:accontax.be ip4:109.74.194.187 ?all"
    

    there should be your own serial number for domain, intodns.com says so. change SOA_SERIAL_NUMBER with your own above.

    & this link will give you more information about DNS configuration. http://www.intodns.com/accontax.be

    it seems your are using webmin. it's much better to do all these changes in webmin for you. Check everything under "Servers" menu, in apache menu, check your module config is ok before changing anything. & also change startup command for apache in webmin to apache2ctl. do not allow webmin to use /etc/init.d/apache2 script.

    From yasin inat

0 comments:

Post a Comment