Find the answer to your Linux question:
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.
  1. #1
    Just 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

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,318
    Quote Originally Posted by rout3rx View Post
    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.
    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.:

    Code:
    su -
    vi /etc/hosts
    Then you add an entry for your webserver, on a new line:

    Code:
    192.168.1.2  webserver webserver.localhost www.mywebsite.com
    now you can open a browser on the Linux client and put in the address bar any of these:

    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.:

    Code:
    [root@localhost ~]# grep ^hosts /etc/nsswitch.conf
    hosts:      files dns
    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).

    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?
    Check out the VirtualHost declarative for Apache, it is what you need.

    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:

    Code:
    192.168.1.2 www.website1.com www.website2.com
    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").

  3. #3
    Just 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

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,318
    Quote Originally Posted by rout3rx View Post
    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
    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.:

    Code:
    ping <WEBSERVER_HOSTNAME>
    where WEBSERVER_HOSTNAME is the name of the webserver that you (hopefully) put in the /etc/hosts file on your client PC.

    If instead, you are using DNS, you can use the "host" command, e.g.:
    Code:
    host <WEBSERVER_HOSTNAME>
    This command should return any ip address records associated with that name on your DNS servers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •