-1

i was thinking of having 2 websites, and i'd write all my stuff (not using wordpress hosts for example). As far as i understood i can "link" several urls with a single web-hosting server. (Let's suppose i'd use a windows host, just because i'm more comfortable with windows than Linux). But how do i make that actual server work? Before spending money i'd like to know what i'm getting into.

All i can think of is i'd run the server program (like "node server.js"), but how does the url connect someone to that program instead of another "server.exe" in the same host? How does it all work? Everytime i look for tutorials or examples i get stuff that aims to non-programmers to "make your website easy using our templates". I dont want that.


As i said, this question has nothing to do with relative vs absolute urls. I've no idea where the one that flagged it has read something like that in my words.

Barnack
  • 921
  • 1
  • 8
  • 20
  • Possible duplicate of [Absolute vs relative URLs](https://stackoverflow.com/questions/2005079/absolute-vs-relative-urls) – Tripp Kinetics May 06 '18 at 17:42
  • You might want to take an HTML tutorial. Also, you might want to get a handle on how networks work. – Tripp Kinetics May 06 '18 at 17:43
  • @Tripp Kinetics how is my question a duplicate of that one? I know what urls are. What i dont know is how web servers work. How do these remote machines relate etcc. I can setup a local server, write the server program in c++, java, JavaScript for node. I know all this stuff. But i've never gone out of the LAN – Barnack May 06 '18 at 17:47
  • Read that question again. You are asking about absolute URLs vs relative ones. – Tripp Kinetics May 06 '18 at 17:48
  • Read SPECIFICALLY about the difference between the two. – Tripp Kinetics May 06 '18 at 17:49
  • As far as I understand you problem is that you can't connect to your webserver from the 'real internet' is that correct or did I misunderstood your question? – Aaron Stein May 06 '18 at 17:49
  • Read MY question again. Maybe i know what i'm asking better than you, just maybe. – Barnack May 06 '18 at 17:50
  • @Aaron Stein I never tried, i'd like to have a general idea before spending money on a web hosting service, that's it. But yeah that's the point of my question, understanding how setting up that stuff works. – Barnack May 06 '18 at 17:51

2 Answers2

0

To host your own webserver you need to decide which webserver to use:

You basically have two options: Apache or nginx

As you are hosting on windows and are only using the server for developing I can recommend XAMPP, it contains Apache, MariaDB(SQL Database based on MySql),PHP and Perl. Installation is usage is straight forward but if you want here is a tutorial to use it.

As Tripp Kinetics pointed out, you should probably check out some HTML tutorials or buy a book.

Aaron Stein
  • 526
  • 7
  • 18
0

Let's split it in parts, shall we?

As far as i understood i can "link" several urls with a single web-hosting server

If by that you mean that you can have more than 1 domain name for your web-server; yes you can. A domain name is something like "www.google.com" for instance.

So I understand that you're asking if you can have two different domain names, like "www.myweb.com" and "some.other-domainname.org" to point to your machine that will be hosting your website.

Yes you can. You should take a look on what a Domain Name System is. But basically, what a DNS does is translate these names into actual IP addresses.

This is done by having something called a name table that could look like:

"www.google.com" -> XXX.XXX.XXX.XXX (for IPv4 as an example)
"www.youtube.com" -> AAA.AAA.AAA.AAA

Since this is done by some kind of mapping you will also need a static IP address.

Both, static IP adresses and domain names must be bought or rented.

The way the things are connected, they also have to do with the ports where they operate. For instance, http requests operate in port 80 and SSH typically in port 22 if I remember correctly.

So what your web-server would do something similar to this:

listen to port 80 -> read the requested file (specified within the URL request) -> send it through that port 80 along with the http headers and payload as a response.


After that the browser requesting the file would read that http response, parse it and show that info into the actual window of the browser.




And you can also rent a webhosting service.
A webhosting service is basically somebody that already dealt with all of this gibberish and has machines that are ready to serve web content. You only have to upload your website into their webserver.

You can also buy a domain name and make it to point to that rented service

Some random IT boy
  • 7,569
  • 2
  • 21
  • 47
  • In case i have 2 "http" server programs to run, how does the machine know which program should handle the request my machine is reciving from outside? Two programs cant listen to the same port in the same machine if i remember correctly... – Barnack May 06 '18 at 18:10
  • That's right you can't have two servers on the same port. What will probably happen is that the second program that tries to serve requests in that port that is already in use will crash with some "port already in use exception or so". – Some random IT boy May 06 '18 at 18:12
  • For example; in another answer he mentioned about XAMPP. If you try to run XAMPP after "Skype.exe" the Apache server will crash, since Skype uses the ports 80 and 443 if I'm not mistaken – Some random IT boy May 06 '18 at 18:13
  • so i cant have two different "website" servers running in the same machine despite buying two different domains? – Barnack May 06 '18 at 18:16
  • you can, but you must reconfigure their operating port so they don't step on each other. – Some random IT boy May 06 '18 at 18:17
  • yeah i know i can "rent webhosting services where i can upload my website", the point is i'd prefer to have more freedom. So i can make it run my website, another friend's website, and still use it for some other stuff like testing etcc. I'd rather have the control to run which programs in the machine rather than submitting a standard-formatted website (as i said, something like wordpres is not in my mind) – Barnack May 06 '18 at 18:18
  • what you can also do is to include both websites in the same server and serve the website depending on the request. And I think you can work around this with some extra router configuration – Some random IT boy May 06 '18 at 18:19
  • 1
    Ok thanks for all the answers, i guess what i need to do now i just try out. – Barnack May 06 '18 at 18:21
  • Before paying some good amount of real money I'd recommend you to play a little bit with some local DNS servers in your local network. I've been playing with my Orange Pi as DNS with "Bind9" DNS server and it's working pretty well. My main machine is miquel.pi.local, the webserver is hosted at web.pi.local and etc. When you feel like you know what you're doing feel free to make one step further and buy/rent whatever you need. :) – Some random IT boy May 06 '18 at 18:25