0

I actually don't know many things about server-side things (other than some PHP), but I'm trying to get familiar with it, so here's the problem:

I just downloaded Apache HTTP Server and it works like a charm. I even tried it on local network and it still does work, but when I need to access files, I need to type local ip address like "192.168.1.33", but I need to access it by domain name that doesn't exist on web. The whole network is isolated and it is not connected to internet. Is there any way to do so?

For example, would it be possible to access my server with domain like "myname.com" or "myname.local"';

I tried to find solution to this problem both on google and here too, but without luck, but maybe that is due to my lack of knowledge, so I will apologise in advance if I'm asking something really easy or silly and if there is a resource that could help me, I would really appreciate giving me directions ;)

3
  • 1
    Is apache installed on *nix or on Windows through WAMP/AMPPS/etc? Look into your 'hosts' file. Linux: /etc/hosts and Windows: C:\windows\system32\drivers\etc. You can add a record like: 127.0.0.1 myname.local -- which will then resolve to your localhost. Commented Oct 19, 2012 at 17:57
  • Now I have it on Windows, but I'm planning linux :) if I change that in host file, will that server be accessed with particular domain from every computer connected to local network? Commented Oct 19, 2012 at 18:01
  • 1
    Your hosts file controls your machine only. You would need to have a DHCP server with a hosts file to control your whole network. Commented Oct 19, 2012 at 18:04

2 Answers 2

2

Follow these steps to configure a custom domain on apache through windows:

Open Notepad (As Administrator): c:\windows\System32\drivers\etc\hosts

Add a line to the bottom:

127.0.0.1     yourfakedomain.local

Then, open your apache configuration: /bin/apache/Apache/conf/httpd.conf

Add these lines to the bottom:

<VirtualHost *:80>
  ServerName yourfakedomain.local
  ServerAlias www.yourfakedomain.local
  DocumentRoot "c:\path\to\your\code"
  DirectoryIndex index.php
</VirtualHost>

Note: you can also put the apache configuration in your /bin/apache/conf/extra/httpd-vhosts.conf file if you have it set to be read in httpd.conf.

Then, gracefully restart apache:

From Command prompt: service httpd graceful

..or Restart Services from your GUI.

Sign up to request clarification or add additional context in comments.

1 Comment

Now I know a thing or two about servers. @Robert Thanks, that's exactly what I was looking :) I just wish that I could make that domain available throughout all computers without extra DHCP server
1

The solution would be to have your own dns server to solve all the .local dns requests, and all local computers pointing to that dns server. However, you have easier work arounds like Robert's answer.

Probably you can also If you had internet access, you could use a public domain hosting pointing to a private address, as other soultions it will work only for computers in your local network. For example creating: yourname.tk in www.dot.tk pointing to your local address: 192.168.1.33.

4 Comments

I don't understand if my local network, which has no access to internet, how could it use public domain? Could that work or am i wrong? If you mean in case of internet connection, I get it ;) Anyway, thanks for opinion @pmoleri ;)
You are right, that would only work if you have access to internet. I'll correct the answer.
Don't get me wrong, I thought that I was wrong, not you ;) i'm just a beginner :)
No problem, the isolation of the network was part of the question, I just forgot it while answering :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.