Preface
It's just a coincidence to write a little nonsense about node. js.
Before that I would like to build a person's website, I feel that the existing blog/space can only give users limited control. So on AWS to apply for a free one-year VPS, bought a domain name , Baidu after the choice of the host on the hanging a nginx. After this I found that direct handwritten HTML is a very troublesome thing, and temporarily lost the direction of construction. Just changed the default homepage of Nginx, it is put on first.
In the new semester after this, I have a course on database principles, and before that I learned about some of the concepts of NoSQL through Wang Yin's blog . Database principle The teacher's praise of the traditional relational database made me feel very uncomfortable, so I went to the school library to find information about the NoSQL database, but most of the school books are outdated, I had to give up the search. This was followed by a chance to find the server as well as Web development related books when the luling Cow 's "node. js authoritative guide"was found. I was delighted when I found that the introduction to the book referred to the use of Nosql ( MongoDB) . So I simply browsed through the catalogue, and felt the idea of the personal site to be realized appeared. So I started learning node. js.
More, a few months ago I applied for Blog Park blog, but have been afraid to write something, this piece of essay as My virginity, also as I learn node. JS Study notes.
Environment Construction
I am delighted to see in a Chinese book the same approach to installing node. js under Win/osx/linux.
Now that I'm used to living and working under Linux, I'm using the desktop version of Ubuntu 14.10,
The first is to download node. js, which is different from the "node. js authoritative guide" In the nodejs.org is actually provided for running in the Linux environment in the binary files, but I chose to download the source package, compile and install.
version node-v0.10.33.
Download file node-v0.10.33.tar.gz, unzip
And then. We're going to use the terminal.
1 CD-To-Unzip directory
2 Execute $./configure
3 Make
4 sudo make install
It wasn't long before the installation was complete.
And then we can start to like Hello World.
First Test
before writing the code. First I have to build a writing environment, to get an IDE seems to be a bit bloated trouble, consider a bit. Authoring Environment after Take your time and finish the test first, so that I can use the editor that comes with the KDE suite directly, Kate, at least syntax highlighting.
Three sentences, respectively, refer to the HTTP module, creating a sentence that accepts and responds to HTTP and console output.
var http =require (' http '); Http.createserver (function (req,res) {res.writehead (200,{' content-type ': ' text/html '}); Res.write (' After writing, save it. Then use the terminal input
$ node File name
To execute, then you can enter 127.0.0.1:1337 in the browser to see the results.
Well, that's it.
node. JS Learning 00