Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sat Sep 13, 2008 5:59 pm 
Offline
Senior Newbie

Joined: Wed Sep 10, 2008 1:58 pm
Posts: 16
I’m trying to set up two web sites on my Apache2 server using virtual hosting. I created DNS domain zones for both sites. When I point my browser to either domain name, I get the Apache2 default index.html file.

I want to get one site set up correctly, then add the second one. I
I looked at several online tutorials, and finally settled on the approach described at: http://www.debian-administration.org/articles/412 :

I’m running Debian Etch. I’ll create both sites in the /var/www/ directory. The first domain name is bookgenius.org, so I created these directories:

/var/www/bookgenius.com/html
/var/www/bookgenius.com/hcgi-bin
/var/www/bookgenius.com/logs

I opened the file /etc/apache2/sites-available/default

and commented out the first line containing

NameVirtualHost *

(This was per the advice of the tutorial, which notes that when apache starts up, it reads the contents of all files included in /etc/apache2/conf.d.

Next, I created a virtual.conf file in /etc/apache2/conf.d/
containing just the line:

NameVirtualHost *

Then I created a file called /etc/apache2/sites-available/bookgenius.org containing the following:

#########################################

<VirtualHost *:80>

# Admin email, Server Name (domain name) and any aliases
ServerAdmin morgan@acm.org
ServerName bookgenius.org
ServerAlias www.bookgenius.org

# Index file and Document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot /var/www/bookgenius.org/html/

# CGI Directory
ScriptAlias /cgi-bin/ /var/www/bookgenius.org/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>

# Custom log file locations
LogLevel warn
ErrorLog /var/www/bookgenius.org/logs/error.log
CustomLog /var/www/bookgenius.org/logs/access.log combined

</VirtualHost>

##########################################


Lastly, I typed:

a2ensite bookgenius.org

and got:

Site bookgenius.org installed; run /etc/init.d/apache2 reload to enable.

I reloaded Apache, but the browser still points to the default Apache index.html page instead of the new index.html page I put in the bookgenius.org/html directory.

Does anyone have any ideas about what I’m doing wrong?

Many thanks!

- Chris M.


Top
   
 Post subject:
PostPosted: Sat Sep 13, 2008 6:08 pm 
Offline
Senior Newbie

Joined: Wed Sep 10, 2008 1:58 pm
Posts: 16
Correction: The three directories I listed in my first post had typos in them -- they're as follows on my site):

/var/www/bookgenius.org/html
/var/www/bookgenius.org/cgi-bin
/var/www/bookgenius.org/logs

- Sorry!


Top
   
 Post subject:
PostPosted: Sat Sep 13, 2008 10:34 pm 
Offline
Newbie

Joined: Mon Apr 28, 2008 12:31 pm
Posts: 3
Try disabling the default site:

a2dissite default

Also try to put your ip in the VirtualHost directive:

<VirtualHost xx.xx.xx.xx>


Top
   
 Post subject:
PostPosted: Sun Sep 14, 2008 7:25 am 
Offline
Senior Newbie

Joined: Wed Sep 10, 2008 1:58 pm
Posts: 16
Disabling the default site did it! I'm getting my index.html page now.

Many thanks!

- Chris M.


Top
   
 Post subject:
PostPosted: Sun Sep 14, 2008 11:08 am 
Offline
Senior Newbie

Joined: Wed Sep 10, 2008 1:58 pm
Posts: 16
Just an addendum to anyone reading this thread who tries to create a similar setup. I thought I had solved the problem after setting up the first site, but when I added the second site, I got this warning message:

[warn] _default_ VirtualHost overlap on port 80, the first has precedence

So, disabling the default web site wasn't enough. The solution (as karsh suggested in his post) was to change the VirtualHost directives in the two files in the sites-available directory to be the names of the two domains, e.g.:

<VirtualHost bookgenius.org:80>

But I also had to add the following NameVirtualHost line containing my specific IP address to the end of my apache2.conf file:

NameVirtualHost <xx.xx.xx.xx>:80

This was because Apache wasn't happy with the virtual.conf file I had created that contained this line. (As I surfed the web looking for tips about setting up virtual servers, I found a lot of conflicting advice about where to put this NameVirtualHost line in the Apache2 file structure, but putting it at the end of apache2.conf worked for me.)

So, with all those changes made, I deleted the default file in the sites-available directory (so it wouldn't come back to haunt me). Then I ran a2dissite on both sites (just to clean things out), then I re-ran a2ensite on both sites, reloaded Apache, and both sites are now working correctly.

Yikes -- this Virtual Hosting is tricky stuff! (Thanks again for the advice, karsh!)

- Chris M.


Top
   
PostPosted: Mon Sep 15, 2008 8:03 am 
Offline
Senior Member

Joined: Wed Oct 20, 2004 8:55 am
Posts: 120
cpmorganesq wrote:
I’m running Debian Etch.


Since your running Etch, this will give you a few starters for most things you may want to do.

http://www.linode.com/wiki/index.php/User:Kangaby


Top
   
 Post subject:
PostPosted: Mon Sep 15, 2008 8:08 am 
Offline
Senior Newbie

Joined: Wed Sep 10, 2008 1:58 pm
Posts: 16
Great -- many thanks!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group