Virtual Hosts won't work

Hi, so I want to get my webserver working so that I can access by for instance

http://www.TestServer.com

instead of

192.168.1.255 (e.g.)
However after editing the httpd.conf file to include
Code:
etc/apache22/extra/httpd-vhosts.conf
and restarting Apache it stops working (the Apache service doesn't start (I only know this from running restart after start and it then saying it isn't running (error - httpd not running, trying to start).

As far as I know the hosts file is ok, here it is just in case -
Code:
::1                     localhost localhost.com
127.0.0.1               test.TestServer.com TServer
127.0.0.1               localhost.TestServer.com
192.168.1.233           TestServer.com TServer
192.168.1.233           TestServer.com

Note that before including the vhosts file that I can access the web page on the servers webpage using Tserver, or TestServer.com etc. Here is the file with the virtual hosts setup stuff -
Code:
NameVirtualHost 192.168.1.233:8080

<VirtualHost 192.168.1.233:8080>
    ServerAdmin root@TestServer.com
    DocumentRoot "/usr/local/www/TestServer"
    ServerName TestServer.com
    ServerAlias TestServer.com TServer
    ErrorLog /usr/local/www/logs/TestServer-error_log
    CustomLog /usr/local/www/logs/TestServer-access_log combined
</VirtualHost>
#Note this virtual host is not used and is here as a template
#<VirtualHost 192.168.1.233:8080>
    #ServerAdmin root@d.example.com
    #DocumentRoot "/usr/local/www/example.com
    #ServerName example.com
    #ServerAlias www.example.com
    #ErrorLog /usr/local/www/logs/example-error_log
    #CustomLog /usr/local/www/logs/example-access_log combined
#</VirtualHost>

I'm sure that I need to do something with DNS but have no idea what, and because once I enable vhosts apache won't restart I don't know what to do! Any help would be much appreciated.
 
Note something else which I find odd is I cannot ping 127.0.0.1 but I can ping my IP address (192.168.1.255 (manually set))
 
jackocurly0074 said:
Hi, so I want to get my webserver working so that I can access by for instance

http://www.TestServer.com

instead of

192.168.1.255 (e.g.)
You will need to either register that domain, run your own DNS server or add it to your /etc/hosts file.

No amount of editing in httpd.conf will make that hostname available to other machines.
 
jackocurly0074 said:
Note something else which I find odd is I cannot ping 127.0.0.1 but I can ping my IP address (192.168.1.255 (manually set))

Firewall settings?
 
As far as I know there isn't a firewall installed, or at least not one that I have configured? Is one automatically installed for FreeBsd? With regards to the DNS server, what is the easiest way to get it working locally (i.e. on the local network but without outside access). Can I run a DNS server on the machine which is acting as the web server, I know this may be bad practice to put them in the same place but would it work?

You will need to either register that domain, run your own DNS server or add it to your /etc/hosts file.

Looking at that you say I will need to add it to the hosts file, however I thought it already was in the hosts file? Or maybe I need to put a different entry in? If I don't register the domain or run a DNS server does this mean I will not be able to get it to work?

Lastly, what is the quickest way I will be able to access the web server using a name even if it is simply restricted to my local network (192.168.1.x)

Thanks
 
jackocurly0074 said:
Lastly, what is the quickest way I will be able to access the web server using a name even if it is simply restricted to my local network (192.168.1.x)
Add the hostname to the hosts file on all the client machines. Remember it's the client that does the resolving, not the webserver.
 
On all the client machines .....:S! Good point forgot that, though usually a DNS server does it, if I want to setup DNS on the machine is it a lengthy/tricky process? Or is it simply a matter of installing the DNS program from ports and putting an entry in its config file? What is the main DNS program used for this btw! Thanks!
 
Bind is the standard DNS server and it's even included with the Base OS. There's a slightly newer version in the ports and there are also alternatives to bind.

It's a bit tricky to setup, you really need to know how DNS works. OTOH there are numerous howtos floating around on the internet that will guide you through it.
 
Change this back in /etc/hosts:

Code:
127.0.0.1		localhost localhost.my.domain

127.0.0.1 should be localhost, plain and simple.
 
Thanks for that, I was looking at my windows hosts file and realised that my Unix one was pretty messy and didn't look right! Thanks for the pointer :)
 
With regards to pinging the local host (127.0.0.1 (home...)) I still can't seem to do it and as far as I know I don't have a custom firewall installed! Any ideas on why it might not work/
here is the error -
Code:
ping localhost
PING 127.0.0.1 (127.0.0.1): 56 data bytes
ping: sendto: Can't assign requested address

So it is resolving the IP correctly using the hosts file but is unreachable. Any way of checking the configuration of the firewall (the inbuilt one)
 
Does a straight [cmd=]ping 127.0.0.1[/cmd] work? What's the output of [cmd=]ifconfig lo0[/cmd]?
 
The result of a straight ping is shown below -

Code:
%ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
ping: sendto: Can't assign requested address
ping: sendto: Can't assign requested address
ping: sendto: Can't assign requested address
ping: sendto: Can't assign requested address

And the result of ifconfig -

Code:
%ifconfig lo0
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
        inet6 ::1 prefixlen 128

Unsure as why it has stopped working but must have changed a config file somewhere that has messed it up! Problem is without access to localhost some of the programs I wish to use won't work (e.g. squrriel mail server)
 
You don't have the address 127.0.0.1 assigned to lo0 (or anywhere on your system). I'm surprised your system even works like that ;) Does it come back after a reboot?

