I have two different domain names, which I want to host on the same private hosting I have. I want them to point to the same IP address and yet have different content (of course). How can I do that? Are there different ways to do this? In that case what is the best way. Thanks.
You'll probably want to use Apache's Virtual Hosting. It's a well-supported method for hosting many domains on a single IP address.
Specifically, name-based virtual hosts: http://httpd.apache.org/docs/2.2/vhosts/name-based.html
Apache2 supports serving different contents depending on domain names, even if all those domains resolve to the same IP address. Each of the domain names is handled by a virtual host, thus the name name-based virtual host.
Here is a sample configuration for two domains:
You will find the official documentation on name-based virtual host support here.
However, please note this will only work with plain HTTP connections, not with HTTPS (HTTP over SSL): name-based virtual hosts rely on knowing what name is being requested, but this information can't be known by Apache until the encrypted SSL connection is established.
If you need to have your setup working with HTTPS too, you need to rely on an extension to the SSL protocol called Server Name Indication (SNI)(RFC4366). Basically, SNI-enabled clients (ex: web browsers) add an extra plain text information when establishing the encrypted SSL connection, allowing the server to know the name being requested before the SSL connection is ready.
All browsers do not support SNI yet. At the time of writing and according to Wikipedia, these ones do:
Hosting several name-based virtual hosts accessible trough HTTPS requires you to enable mod_ssl and add a similar configuration as in the example above:
Remember that using SSL requires you to buy SSL certificates for you domains - or to generate some auto-signed ones, and to configure Apache to use them for SSL connections.