Operating Environment :
Ubuntu 14.04 LTS running under local VirtualBox
0. Take a look at the IP address of the server
Ifconfig
My server IP is 192.168.0.108
1. Installing Nginx
First update APT package management, then install Nginx
sudo apt-get updatesudo apt-get install Nginx
Then restart the local Nginx service.
Service Nginx Restart
Then type 192.168.0.108 in the browser
You should see the following Nginx Welcome page
2. Install node. js
Use apt to install node. JS directly in versions of Ubuntu 14.04
sudo apt-get install Nodejs
Check the version of Nodejs.
Nodejs-v
3. Create a simple node. js App
Create an app's folder "HelloApp" under/var/www, and then create a file named App.js
mkdir/var//var/www//var/www/HELLOAPPVI app.js
Here is the simple code, which is the demo on http://www.nodejs.org.
var http = require (' http '); http.createserver(function (req, res) { res.writehead (200, {' Content-type ': ' text/Plain '}); Res. End (' Hello world\n ');}). Listen (1337, ' 127.0.0.1'); Console.log (' Server running at http://127.0.0.1:1337/');
And then execute it with Nodejs.
Nodejs App.js
If you use putty, you can open a new terminal with Crul to see if it is normal to perform