The FreeBSD Forums  

Go Back   The FreeBSD Forums > Server & Networking > Web & Network Services

Web & Network Services Discussion related to network/web services such as apache, bind, sendmail, etc.

Reply
 
Thread Tools Display Modes
  #1  
Old November 3rd, 2009, 13:11
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default Virtual Hosts won't work

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

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.
Reply With Quote
  #2  
Old November 3rd, 2009, 13:12
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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))
Reply With Quote
  #3  
Old November 3rd, 2009, 13:13
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Oops apologies, should be .233, but I can't edit my posts or delete them so I have had to post again! Sorry.
Reply With Quote
  #4  
Old November 3rd, 2009, 13:53
SirDice's Avatar
SirDice SirDice is offline
Giant Locked
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 2,650
Thanks: 5
Thanked 294 Times in 285 Posts
Default

Quote:
Originally Posted by jackocurly0074 View Post
Hi, so I want to get my webserver working so that I can access by for instance

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.
__________________
Oliver's Law:
Experience is something you don't get until just after you need it.
Reply With Quote
  #5  
Old November 3rd, 2009, 13:55
SirDice's Avatar
SirDice SirDice is offline
Giant Locked
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 2,650
Thanks: 5
Thanked 294 Times in 285 Posts
Default

Quote:
Originally Posted by jackocurly0074 View Post
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?
__________________
Oliver's Law:
Experience is something you don't get until just after you need it.
Reply With Quote
  #6  
Old November 3rd, 2009, 14:04
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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?

Quote:
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
Reply With Quote
  #7  
Old November 3rd, 2009, 15:06
SirDice's Avatar
SirDice SirDice is offline
Giant Locked
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 2,650
Thanks: 5
Thanked 294 Times in 285 Posts
Default

Quote:
Originally Posted by jackocurly0074 View Post
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.
__________________
Oliver's Law:
Experience is something you don't get until just after you need it.
Reply With Quote
  #8  
Old November 3rd, 2009, 15:16
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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!
Reply With Quote
  #9  
Old November 3rd, 2009, 15:24
SirDice's Avatar
SirDice SirDice is offline
Giant Locked
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 2,650
Thanks: 5
Thanked 294 Times in 285 Posts
Default

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.
__________________
Oliver's Law:
Experience is something you don't get until just after you need it.
Reply With Quote
  #10  
Old November 3rd, 2009, 19:15
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 3,330
Thanks: 8
Thanked 440 Times in 415 Posts
Default

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.
__________________
FreeBSD Handbook | FreeBSD Manuals | FAQ FreeBSD 6/7 | FreeBSD Wiki | FreeBSD Forum FAQ (Rules & Tips)
Always use CODE tags for posting system output! | End-of-Year Fundraising Drive | Donate!
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
  #11  
Old November 4th, 2009, 10:30
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #12  
Old November 4th, 2009, 10:35
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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)
Reply With Quote
  #13  
Old November 4th, 2009, 17:06
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 3,330
Thanks: 8
Thanked 440 Times in 415 Posts
Default

Does a straight ping 127.0.0.1 work? What's the output of ifconfig lo0?
__________________
FreeBSD Handbook | FreeBSD Manuals | FAQ FreeBSD 6/7 | FreeBSD Wiki | FreeBSD Forum FAQ (Rules & Tips)
Always use CODE tags for posting system output! | End-of-Year Fundraising Drive | Donate!
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
  #14  
Old November 4th, 2009, 17:31
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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)
Reply With Quote
  #15  
Old November 4th, 2009, 17:49
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 3,330
Thanks: 8
Thanked 440 Times in 415 Posts
Default

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.
__________________
FreeBSD Handbook | FreeBSD Manuals | FAQ FreeBSD 6/7 | FreeBSD Wiki | FreeBSD Forum FAQ (Rules & Tips)
Always use CODE tags for posting system output! | End-of-Year Fundraising Drive | Donate!
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
  #16  
Old November 4th, 2009, 18:11
SirDice's Avatar
SirDice SirDice is offline
Giant Locked
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 2,650
Thanks: 5
Thanked 294 Times in 285 Posts
Default

Odd indeed, lo0 does have the correct IPv6 address (::1)
__________________
Oliver's Law:
Experience is something you don't get until just after you need it.
Reply With Quote
  #17  
Old November 5th, 2009, 10:03
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
  #18  
Old November 5th, 2009, 10:06
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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"
Reply With Quote
  #19  
Old November 5th, 2009, 10:19
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #20  
Old November 5th, 2009, 11:00
SirDice's Avatar
SirDice SirDice is offline
Giant Locked
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 2,650
Thanks: 5
Thanked 294 Times in 285 Posts
Default

Quote:
Originally Posted by jackocurly0074 View Post
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.
__________________
Oliver's Law:
Experience is something you don't get until just after you need it.
Reply With Quote
  #21  
Old November 5th, 2009, 11:21
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by SirDice View Post
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
Reply With Quote
  #22  
Old November 5th, 2009, 11:59
SirDice's Avatar
SirDice SirDice is offline
Giant Locked
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 2,650
Thanks: 5
Thanked 294 Times in 285 Posts
Default

Ow.. Wait.. Remove that whole network_interfaces line or add lo0 to it.
__________________
Oliver's Law:
Experience is something you don't get until just after you need it.
Reply With Quote
The Following User Says Thank You to SirDice For This Useful Post:
jackocurly0074 (November 5th, 2009)
  #23  
Old November 5th, 2009, 12:04
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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"
Reply With Quote
  #24  
Old November 5th, 2009, 12:12
jackocurly0074 jackocurly0074 is offline
Junior Member
 
Join Date: Oct 2009
Posts: 61
Thanks: 5
Thanked 0 Times in 0 Posts
Default

I deleted the line and everything appears to work fine! Thanks very much, you guys are most helpful folk
Reply With Quote
  #25  
Old November 5th, 2009, 14:08
SirDice's Avatar
SirDice SirDice is offline
Giant Locked
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 2,650
Thanks: 5
Thanked 294 Times in 285 Posts
Default

Quote:
Originally Posted by jackocurly0074 View Post
erm.... right, if I'm going to add lo0 to it what is the correct syntax??
For future reference:

Code:
network_interfaces="fxp0 lo0"
__________________
Oliver's Law:
Experience is something you don't get until just after you need it.
Reply With Quote
Reply

Tags
"httpd-vhosts.conf", "virtual hosts", namevirtualhost

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/hosts getting overwritten after reboot? mrab54 Networking 2 May 30th, 2009 21:42
Jails vs. Virtual Hosts cwhitmore Web & Network Services 1 April 15th, 2009 20:37
Sendmail resolving global MX, not from /etc/hosts Phliplip Web & Network Services 2 March 24th, 2009 15:55
[Solved] Correct way to set up /etc/hosts rota Installing & Upgrading 5 March 19th, 2009 20:39
Database Storage of Apache Virtual Hosts Enter4 Web & Network Services 2 January 8th, 2009 12:12


All times are GMT +1. The time now is 09:40.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.