tutorial on installing Node.js on an Ubuntu system _node.js

Source: Internet
Author: User
Tags install node line editor

Node.js is a WebSocket based push technology in real time Web applications. What kind of revolution does that mean? Well, after more than 20 years of stateless interaction based on a stateless request-back mechanism, we finally have a real-time, two-way connected Web application where both client and server can initiate communication and freely exchange data. In stark contrast to this is the traditional Web response pattern, the client always initiates the communication and the service side returns passively. In addition, these are based on open Web Components (HTML, CSS, and JS) that are running on standard 80 ports.

Some might say that we've been using Flash and Java applets for years--but in practice, they're just using the network to deliver data to the sandbox environment on the client. They are all isolated, and often operate on non-standard ports that require additional permissions.

With its unique advantages, Node.js has now played a key role in the products of many famous companies.

The main idea of node.js is to maintain lightweight and efficient use of non-blocking, event-driven I/O operations to handle data-intensive real-time applications across platforms (across distributed devices). That sounds a little bit around the mouth.

What it really means is that node.js is not a silver-bullet platform for the world that is about to dominate web development. Instead, it is a platform to meet special needs. You certainly wouldn't want to use Node.js to do CPU-intensive operations. In fact, using it for heavy computing is tantamount to discarding almost all of the benefits of Node. The real bright spot for Node is to build high-performance, highly scalable Internet applications-because it can handle large and highly-throughput concurrent connections.

Base system Installation
Node can be perfectly run on linux,macintosh,solaris systems, and Ubuntu is quite appropriate for Linux distributions. That's why we're trying to install Node.js on Ubuntu 15.04, and of course you can use the same steps to install it on 14.04.

1) system resources
The basic system resources required for node.js depend on your architectural needs. This tutorial will be done on a server with 1GB memory, 1GHz processor, and 10GB disk space, with minimal installation and no need to install a WEB server or database server.

2) System Update
Before we install Node.js, we recommend that you update the system to the latest patches and upgrades, so log in to the system and run the following command using Superuser:

# Apt-get Update


3) Installation Dependency
Node.js only need some basic system and software features on your server, such as ' make ', ' gcc ' and ' wget '. If you have not installed them, run the following command to install:

# apt-get Install python gcc make g++ wget


Download the latest version of node JS v4.0.0
Access link Node JS Download Page Download source code.

Copy the link to the latest source code, and then download it with the wget command as follows:

# wget https://nodejs.org/download/rc/v4.0.0-rc.1/node-v4.0.0-rc.1.tar.gz


Use command tar to decompress after download:

# TAR-ZXVF Node-v4.0.0-rc.1.tar.gz



Install Node JS v4.0.0
You can now start compiling node.js with a good download source code. Before you start compiling, you need to switch to the source code uncompressed directory on Ubuntu server and run the Configure script to configure the source code.

root@ubuntu-15:~/node-v4.0.0-rc.1#./configure



Now run the command ' make install ' compile installation node.js:

root@ubuntu-15:~/node-v4.0.0-rc.1# make Install


The make command takes a few minutes to complete the compilation, and the quiet wait for a while.

Verifying Node.js Installation
Once the compilation task is complete, we can start verifying that the installation work is OK. We run the following command to confirm the Node.js version.

root@ubuntu-15:~# node-v


V4.0.0-pre
Run node with no parameters at the command line will enter the REPL (Read-eval-print-loop, read-execute-output-loop) mode, which has a simplified version of the Emacs line editor, through which you can run JS interactively and view the results of the run.

Writing test procedures
We can also write a very simple terminal program to test the success of the installation and work properly. To do this, we will create a "test.js" file that contains the following code, as follows:

root@ubuntu-15:~# vim test.js
var util = require ("util");
Console.log ("hello! This is a Node Test program ";
: wq!


To run the above program now, run the following command at the command line.

root@ubuntu-15:~# node Test.js



In a successful installation of Node JS in the environment to run the above program will be shown on the screen above the output, the program loaded class "Util" to the variable "util", and then use the object "util" run the terminal task, Console.log This command function similar to the cou in C + + T

Conclusion
This is it. If you are just starting to use Node.js to develop your application, hopefully this article will help you understand the node.js by installing and running Node.js on Ubuntu. Finally, we can expect that the Node JS v4.0.0 can achieve significant performance gains.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.