Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a development web server (ubuntu + apache) that can be accessed via the url glacialsummit.com. For some reason, http://www.glacialsummit.com serves pages from the /srv/www/glacialsummit.com/ directory, but http://glacialsummit.com serves pages from the /var/www/ directory. Here's what some of my virtualhost config files look like

filename: /etc/apache2/sites-enabled/glacialsummit.com

<VirtualHost 97.107.140.47:80>
     ServerAdmin sovereign@glacialsummit.com
     ServerName glacialsummit.com
     ServerAlias www.glacialsummit.com
     DocumentRoot /srv/www/glacialsummit.com/public_html/
     ErrorLog /srv/www/glacialsummit.com/logs/error.log
     CustomLog /srv/www/glacialsummit.com/logs/access.log combined
</VirtualHost>
<VirtualHost 97.107.140.47:443>
     ServerAdmin sovereign@glacialsummit.com
     ServerName glacialsummit.com
     ServerAlias www.glacialsummit.com
     DocumentRoot /srv/www/glacialsummit.com/public_html/
     ErrorLog /srv/www/glacialsummit.com/logs/error.log
     CustomLog /srv/www/glacialsummit.com/logs/access.log combined

        SSLEngine on

        SSLCertificateFile    /etc/ssl/localcerts/www.glacialsummit.com.crt
        SSLCertificateKeyFile /etc/ssl/localcerts/www.glacialsummit.com.key

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
        </Directory>
        BrowserMatch ".*MSIE.*" \
                nokeepalive ssl-unclean-shutdown \
                downgrade-1.0 force-response-1.0

</VirtualHost>
<VirtualHost 97.107.140.47:80>
     ServerAdmin sovereign@glacialsummit.com
     ServerName project.glacialsummit.com
     ServerAlias www.project.glacialsummit.com
     DocumentRoot /srv/www/project.glacialsummit.com/public_html/
     ErrorLog /srv/www/project.glacialsummit.com/logs/error.log
     CustomLog /srv/www/project.glacialsummit.com/logs/access.log combined
</VirtualHost>
## i have many other vhosts that work fine in this file

filename /etc/apache2/sites-enabled/000-default

<VirtualHost 97.107.140.47:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            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 /var/log/apache2/error.log

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

    CustomLog /var/log/apache2/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>

filename: /etc/apache2/ports.conf

NameVirtualHost 97.107.140.47:80
Listen 80

<IfModule mod_ssl.c>
    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
    Listen 443
</IfModule>

How do I make http://glacialsummit.com serve web pages from /srv/www/glacialsummit.com/public_html just like http://www.glacialsummit.com?

share|improve this question
    
Posting (and reading!) the output of httpd -S will give you some clues as to the nature of your configuration problem. –  MikeyB Apr 18 '10 at 14:32
    
i tried to run httpd, but got a command not found. i tried apt-get install httpd but go a "Package httpd has no installation candidate". What library do i need to install use this command? –  John Apr 18 '10 at 16:18
    
It varies depending on distro; on my Debian install the command is: apache2ctl -S –  MikeyB Apr 18 '10 at 22:30

3 Answers 3

up vote 2 down vote accepted

What is the server name of the entire server, outside of any VirtualHosts? I'll bet it's glacialsummit.com... If so, then that becomes the ServerName for the unnamed VirtualHost in 000-default.conf, and this VirtualHost overrides the www.glacialsummit.com VirtualHost.

share|improve this answer
    
Confirmed!!! I looked in my /etc/hosts and saw the line "97.107.140.47 glacialsummit.com sovereign". I changed that line to "97.107.140.47 somethingelse.com sovereign", restarted apache and now glacialsummit.com serves pages from the same place as www.glacialsummit.com! –  John Apr 18 '10 at 16:25
    
Glad I could help. It's often recommended to use a hostname that's different from any websites hosted by Apache, unless the IP will not have any VirtualHosts. So something.glacialsummit.com rather than just glacialsummit.com –  Josh Apr 18 '10 at 19:45

Under your ServerAlias for your top-most virtualhost, add glacialsummit.com along with www.glacialsummit.com

share|improve this answer
    
I just tried it, reloaded apache, but still the same problem –  John Apr 17 '10 at 16:57
ServerAlias *.glacialsummit.com 

makes everything, (www, non-www, and subdomains ) fault to the alias.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.