Make sure you have this in /etc/defaults/rc.conf (which you should never edit):

Code:
ifconfig_lo0="inet 127.0.0.1"	# default loopback device configuration.
 
Hey, just checked the defaults rc.conf file and yes that line is there! Also looking at that file there is not a firewall enabled so that can't be the problem as far as I can tell.
 
Just in case it is of any use, here is the rc.conf file (located at /etc/rc.conf)

Code:
# -- sysinstall generated deltas -- # Wed Oct 28 14:00:19 2009
# Created: Wed Oct 28 14:00:19 2009
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
keymap="uk.cp850"
linux_enable="YES"
sshd_enable="YES"
saver="snake"
mysql_enable="YES"
apache22_enable="YES"
font8x8="cp437-8x8"
font8x14="cp437-8x14"
font8x16="cp437-8x16"
moused_port="/dev/psm0"
moused_type="auto"
moused_enable="YES"
hald_enable="YES"
dbus_enable="YES"
gdm_enable="YES"
gnome_enable="YES"
samba_enable="YES"


hostname=RinicomTestServer.com
# -- sysinstall generated deltas -- # Mon Nov  2 13:46:37 2009
defaultrouter="192.168.1.1"
network_interfaces=fxp0
Name_server 192.168.0.1
ifconfig_fxp0="inet 192.168.1.233 netmask 255.255.255.0"
 
Also here is the entry from the defaults rc.conf file -
Code:
#cloned_interfaces="gif0 gif1 gif2 gif3" # Pre-cloning GENERIC config.
ifconfig_lo0="inet 127.0.0.1"	# default loopback device configuration.
#ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry.
#ifconfig_ed0_ipx="ipx 0x00010010"	# Sample IPX address family entry.
#ifconfig_fxp0_name="net0"	# Change interface name from fxp0 to net0.
#ipv4_addrs_fxp0="192.168.0.1/24 192.168.1.1-5/28" # example IPv4 address entry.
#
#autobridge_interfaces="bridge0"	# List of bridges to check 
#autobridge_bridge0="tap* vlan0"	# Interface glob to automatically add to the bridge
#
# If you have any sppp(4) interfaces above, you might also want to set
# the following parameters.  Refer to spppcontrol(8) for their meaning.
sppp_interfaces=""		# List of sppp interfaces.
#sppp_interfaces="isp0"		# example: sppp over ISDN
#spppconfig_isp0="authproto=chap myauthname=foo myauthsecret='top secret' hisauthname=some-gw hisauthsecret='another secret'"
gif_interfaces=""		# List of GIF tunnels.
#gif_interfaces="gif0 gif1"	# Examples typically for a router.
				# Choose correct tunnel addrs.
#gifconfig_gif0="10.1.1.1 10.1.2.1"	# Examples typically for a router.
#gifconfig_gif1="10.1.1.2 10.1.2.2"	# Examples typically for a router.
fec_interfaces=""		# List of Fast EtherChannels.
#fec_interfaces="fec0 fec1"
#fecconfig_fec0="fxp0 dc0"	# Examples typically for two NICs
#fecconfig_fec1="em0 em1 bge0 bge1"	# Examples typically for four NICs
 
jackocurly0074 said:
Code:
hostname=RinicomTestServer.com

network_interfaces=fxp0
Name_server 192.168.0.1
I think the problems are these. Put quotes around the hostname and network_interface. Also remove that Name_server line.
 
SirDice said:
I think the problems are these. Put quotes around the hostname and network_interface. Also remove that Name_server line.

Right tried that, restarted the machine and still get the same message, to ensure I have edited the file correctly here it is -
Code:
# -- sysinstall generated deltas -- # Wed Oct 28 14:00:19 2009
# Created: Wed Oct 28 14:00:19 2009
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
keymap="uk.cp850"
linux_enable="YES"
sshd_enable="YES"
saver="snake"
mysql_enable="YES"
apache22_enable="YES"
font8x8="cp437-8x8"
font8x14="cp437-8x14"
font8x16="cp437-8x16"
moused_port="/dev/psm0"
moused_type="auto"
moused_enable="YES"
hald_enable="YES"
dbus_enable="YES"
gdm_enable="YES"
gnome_enable="YES"
samba_enable="YES"


hostname="RinicomTestServer.com"
# -- sysinstall generated deltas -- # Mon Nov  2 13:46:37 2009
defaultrouter="192.168.1.1"
network_interfaces="fxp0"
#Name_server 192.168.0.1
ifconfig_fxp0="inet 192.168.1.233 netmask 255.255.255.0"
Still the same message when I try t o ping local host! Something related when I try to access squirrel mail I get the following error which is due to the problem with local host as far as I can tell -

Code:
ERROR: Error connecting to SMTP server "localhost:25".Server error: (49) Can't assign requested address
 
erm.... right, if I'm going to add lo0 to it what is the correct syntax??

network_interfaces="fxp0","lo0"

or

network_interfaces="fxp0,lo0"
 
jackocurly0074 said:
erm.... right, if I'm going to add lo0 to it what is the correct syntax??
For future reference:

Code:
network_interfaces="fxp0 lo0"
 
Back
Top