Reputation: 31
I am a beginner and I learned only HTML and CSS.
When I tried to host my website I opened this look at method two it is about localhost I searched a lot about it but I didn't understand anything like:
It is a server side like PHP and phpMyAdmin
localhost is a hostname that means this computer and may be used to access the computer's own network services via its loopback network interface
I can't understand anything is it like WikiHow said and I can host my HTML and CSS website for free? Or is it like Google said?
Upvotes: 2
Views: 8734
Reputation: 127
You can try some IDE for coding, such as RubyMine or PHPStorm, and they're creating localhost for you, when you're running your code in web browser. I think that can be helpful because some of Chrome Extensions for web development doesn't work with local pages, for example, page rulers or so on.
Upvotes: 0
Reputation: 41
First of all when learning CSS and HTML, you can simply just open the file location of the HTML in your web browser. There is truly no known reasons for someone doing CSS, HTML, and Javascript programming that is self-contained (i.e. no databases or crap like that)to NEED or even BENEFIT from having a web server set up.
That said, I'm a beginner, too, in a sense (I've just returned to web programming and found it so much easier and more fun than it was 7 years ago!) and I have been using a web server and localhost
every time I program lately. This is because I'm programming in Ruby
and I'm using a library for Ruby called Sinatra
that makes web programming with Ruby SUPER easy! Anyways, when you use Sinatra, you must have a web server running, and you must use localhost
rather than just opening a file location on your computer. Why? Because Sinatra replies to the GET
and POST
requests that a web server makes in response to a user's actions.
So, with Ruby installed, and Sinatra installed (I'm on Windows, not that it matters much) I simply use the Start Command Prompt with Ruby
shortcut that was installed with Ruby and then at that command prompt I go to the directory with my program and type, e.g., ruby test.rb
, and then I open Chrome and type localhost:3456
. That's the default port for Sinatra. It can be changed easily. If you want examples of simple Ruby programs using Sinatra that you can use to see this web server behavior without even having to install a regular web server (you'll instead be using the lightweight one that comes WITH Sinatra's installation [on all platforms, I think]), you can find such examples if you Google Learn Ruby the Hard Way Exercise 50/51/52
. That site is great. I've only used those 3 so that's why I chose them, there may be more.
Also, and again I've only been doing this for one month, on my own in a non-professional non-academic setting, I installed Apache
, Googled that a bit, and it was also easy to install and serve up a HTML file to myself at least, and I think I got my Ruby program running easily, you just have to make sure you understand what the directory paths are supposed to be.
So, even though you don't need to unless you're doing something beyond HTML and CSS and basic Javascript, go ahead and either install Ruby and then follow Exercise 50 in Ruby the Hard Way to see how localhost works (this is easier than doing Apache IMO but that was my experience, plus you'll get exposed to Ruby with very easy copy and pasting from Ruby the Hard Way), or install Apache, it's super easy, get it running, and just find out what directory it's going to look for it's index.html on your system and make sure you put your index.html
in that correct spot, load up your browser, and type localhost in the address bar (on chrome on windows 7 that's all you need, I bet OSX and Linux are same).
In fact, type localhost
into Chrome (at least) and you'll see an ERR_CN_REFUSED
or something like that. Note that Chrome would normally search the Internet. So, that loopback
localhost functionality is in the OS... Cool stuff, good luck.
Upvotes: 4
Reputation: 36
Localhost is just your local computer. It has an ip4 address 127.0.0.1 ipv6 ::1.
So if you connect to localhost you always connect to your own computer (usually not visible to the outside world unless you leave your computer on and stay connected to the internet and have your router/firewall configured that it forwards traffic to your PC (only do that when you know what your are doing).
Upvotes: 2