How to set-up my webserver properly on my local network?
I have an intranet (inside the network) website, but it is somewhat of a pain. First of all, this is a home network, if that helps anyone. I have a computer running Apache web server with PHP, and I want to point 3 URLs on the local network to it. I have had some success, but it isn't always dependable. For DNS and DHCP I have a Thompson Speedtouch ST546 v6 DSL router.
Edit: I need it for intranet websites, not just file hosting, as I do quite a bit with CMSs.
Rewrite for clarity: I have a computer with three subdomains on the local network pointing to IP address 10.0.0.2, abp.bhc.com
, wiki.bhc.com
, and server.bhc.com
, along with the webserver's personal dns name. I use the SpeedTouch for the DNS, and have complete control over it. It usually works, after I fiddle with it for an hour.
My question is whether there is a more elegant solution than manually adding the domain each time I need another one. It usually seems to work, though.
Here is my current VH file:
NameVirtualHost 10.0.0.2
<VirtualHost 10.0.0.2>
ServerName abp.bhc.com
DocumentRoot "htdocs/abp"
</VirtualHost>
<VirtualHost 10.0.0.2>
ServerName server.bhc.com
DocumentRoot "htdocs/server"
</VirtualHost>
<VirtualHost 10.0.0.2>
ServerName wiki.bhc.com
DocumentRoot "htdocs/wiki"
Alias /wiki htdocs/wiki/wbhc/index.php
</VirtualHost>
Duh, I figured out my immediate problem. The IP Address was set wrong, apparantly because I recently got a new LAN adapter. My question about whether there is a better solution still stands.
Solution 1:
There's two ways:
- Setup your own DNS and configure it.
- Add entries the hosts file on each file system you want to access the site.
I'm assuming that you can't change the DNS settings on your router and don't want to setup and configure Bind. To add entries to the hosts file, open up the file (/etc/hosts on Linux c:\windows\system32\drivers\etc\hosts on Window) and add lines like:
192.168.0.1 abp.bhc.com
192.168.0.1 wiki.bhc.com
192.168.0.1 server.bhc.com
Solution 2:
If you don't have an internal dns server you can put the ip-adress from your server in the hosts file of all clients and the server like shf301 said. The apache have to be configured with virtual hosts like this:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot c:/www/wiki
ServerName wiki.bhc.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot c:/www/server
ServerName server.bhc.com
</VirtualHost>
Documentation: apache virtual hosts