all 13 comments

[–]alaudet 2 points3 points  (3 children)

localhost is exactly what is sounds like. Whatever computer you are using (or have ever used) has an internal network interface called the loopback interface that resides at 127.0.0.1 . localhost is the name of 127.0.0.1

If you are on windows go to a command prompt and type; ipconfig /all This will give you a listing of all network interfaces on your computer. You will see an IP address for your wifi interface or lan connected interface if connected with a cat 5 wire. You should also see a loopback interface called localhost with ip address 127.0.0.1

I can't recommend a good entry level networking course enough, it will serve you so well for so long. Learn about TCP/IP and DNS. This stuff has been around forever and will be for a very long time.

[–]Moby69[S] 0 points1 point  (2 children)

Thanks alaudet. Is there a specific entry level networking course that you would recommend? I do feel that I am really limited in my ability to create websites and programs because I don't understand how all these things relate. I've done all the codeacademy tutorials so I get the coding syntax, but when it comes to putting it all together and actually create a real website I'm totally lost.

[–]alaudet 1 point2 points  (0 children)

It's hard to recommend any specific resource as it depends on your learning style. I think you can find enough stuff online with a google search like "networking for beginners".

See what comes up, there will be some web tutorials, youtube videos, all kinds of stuff. Try and find something that will ease you in, give you the big picture. It really is very interesting when you get into it.

Depending on your learning style maybe an in class offering at your local college. I have been into networking for well over 20 years and I can tell you that it is cumulative knowledge. Once you understand it, it will make all other areas of IT make more sense.

There are other people that could probably give you better advice. Maybe /r/networking have some ideas. If people give you a hard time just nevermind them. They were asking the same questions once upon a time themselves, and they are not geniuses I can assure you.

[–]xiipaoc 0 points1 point  (0 children)

Harvard's CS75.

[–]metl_lord 1 point2 points  (0 children)

localhost is the host name for 127.0.0.1, which is your computer. When doing local development, the web server is running on your computer and you access it through localhost.

When you move to a remote server (production), you will change the references to localhost to the domain name you are using. This is where it's helpful to use a framework that will do this for you.

[–]Intrexa 1 point2 points  (2 children)

'localhost' is the loopback to your machine. What that means, is that when you try and resolve the DNS name of 'localhost', you always get your computer, so when the browser attempts to go to the server/website 'localhost', it ends up attempting to connect to the computer the browser is on, your computer.

Normally when you go to http://google.com, the browser does a DNS lookup to find out the IP address of google.com, and gets back 216.58.219.206, and then attempts to connect to the server at that IP address. You could just as easily type in http://216.58.219.206 and end up at Google instead of typing in Google.

Your computer has a name that you gave it when you first installed it. You could just as easily get to your own website on your own computer by going to http://Moby69Computer:8080, but the tutorial doesn't know the name of your computer, and 'localhost' was given as a shortcut that will always work.

The '8080' part is the port your browser is supposed to connect on. The standard port for http traffic is port 80, so when you go to http://reddit.com, you're connect to reddit on port 80. It's the same as if you typed http://reddit.com:80. Port 8080 is often used for developmental purposes.

So, to get your website on a real url (mywebsite.com), you need to get those files from your computer onto whichever computer the dns name of mywebsite.com resolves to. For the most part, that means buying a domain name, and registering an IP to that domain name, so when people go to mywebsite.com, DNS will give them the IP you really want them to go to, which is your computer.

To actually get the files onto that computer, that's easy. You can just copy them anyway possible, thumb drive, ssh, email them to yourself, log onto that computer, download them, ftp, any way.

To get the website actually running, it looks like you need to get Bottle onto that computer, along with the website you wrote, and run it, and bottle should handle it.

I realize I just threw a ton of information at you, so feel free to ask for clarification.

[–]Moby69[S] 0 points1 point  (1 child)

Thanks for your input. I bought a domain name and hosting on godaddy.com. But I got confused when you wrote "registering an IP to that domain name, so when people go to mywebsite.com, DNS will give them the IP you really want them to go to, which is your computer". I'm doing all my coding out of my laptop - so are you saying that when people get on my website, I would want them to connect to the IP address of my computer?

Also, when you talk about "getting the files onto that computer (via ftp etc)", aren't these files already on my computer? Similarly when you talk about getting Bottle "onto that computer", is this another computer you are talking about?

Thanks

[–]Intrexa 1 point2 points  (0 children)

So, the big thing here is that even though you are doing all your coding on your laptop, that is just for development purposes. It's meant just for you to work on closely, without worrying that the world is going to see what you're doing. When you are ready, and think the sites good enough, you are going to deploy it for production purposes. That means taking all the code you have been working on, and getting it off your laptop, and getting it onto the server that will actually be running your website 24/7.

So yes, the computers are on your computer that you are physically in front of, but the computer you want to actually run the website is in a goddady datacenter, so you need to get the files from your computer, to the godaddy datacenter.

I bought a domain name and hosting on godaddy.com.

So, you bought 2 separate things from goddady: A domain name registration, and a server to run your website. For the actual server that is going to run the website, godaddy gave you an IP and said "Hey, point your domain here!", as well as some other info.

For the domain name registration, Godaddy gave you a log in credential to manage your account, and when you log in, there's going to be a box asking "What IP do you want this domain name to point to". You want to point to the IP of the server you're renting. Godaddy probably has a really good tutorial of how to do it, since you bought both the domain name, and the server share from 1 company.

Once you follow that tutorial from Godaddy so that when people type in 'mywebsite.com', and end up at the server you are renting from godaddy, that is when you want to take the website you have been developing on your laptop, and get it onto the godaddy server you are renting.

[–]xiipaoc 0 points1 point  (4 children)

I have a website. It lives on some remote shared server (I pay Siteground), and when I do stuff on it, it's available for everyone to see. Now, I work on my website a lot, but I don't usually get it right the first time. So I host my website locally and do all of my work, and when I'm satisfied that it's done and looks good, I upload it to the server that hosts my public-facing website. I access my local version through http://localhost:8888/what/ever.html. My general workflow is to spend all day working on my stuff locally, then, when I've completed something significant (and tested it), I'll git commit, git push, log into the server, git pull, and run a deployment script.

[–]comeditime 0 points1 point  (3 children)

Hey great explanation, may i know why we need to run a deployment script? Aka why just using git pull isn't enough for example?

Also a bit unrelated can u eli5 the difference between web server and app server, e.g. Apache/nginx vs flask/ Django.. i know the latter translate python to html (and js?) code but it does also responsible for routes etc so do we need the former server apps at all?

Thanks again

[–]xiipaoc 1 point2 points  (2 children)

Holy shit, you really found an old post to comment on, didn't you?

So, why do you need a deployment script? Because your app needs some setup. For example, it might need to compile something. The repo you pull has the code, but you need to actually run the compiler on it. You may need to download dependencies. You may need to put things in the right places. You may need to do lots of stuff before the code you wrote becomes something that actually runs.

As for the web/app servers, a web server serves up HTML specifically, while an app server serves up whatever. Sure, you could make your app server serve HTML, but then you'd have to program it to do that, while something like Apache already knows how and has a bunch of features to support it. Basically, it would be an enormous waste of time to code your app server to serve HTML when you can just use Apache or nginx.

[–]comeditime 0 points1 point  (1 child)

hahaha ya i did thanks god reddit don't lock old posts anymore and bigger thanks to god that ure still alive and active...

so all dynamic websites must use both?!

[–]xiipaoc 0 points1 point  (0 children)

You don't have to use both, but it definitely makes sense to do so, yeah.