LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-19-2008, 04:31 PM   #1
nkoplm
Member
 
Registered: May 2005
Distribution: Fedora
Posts: 92

Rep: Reputation: 15
What is the proper way to server multiple domain names with httpd?


I have a server in my basement that is currently serving a bunch of different websites for 3 TLDs. The only way I have ever known how to make this work is to add a bunch of these to the bottom of my httpd config file:

Quote:
NameVirtualHost 192.168.1.80:80
<VirtualHost 192.168.1.80:80>
ServerAdmin email-address@is.invalid
DocumentRoot /var/www/html/mysite.com
ServerName mysite.com
ErrorLog logs/error-log
CustomLog logs/access-log common
</VirtualHost>

NameVirtualHost 192.168.1.80:80
<VirtualHost 192.168.1.80:80>
ServerAdmin email-address@is.invalid
DocumentRoot /var/www/html/mysitestore
ServerName orders.mysite.com
ErrorLog logs/error-log
CustomLog logs/access-log common
</VirtualHost>

NameVirtualHost 192.168.1.80:80
<VirtualHost 192.168.1.80:80>
ServerAdmin email-address@is.invalid
DocumentRoot /var/www/html/myothercoolsite.com
ServerName www.myothercoolsite.com
ErrorLog logs/error-log
CustomLog logs/access-log common
</VirtualHost>
this seems to do the trick, but it is starting to get a bit messy with lots and lots of different sites starting to pile up at the end of my config file. Is there a cleaner or better way to do this?

also if it helps whenever i start the httpd service, i get these errors
[root@nethost root]# /sbin/service httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Fri Dec 19 13:53:22 2008] [warn] NameVirtualHost 192.168.1.80:80 has no VirtualHosts
[Fri Dec 19 13:53:22 2008] [warn] NameVirtualHost 192.168.1.80:80 has no VirtualHosts
[Fri Dec 19 13:53:22 2008] [warn] NameVirtualHost 192.168.1.80:80 has no VirtualHosts
[Fri Dec 19 13:53:22 2008] [warn] NameVirtualHost 192.168.1.80:80 has no VirtualHosts
[Fri Dec 19 13:53:22 2008] [warn] NameVirtualHost 192.168.1.80:80 has no VirtualHosts
[Fri Dec 19 13:53:22 2008] [warn] NameVirtualHost 192.168.1.80:80 has no VirtualHosts
[Fri Dec 19 13:53:22 2008] [warn] NameVirtualHost 192.168.1.80:80 has no VirtualHosts
[Fri Dec 19 13:53:22 2008] [warn] NameVirtualHost 192.168.1.80:80 has no VirtualHosts
[Fri Dec 19 13:53:22 2008] [warn] NameVirtualHost 192.168.1.80:80 has no VirtualHosts
[Fri Dec 19 13:53:22 2008] [warn] NameVirtualHost 192.168.1.80:80 has no VirtualHosts
[ OK ]
(one for each site)
 
Old 12-19-2008, 04:37 PM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
You don't need the "NameVirtualHost 192.168.1.80:80" before each VirtualHost. That may cause the error. Do you want to remove the text colouring so we can read that btw?

Depending on you distro, you may be able to separate your virtual definitions into /etc/httpd/conf.d or similar. Not quite sure I'd bother though.
 
Old 12-19-2008, 06:41 PM   #3
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
I have one single 'NameVirtualHost' entry followed by numerous VirtualHost sections, and it's been working fine for quite some time

I agree with Billymayday -- nix those NameVirtualHost entries (save for the first).
 
Old 12-19-2008, 08:11 PM   #4
AuroraCA
Member
 
Registered: Jul 2008
Location: Northern CA USA
Distribution: Ubuntu, Slackware, Gentoo, Fedora, Red Hat, Puppy Linux
Posts: 370

Rep: Reputation: 35
Different distributions of Linux have different ways of implementing Virtual Hosts. Debian and derivatives use a separate /etc/apache2/sites-available directory in which separate individual virtual host files are maintained. A virtual host is enabled using the command:
Code:
a2ensite virtualsitefilename
(a2dissite disables a virtual host)

This command creates a link in the /etc/apache2/sites-enabled directory. When Apache2 is reloaded or started the configuration files are read from the /etc/apache2/sites-enabled directory to initialize the virtual hosts.

I prefer this implementation to the all in one httpd.conf file.

Last edited by AuroraCA; 12-19-2008 at 08:12 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
single IP multiple domain names jduckett01 Linux - Networking 2 08-26-2008 08:38 PM
How do I point several domain names to seperate parts of my root server in Plesk 7? mohawx Linux - Newbie 2 03-19-2006 05:58 PM
multiple domain names stuffradio Slackware 1 01-11-2006 06:02 AM
Multiple names for the same SAMBA server Paul.Hermans Mandriva 0 07-29-2005 09:53 AM
Mail Server for Multiple Domain Names iamPlace Linux - Newbie 0 06-27-2003 09:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration