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

I'm setting up my first virtual host but the domain is not working. I've sudo a2ensite SITENAME'd it and restarted apache but it's still not accessible. I've verified that the IP is correct because I'm currently logged into splunk via the IP.

update

I have my NameVirtualHost *:80 on apache2.conf. My updated VirtualHost configuration for the site is:

<VirtualHost xx.xxx.xxx.xxx:80>
        ServerName www.domain.com
        ServerAlias domain.com
        ServerAdmin email@gmail.com

        DocumentRoot /home/source/public_html/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/source/public_html/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /home/source/log/error_log
        TransferLog /home/source/log/access_log
</VirtualHost>

I have also updated /etc/hosts to show:

127.0.0.1       localhost
127.0.1.1       productionserver
127.0.0.1       www.domain.com
share|improve this question

3 Answers 3

up vote 2 down vote accepted

What version of Apache are you using? If you are using version 2, the default VirtualHost configuration should serve you well. Use the following command to create a new VirtualHost:

$ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/www.yoursite.com 

Edit directives using your favourite text editor:

$ gksudo gedit /etc/apache2/sites-available/www.yoursite.com

Activate your site:

$ sudo a2ensite www.yoursite.com

Reload Apache:

$ sudo /etc/init.d/apache2 reload

Update /etc/hosts file with IP address and domain name:

127.0.0.1 www.yoursite.com

Browse to www.yoursite.com.

Hope this helps!

Mike

share|improve this answer
    
Thanks for the tips, a few steps you mentioned I had forgotten, but I'm still not able to access the site. –  Webnet Aug 20 '10 at 16:40
NameVirtualHost *:80
<VirtualHost xxx.xxx.xxx.xxx:80>
</VirtualHost>

Better yet, just use *:80 in the VirtualHost directive if you don't need (or care) to tie it to a specific IP address.

NameVirtualHost *:80
<VirtualHost *:80>
</VirtualHost>
share|improve this answer
    
PS: it's common syntax that 'ServerName' should always be the first line inside the VirtualHost block for clarity. It's not a technical thing, but a human readable thing. –  troyengel Aug 20 '10 at 0:55
    
Also, use tail on apache's log files when making request. –  peelman Aug 20 '10 at 4:34
    
I'd prefer to stick with the IP address –  Webnet Aug 20 '10 at 18:18

You only have www.domain.com in your hosts file and the server name is domain.com.

You can fix it by either adding www.domain.com after domain.com in your hosts file or adding this line after ServerName directive in apache configuration:

ServerAlias www.domain.com

Then reload apache configuration.

Thanks, -Kamil

share|improve this answer
    
I made that adjustment and reloaded apache, it didn't appear to have any effect. –  Webnet Aug 20 '10 at 17:07

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.