apache config question

Hi,

Got an Ubuntu server, DHCP, running Apache2
Want to setup multiple virtual hosts e.g.

NameVirtualHost *:80
<VirtualHost *:80>
      ServerAdmin webmaster@localhost
      ServerName XYZ
      

NameVirtualHost *:82
<VirtualHost *:82>
      ServerAdmin webmaster@localhost
      ServerName XYZ

Purely an internal network, no common DNS within the network
On the server itself, /etc/hosts has 127.0.0.1 XYZ

When restart Apache, get

"apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName"

How can I configure all of this so that I don't get this error?
On the server itself I can ping "XYZ"

Thanks, Ben

bcopsAsked:
Who is Participating?
 
slyongConnect With a Mentor Commented:
You can do it like this:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       bigserver bigserver.mysite.com   localhost.localdomain   localhost
0
 
nociSoftware EngineerCommented:
FQDN (Fully Quali...) is a hostname with domain name appended i.e.

you have server xyz in exmaple.com then the FQDN is XYZ.example.com
Find the line with ServerName in your apache config file and set the right name there.

This servername has nothing to do with the virtualHosts you created.
0
 
pjedmondConnect With a Mentor Commented:
You need something like the following in your /etc/hosts:

--------x8-----------
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost
192.168.1.100   bigserver bigserver.mysite.com
--------x8-----------
(   (()
(`-' _\
 ''  ''
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
slyongCommented:
Hi Ben,

Look for the ServerName directive in your httpd.conf file.  Change the ServerName to something like xyz.yourdomain.com and also add that into your /etc/hosts file
127.0.0.1 xyz xyz.yourdomain.com

0
 
bcopsAuthor Commented:
Hi all,

RE: pjedmonds answer - v helpful by the way:

--------x8-----------
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost
192.168.1.100   bigserver bigserver.mysite.com
--------x8-----------

The second line that has the IP address - problem I have is that the server does not have a fixed IP, and ideally I'd like it if it didn't - if it remained with a DHCP'd address.

Could I not alter it so that it ended up like this:

--------x8-----------
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost
127.0.0.1       bigserver bigserver.mysite.com
--------x8-----------

??

Thanks, Ben











0
 
slyongCommented:
Also you have to change your httpd.conf with the line:

ServerName  bigserver.mysite.com

if you search through the httpd.conf file you should see the ServerName directive.
0
 
bcopsAuthor Commented:
Ok, great.
And the bigserver.mysite.com can be completely made up? Remember it's an internal only server.

Thanks.

0
 
slyongCommented:
Hi Ben,

Yes it can be just made up.
0
 
bcopsAuthor Commented:
Great, many thanks. I'll try it this w/e, and let all know how I get on.
Thanks to one and all.

0
 
bcopsAuthor Commented:
OK, thanks - that appears to have fixed the ServerName issue. I'm now left with:

[Sat Jul 15 21:37:43 2006] [error] VirtualHost *:82 -- mixing * ports and non-* ports with a NameVirtua lHost address is not supported, proceeding with undefined results
[Sat Jul 15 21:37:43 2006] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtua lHost address is not supported, proceeding with undefined results
[Sat Jul 15 21:37:43 2006] [warn] NameVirtualHost *:82 has no VirtualHosts
[Sat Jul 15 21:37:43 2006] [warn] NameVirtualHost *:80 has no VirtualHosts
[Sat Jul 15 21:37:44 2006] [error] VirtualHost *:82 -- mixing * ports and non-* ports with a NameVirtua lHost address is not supported, proceeding with undefined results
[Sat Jul 15 21:37:44 2006] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtua lHost address is not supported, proceeding with undefined results
[Sat Jul 15 21:37:44 2006] [warn] NameVirtualHost *:82 has no VirtualHosts
[Sat Jul 15 21:37:44 2006] [warn] NameVirtualHost *:80 has no VirtualHosts

which completely baffles me. I'm using a 000-default file in /etc/apache2/sites-enabled that I've used before with Apache2 & Ubuntu before.

Perplexed.

0
 
slyongCommented:
Hi Ben,

It appears that you are mixing NameVirtualHost with VirtualHost *.  They cannot be used together.  If you want to use port 80 and 82 as different VirtualHost, try to comment out all the NameVirtualHost entries.  If you are not sure, you can put up your httpd.conf file here and the experts will troubleshoot for you.
0
 
bcopsAuthor Commented:

OK, seem to have sorted it. I'm using Ubuntu, and on Debian/Ubuntu the httpd.conf file is split into many small files in various different locations.

The main chunk where you define VirtualHosts is in /etc/apache2/sites-available/default. HOWEVER - there is also a symbolic link from /etc/apache2/sites-enabled/000-default to that same file. I was editing the 000-default file rather than the sites-available/default file.

When I started to edit the  sites-available/default file directly, all seemed to work file.

Wierd.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.