Results 1 to 4 of 4
hi,
how are u my friend?
i have 2 question:
1: I have a linux server(web) in my office, i explorer it with a local ip 192.168.1.2, how can i ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 06-07-2012 #1Just Joined!
- Join Date
- Jun 2012
- Posts
- 2
set linux hostname & question about set multiple domain on one ip
hi,
how are u my friend?
i have 2 question:
1: I have a linux server(web) in my office, i explorer it with a local ip 192.168.1.2, how can i view it with a domain ( in local)?
replace ip, type an address.com in browser.
2: i have a vps with an ip, i want to use this vps with 2 domain. each domain point different folders in /var/www .
how can i do that? i installed ispconfig for this but do not work. i need dns server? which dns records?
thanks
- 06-09-2012 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,696
You need to do IP address to hostname resolution. You can accomplish this with DNS, or using "hosts" files. DNS is a beast, so I would recommend starting with the "hosts" method.
Say this is your IP addressing setup:
Linux webserver: 192.168.1.2
Linux client: 192.168.1.3
On the Linux client, you need to modify the file "/etc/hosts". You need to be root to modify it, so su to root first, then open it in an editor, e.g.:
Then you add an entry for your webserver, on a new line:Code:su - vi /etc/hosts
now you can open a browser on the Linux client and put in the address bar any of these:Code:192.168.1.2 webserver webserver.localhost www.mywebsite.com
http://192.168.1.2
http://webserver
http://webserver.localhost
http://www.mywebsite.com
and it will point to your Linux webserver. Technically, to make sure the resolving happens with "hosts" before DNS, you need to check the file "/etc/nsswitch.conf", but by default it is in the proper order, e.g.:
Note that if "www.mywebsite.com" is an actual internet address, your ip address in /etc/hosts will override it (due to the line in nsswitch.conf).Code:[root@localhost ~]# grep ^hosts /etc/nsswitch.conf hosts: files dns
Check out the VirtualHost declarative for Apache, it is what you need.2: i have a vps with an ip, i want to use this vps with 2 domain. each domain point different folders in /var/www .
how can i do that? i installed ispconfig for this but do not work. i need dns server? which dns records?
http://httpd.apache.org/docs/2.0/vhosts/examples.html
Just make sure that on your Linux client PC, you resolve the domain names hosted on the Linux server with the correct IP address. For example, in your Linux client /etc/hosts file, you might have:
It is up to the Apache server to redirect browser requests to the proper virtual host, and it does that by using the domain name used by the client to access the webserver (e.g. "www.website1.com" or "www.website2.com").Code:192.168.1.2 www.website1.com www.website2.com
- 06-12-2012 #3Just Joined!
- Join Date
- Jun 2012
- Posts
- 2
thanks for your best explain.
but my network is connected with an adsl modem router and when i set a domain in hosts and enter it on browser , browser thinks its over internet....
what can i do ? thanks
- 06-12-2012 #4Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,696
Okay, tell us exactly what you did, so that we can better help you.
For instance, did you update the /etc/hosts file on any machines? If so, which machines? What did you enter (show /etc/hosts)? What did you use as the URL in the browser? On what machine did you run the browser?
Also,
A quick test you can do on the client is to try to resolve the hostname of the server to an ip address using ping, e.g.:
where WEBSERVER_HOSTNAME is the name of the webserver that you (hopefully) put in the /etc/hosts file on your client PC.Code:ping <WEBSERVER_HOSTNAME>
If instead, you are using DNS, you can use the "host" command, e.g.:
This command should return any ip address records associated with that name on your DNS servers.Code:host <WEBSERVER_HOSTNAME>


Reply With Quote

