Forum

IP address in virtual host

Shashank
27 March 2009, 15:42
i do not want to map the web server to a unique ip.
the ip of my machine changes regularly, as this is get through the dhcp server.
so is there any other way to give the general term there.

My virtual host looks like following

VirtualHost{
Hostname = 10.112.79.145
WebsiteRoot = /var/www/MyWebSite
StartFile = index.html
ExecuteCGI = yes
TimeForCGI = 5
}

the host name here i have to change everytime, my IP changes.!!
this is the problem i am facing.
can you help me in this regard

thanks in advance.
Hugo Leisink
27 March 2009, 16:36
What you can do is use a hostname instead of an IP address for the Hostname setting. But what you should do is make sure your DHCP server gives the same IP address to the webserver everytime.
Shashank
28 March 2009, 07:08
thats tough in my case as our is a network device.
As we have macro INADDR_ANY to bind socket to all IPs exist on device, is there a method to configure httpd.conf in similar way ?

Thanks
Hugo Leisink
28 March 2009, 10:37
To bind all interfaces, use the following configuration:
Binding {
Interface = 0.0.0.0
...
}
Shashank
28 March 2009, 11:23
Thanks.!!
wil that affect my VirtualHost
beacause the problem still remains with the Hostname ??
Hugo Leisink
28 March 2009, 12:35
A VirtualHost always needs a hostname. Otherwise the webserver doesn't know which VirtualHost to use if a page is requested. If no matching hostname is found, the default host is used. The default host is the host configuration which is not inside a VirtualHost block. So, you can use that.

# This is the default host
Hostname = ...
WebsiteRoot = ...
...

# This is a virtual host
VirtualHost {
Hostname = ...
...
}

# And this is another virtual host
VirtualHost {
Hostname = ...
...
}
Shashank
30 March 2009, 08:34
that means i dont have a choice
but should have a unique IP or the hostname assigned to the machine
in which the webserver is running.
That seems a problem or a ver unlikely case in my situation.
can u suggest any workaround for the same?
Shashank
30 March 2009, 09:50
i mean to say that
i did following steps

changed the
Binding {
Port = 80
Interface = 0.0.0.0
}

then
VirtualHost{
Hostname = 0.0.0.0
WebsiteRoot = /var/www/MyWebSite
StartFile = index.html
ExecuteCGI = yes
TimeForCGI = 5
}

and
Hostname = 127.0.0.1
WebsiteRoot = /var/www/MyWebSite


Please let me know what thing i missed or did wrong
because still the problem persists..
i am getting the error
403 - Forbidden
Hugo Leisink
30 March 2009, 11:16
Please, try this configuration:
Binding {
Port = 80
}

CGIextension = cgi

Hostname = 127.0.0.1
WebsiteRoot = /var/www/MyWebSite
StartFile = index.html
ExecuteCGI = yes
TimeForCGI = 5


What kind of CGI programs do you want to use? PHP, Perl, compiled C?
Shashank
31 March 2009, 16:01
thanks a lot for the help.
it works fine now..
i am using compiled c.
This topic has been closed.